Re: [PATCH] cpuset: fix a regression in validating config change
Hello, Li. I dropped the make_*_empty variables and just put the conditionals directly inside the outer if. Please scream if I messed it up. Applied to cgroup/for-3.11-fixes. Thanks. --- 8< >From 1c09b195d37fa459844036f429a0f378e70c3db6 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Wed, 21 Aug 2013 10:22:28 +0800 Subject: [PATCH] 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 88fa523bff295f1d60244a54833480b02f775152 ("cpuset: allow to move tasks to empty cpusets"). tj: Dropped temp bool variables and nestes the conditionals directly. Signed-off-by: Li Zefan Signed-off-by: Tejun Heo --- kernel/cpuset.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 010a008..ea1966d 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c @@ -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 -* have empty cpus_allowed or mems_allowed. +* be changed to have empty cpus_allowed or mems_allowed. */ ret = -ENOSPC; - if ((cgroup_task_count(cur->css.cgroup) || cur->attach_in_progress) && - (cpumask_empty(trial->cpus_allowed) && -nodes_empty(trial->mems_allowed))) - goto out; + if ((cgroup_task_count(cur->css.cgroup) || cur->attach_in_progress)) { + if (!cpumask_empty(cur->cpus_allowed) && + cpumask_empty(trial->cpus_allowed)) + goto out; + if (!nodes_empty(cur->mems_allowed) && + nodes_empty(trial->mems_allowed)) + goto out; + } ret = 0; out: -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] cpuset: fix a regression in validating config change
Hello, Li. I dropped the make_*_empty variables and just put the conditionals directly inside the outer if. Please scream if I messed it up. Applied to cgroup/for-3.11-fixes. Thanks. --- 8 From 1c09b195d37fa459844036f429a0f378e70c3db6 Mon Sep 17 00:00:00 2001 From: Li Zefan lize...@huawei.com Date: Wed, 21 Aug 2013 10:22:28 +0800 Subject: [PATCH] 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 88fa523bff295f1d60244a54833480b02f775152 (cpuset: allow to move tasks to empty cpusets). tj: Dropped temp bool variables and nestes the conditionals directly. Signed-off-by: Li Zefan lize...@huawei.com Signed-off-by: Tejun Heo t...@kernel.org --- kernel/cpuset.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 010a008..ea1966d 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c @@ -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 -* have empty cpus_allowed or mems_allowed. +* be changed to have empty cpus_allowed or mems_allowed. */ ret = -ENOSPC; - if ((cgroup_task_count(cur-css.cgroup) || cur-attach_in_progress) - (cpumask_empty(trial-cpus_allowed) -nodes_empty(trial-mems_allowed))) - goto out; + if ((cgroup_task_count(cur-css.cgroup) || cur-attach_in_progress)) { + if (!cpumask_empty(cur-cpus_allowed) + cpumask_empty(trial-cpus_allowed)) + goto out; + if (!nodes_empty(cur-mems_allowed) + nodes_empty(trial-mems_allowed)) + goto out; + } ret = 0; out: -- 1.8.3.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] 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 88fa523bff295f1d60244a54833480b02f775152 ("cpuset: allow to move tasks to empty cpusets"). Signed-off-by: Li Zefan --- kernel/cpuset.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 0b5b9a3..70ab3fd 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c @@ -425,6 +425,8 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) struct cgroup_subsys_state *css; struct cpuset *c, *par; int ret; + bool make_cpus_empty; + bool make_mems_empty; rcu_read_lock(); @@ -464,12 +466,15 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) /* * 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; + make_cpus_empty = !cpumask_empty(cur->cpus_allowed) && + cpumask_empty(trial->cpus_allowed); + make_mems_empty = !nodes_empty(cur->mems_allowed) && + nodes_empty(trial->mems_allowed); if ((cgroup_task_count(cur->css.cgroup) || cur->attach_in_progress) && - (cpumask_empty(trial->cpus_allowed) && -nodes_empty(trial->mems_allowed))) + (make_cpus_empty || make_mems_empty)) goto out; ret = 0; -- 1.8.0.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] 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 88fa523bff295f1d60244a54833480b02f775152 (cpuset: allow to move tasks to empty cpusets). Signed-off-by: Li Zefan lize...@huawei.com --- kernel/cpuset.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 0b5b9a3..70ab3fd 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c @@ -425,6 +425,8 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) struct cgroup_subsys_state *css; struct cpuset *c, *par; int ret; + bool make_cpus_empty; + bool make_mems_empty; rcu_read_lock(); @@ -464,12 +466,15 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) /* * 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; + make_cpus_empty = !cpumask_empty(cur-cpus_allowed) + cpumask_empty(trial-cpus_allowed); + make_mems_empty = !nodes_empty(cur-mems_allowed) + nodes_empty(trial-mems_allowed); if ((cgroup_task_count(cur-css.cgroup) || cur-attach_in_progress) - (cpumask_empty(trial-cpus_allowed) -nodes_empty(trial-mems_allowed))) + (make_cpus_empty || make_mems_empty)) goto out; ret = 0; -- 1.8.0.2 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/