cpuset: fix a regression in validating config change
It's not allowed to clear masks of a cpuset if there're tasks in it,
but it's broken:
# mkdir /cgroup/sub
# echo 0 > /cgroup/sub/cpuset.cpus
# echo 0 > /cgroup/sub/cpuset.mems
# echo $$ > /cgroup/sub/tasks
# echo > /cgroup/sub/cpuset.cpus
(should fail)
This bug was introduced by commit 88fa523bff
("cpuset: allow to move tasks to empty cpusets").
tj: Dropped temp bool variables and nestes the conditionals directly.
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
a903f0865a
commit
1c09b195d3
1 changed files with 9 additions and 5 deletions
|
@ -475,13 +475,17 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cpusets with tasks - existing or newly being attached - can't
|
* Cpusets with tasks - existing or newly being attached - can't
|
||||||
* have empty cpus_allowed or mems_allowed.
|
* be changed to have empty cpus_allowed or mems_allowed.
|
||||||
*/
|
*/
|
||||||
ret = -ENOSPC;
|
ret = -ENOSPC;
|
||||||
if ((cgroup_task_count(cur->css.cgroup) || cur->attach_in_progress) &&
|
if ((cgroup_task_count(cur->css.cgroup) || cur->attach_in_progress)) {
|
||||||
(cpumask_empty(trial->cpus_allowed) &&
|
if (!cpumask_empty(cur->cpus_allowed) &&
|
||||||
nodes_empty(trial->mems_allowed)))
|
cpumask_empty(trial->cpus_allowed))
|
||||||
goto out;
|
goto out;
|
||||||
|
if (!nodes_empty(cur->mems_allowed) &&
|
||||||
|
nodes_empty(trial->mems_allowed))
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Reference in a new issue