Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350346
b: refs/heads/master
c: 452477f
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo committed Jan 7, 2013
1 parent bea5878 commit 8eb4922
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8d03394877ecdf87e1d694664c460747b8e05aa1
refs/heads/master: 452477fa68c6d8ef80adebd05194c1c157ad9a53
28 changes: 26 additions & 2 deletions trunk/kernel/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ struct cpuset {

struct fmeter fmeter; /* memory_pressure filter */

/*
* Tasks are being attached to this cpuset. Used to prevent
* zeroing cpus/mems_allowed between ->can_attach() and ->attach().
*/
int attach_in_progress;

/* partition number for rebuild_sched_domains() */
int pn;

Expand Down Expand Up @@ -468,9 +474,12 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
goto out;
}

/* Cpusets with tasks can't have empty cpus_allowed or mems_allowed */
/*
* Cpusets with tasks - existing or newly being attached - can't
* have empty cpus_allowed or mems_allowed.
*/
ret = -ENOSPC;
if (cgroup_task_count(cur->css.cgroup) &&
if ((cgroup_task_count(cur->css.cgroup) || cur->attach_in_progress) &&
(cpumask_empty(trial->cpus_allowed) ||
nodes_empty(trial->mems_allowed)))
goto out;
Expand Down Expand Up @@ -1386,9 +1395,21 @@ static int cpuset_can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
return ret;
}

/*
* Mark attach is in progress. This makes validate_change() fail
* changes which zero cpus/mems_allowed.
*/
cs->attach_in_progress++;

return 0;
}

static void cpuset_cancel_attach(struct cgroup *cgrp,
struct cgroup_taskset *tset)
{
cgroup_cs(cgrp)->attach_in_progress--;
}

/*
* Protected by cgroup_mutex. cpus_attach is used only by cpuset_attach()
* but we can't allocate it dynamically there. Define it global and
Expand Down Expand Up @@ -1441,6 +1462,8 @@ static void cpuset_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
&cpuset_attach_nodemask_to);
mmput(mm);
}

cs->attach_in_progress--;
}

/* The various types of files and directories in a cpuset file system */
Expand Down Expand Up @@ -1908,6 +1931,7 @@ struct cgroup_subsys cpuset_subsys = {
.css_offline = cpuset_css_offline,
.css_free = cpuset_css_free,
.can_attach = cpuset_can_attach,
.cancel_attach = cpuset_cancel_attach,
.attach = cpuset_attach,
.subsys_id = cpuset_subsys_id,
.base_cftypes = files,
Expand Down

0 comments on commit 8eb4922

Please sign in to comment.