mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-30 07:34:12 +08:00
cpusets: decrustify cpuset mask update code
Decrustify the kernel/cpuset.c 'cpus' and 'mems' updating code. Other than subtle improvements in the consistency of identifying white space at the beginning and end of passed in masks, this doesn't make any visible difference in behaviour. But it's one or two hundred kernel text bytes smaller, and easier to understand. [akpm@linux-foundation.org: coding-style fix] Signed-off-by: Paul Jackson <pj@sgi.com> Reviewed-by: Paul Menage <menage@google.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
029190c515
commit
020958b627
@ -488,6 +488,14 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
|
|||||||
return -EINVAL;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,11 +718,13 @@ static int update_cpumask(struct cpuset *cs, char *buf)
|
|||||||
trialcs = *cs;
|
trialcs = *cs;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We allow a cpuset's cpus_allowed to be empty; if it has attached
|
* An empty cpus_allowed is ok iff there are no tasks in the cpuset.
|
||||||
* tasks, we'll catch it later when we validate the change and return
|
* Since cpulist_parse() fails on an empty mask, we special case
|
||||||
* -ENOSPC.
|
* 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);
|
cpus_clear(trialcs.cpus_allowed);
|
||||||
} else {
|
} else {
|
||||||
retval = cpulist_parse(buf, trialcs.cpus_allowed);
|
retval = cpulist_parse(buf, trialcs.cpus_allowed);
|
||||||
@ -722,10 +732,6 @@ static int update_cpumask(struct cpuset *cs, char *buf)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
cpus_and(trialcs.cpus_allowed, trialcs.cpus_allowed, cpu_online_map);
|
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);
|
retval = validate_change(cs, &trialcs);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
return retval;
|
return retval;
|
||||||
@ -830,29 +836,19 @@ static int update_nodemask(struct cpuset *cs, char *buf)
|
|||||||
trialcs = *cs;
|
trialcs = *cs;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We allow a cpuset's mems_allowed to be empty; if it has attached
|
* An empty mems_allowed is ok iff there are no tasks in the cpuset.
|
||||||
* tasks, we'll catch it later when we validate the change and return
|
* Since nodelist_parse() fails on an empty mask, we special case
|
||||||
* -ENOSPC.
|
* 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);
|
nodes_clear(trialcs.mems_allowed);
|
||||||
} else {
|
} else {
|
||||||
retval = nodelist_parse(buf, trialcs.mems_allowed);
|
retval = nodelist_parse(buf, trialcs.mems_allowed);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto done;
|
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,
|
nodes_and(trialcs.mems_allowed, trialcs.mems_allowed,
|
||||||
node_states[N_HIGH_MEMORY]);
|
node_states[N_HIGH_MEMORY]);
|
||||||
oldmem = cs->mems_allowed;
|
oldmem = cs->mems_allowed;
|
||||||
@ -860,12 +856,6 @@ static int update_nodemask(struct cpuset *cs, char *buf)
|
|||||||
retval = 0; /* Too easy - nothing to do */
|
retval = 0; /* Too easy - nothing to do */
|
||||||
goto done;
|
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);
|
retval = validate_change(cs, &trialcs);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
Loading…
Reference in New Issue
Block a user