Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 71466
b: refs/heads/master
c: 020958b
h: refs/heads/master
v: v3
  • Loading branch information
Paul Jackson authored and Linus Torvalds committed Oct 19, 2007
1 parent e11ce4b commit 5acbd19
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 31 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: 029190c515f15f512ac85de8fc686d4dbd0ae731
refs/heads/master: 020958b6272882c1a8bfbe5f3e0927f3845c2698
50 changes: 20 additions & 30 deletions trunk/kernel/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,14 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
return -EINVAL;
}

/* Cpusets with tasks can't have empty cpus_allowed or mems_allowed */
if (cgroup_task_count(cur->css.cgroup)) {
if (cpus_empty(trial->cpus_allowed) ||
nodes_empty(trial->mems_allowed)) {
return -ENOSPC;
}
}

return 0;
}

Expand Down Expand Up @@ -710,22 +718,20 @@ static int update_cpumask(struct cpuset *cs, char *buf)
trialcs = *cs;

/*
* We allow a cpuset's cpus_allowed to be empty; if it has attached
* tasks, we'll catch it later when we validate the change and return
* -ENOSPC.
* An empty cpus_allowed is ok iff there are no tasks in the cpuset.
* Since cpulist_parse() fails on an empty mask, we special case
* that parsing. The validate_change() call ensures that cpusets
* with tasks have cpus.
*/
if (!buf[0] || (buf[0] == '\n' && !buf[1])) {
buf = strstrip(buf);
if (!*buf) {
cpus_clear(trialcs.cpus_allowed);
} else {
retval = cpulist_parse(buf, trialcs.cpus_allowed);
if (retval < 0)
return retval;
}
cpus_and(trialcs.cpus_allowed, trialcs.cpus_allowed, cpu_online_map);
/* cpus_allowed cannot be empty for a cpuset with attached tasks. */
if (cgroup_task_count(cs->css.cgroup) &&
cpus_empty(trialcs.cpus_allowed))
return -ENOSPC;
retval = validate_change(cs, &trialcs);
if (retval < 0)
return retval;
Expand Down Expand Up @@ -830,42 +836,26 @@ static int update_nodemask(struct cpuset *cs, char *buf)
trialcs = *cs;

/*
* We allow a cpuset's mems_allowed to be empty; if it has attached
* tasks, we'll catch it later when we validate the change and return
* -ENOSPC.
* An empty mems_allowed is ok iff there are no tasks in the cpuset.
* Since nodelist_parse() fails on an empty mask, we special case
* that parsing. The validate_change() call ensures that cpusets
* with tasks have memory.
*/
if (!buf[0] || (buf[0] == '\n' && !buf[1])) {
buf = strstrip(buf);
if (!*buf) {
nodes_clear(trialcs.mems_allowed);
} else {
retval = nodelist_parse(buf, trialcs.mems_allowed);
if (retval < 0)
goto done;
if (!nodes_intersects(trialcs.mems_allowed,
node_states[N_HIGH_MEMORY])) {
/*
* error if only memoryless nodes specified.
*/
retval = -ENOSPC;
goto done;
}
}
/*
* Exclude memoryless nodes. We know that trialcs.mems_allowed
* contains at least one node with memory.
*/
nodes_and(trialcs.mems_allowed, trialcs.mems_allowed,
node_states[N_HIGH_MEMORY]);
oldmem = cs->mems_allowed;
if (nodes_equal(oldmem, trialcs.mems_allowed)) {
retval = 0; /* Too easy - nothing to do */
goto done;
}
/* mems_allowed cannot be empty for a cpuset with attached tasks. */
if (cgroup_task_count(cs->css.cgroup) &&
nodes_empty(trialcs.mems_allowed)) {
retval = -ENOSPC;
goto done;
}
retval = validate_change(cs, &trialcs);
if (retval < 0)
goto done;
Expand Down

0 comments on commit 5acbd19

Please sign in to comment.