cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled
@ 2015-02-13  3:19 Zefan Li
       [not found] ` <54DD6D55.2070603-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Zefan Li @ 2015-02-13  3:19 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Christian Brauner, Serge Hallyn, Stéphane Graber, LKML,
	Cgroups

If clone_children is enabled, effective masks won't be initialized
due to the bug:

  # mount -t cgroup -o cpuset xxx /mnt
  # echo 1 > cgroup.clone_children
  # mkdir /mnt/tmp
  # cat /mnt/tmp/
  # cat cpuset.effective_cpus

  # cat cpuset.cpus
  0-15

And then this cpuset won't constrain the tasks in it.

Either the bug or the fix has no effect on unified hierarchy, as
there's no clone_chidren flag there any more.

Reported-by: Christian Brauner <christianvanbrauner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reported-by: Serge Hallyn <serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # 3.17+
Signed-off-by: Zefan Li <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 kernel/cpuset.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 64b257f..7e9d711 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1992,7 +1992,9 @@ static int cpuset_css_online(struct cgroup_subsys_state *css)
 
 	spin_lock_irq(&callback_lock);
 	cs->mems_allowed = parent->mems_allowed;
+	cs->effective_mems = parent->mems_allowed;
 	cpumask_copy(cs->cpus_allowed, parent->cpus_allowed);
+	cpumask_copy(cs->effective_cpus, parent->cpus_allowed);
 	spin_unlock_irq(&callback_lock);
 out_unlock:
 	mutex_unlock(&cpuset_mutex);
-- 
1.8.0.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] cpuset: fix a warning when clearing configured masks in old hierarchy
       [not found] ` <54DD6D55.2070603-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2015-02-13  3:20   ` Zefan Li
  2015-02-13  3:21   ` [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled Zefan Li
  2015-02-13  3:58   ` [PATCH 3/3] cpuset: Fix cpuset sched_relax_domain_level Zefan Li
  2 siblings, 0 replies; 7+ messages in thread
From: Zefan Li @ 2015-02-13  3:20 UTC (permalink / raw)
  To: Tejun Heo; +Cc: LKML, Cgroups

When we clear cpuset.cpus, cpuset.effective_cpus won't be cleared:

  # mount -t cgroup -o cpuset xxx /mnt
  # mkdir /mnt/tmp
  # echo 0 > /mnt/tmp/cpuset.cpus
  # echo > /mnt/tmp/cpuset.cpus
  # cat cpuset.cpus

  # cat cpuset.effective_cpus
  0-15

And a kernel warning in update_cpumasks_hier() is triggered:

 ------------[ cut here ]------------
 WARNING: CPU: 0 PID: 4028 at kernel/cpuset.c:894 update_cpumasks_hier+0x471/0x650()

Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # 3.17+
Signed-off-by: Zefan Li <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 kernel/cpuset.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 7e9d711..29463c2 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -873,7 +873,7 @@ static void update_cpumasks_hier(struct cpuset *cs, struct cpumask *new_cpus)
 		 * If it becomes empty, inherit the effective mask of the
 		 * parent, which is guaranteed to have some CPUs.
 		 */
-		if (cpumask_empty(new_cpus))
+		if (cgroup_on_dfl(cp->css.cgroup) && cpumask_empty(new_cpus))
 			cpumask_copy(new_cpus, parent->effective_cpus);
 
 		/* Skip the whole subtree if the cpumask remains the same. */
@@ -1129,7 +1129,7 @@ static void update_nodemasks_hier(struct cpuset *cs, nodemask_t *new_mems)
 		 * If it becomes empty, inherit the effective mask of the
 		 * parent, which is guaranteed to have some MEMs.
 		 */
-		if (nodes_empty(*new_mems))
+		if (cgroup_on_dfl(cp->css.cgroup) && nodes_empty(*new_mems))
 			*new_mems = parent->effective_mems;
 
 		/* Skip the whole subtree if the nodemask remains the same. */
-- 
1.8.0.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled
       [not found] ` <54DD6D55.2070603-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
  2015-02-13  3:20   ` [PATCH 2/3] cpuset: fix a warning when clearing configured masks in old hierarchy Zefan Li
@ 2015-02-13  3:21   ` Zefan Li
  2015-02-13  3:58   ` [PATCH 3/3] cpuset: Fix cpuset sched_relax_domain_level Zefan Li
  2 siblings, 0 replies; 7+ messages in thread
From: Zefan Li @ 2015-02-13  3:21 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Jason Low, LKML, Cgroups

From: Jason Low <jason.low2-VXdhtT5mjnY@public.gmane.org>

The cpuset.sched_relax_domain_level can control how far we do
immediate load balancing on a system. However, it was found on recent
kernels that echo'ing a value into cpuset.sched_relax_domain_level
did not reduce any immediate load balancing.

The reason this occurred was because the update_domain_attr_tree() traversal
did not update for the "top_cpuset". This resulted in nothing being changed
when modifying the sched_relax_domain_level parameter.

This patch is able to address that problem by having update_domain_attr_tree()
allow updates for the root in the cpuset traversal.

Fixes: fc560a26acce ("cpuset: replace cpuset->stack_list with cpuset_for_each_descendant_pre()")
Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # 3.9+
Signed-off-by: Jason Low <jason.low2-VXdhtT5mjnY@public.gmane.org>
Signed-off-by: Zefan Li <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 kernel/cpuset.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 29463c2..9e25599 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -548,9 +548,6 @@ static void update_domain_attr_tree(struct sched_domain_attr *dattr,
 
 	rcu_read_lock();
 	cpuset_for_each_descendant_pre(cp, pos_css, root_cs) {
-		if (cp == root_cs)
-			continue;
-
 		/* skip the whole subtree if @cp doesn't have any CPU */
 		if (cpumask_empty(cp->cpus_allowed)) {
 			pos_css = css_rightmost_descendant(pos_css);
-- 
1.8.0.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] cpuset: Fix cpuset sched_relax_domain_level
       [not found] ` <54DD6D55.2070603-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
  2015-02-13  3:20   ` [PATCH 2/3] cpuset: fix a warning when clearing configured masks in old hierarchy Zefan Li
  2015-02-13  3:21   ` [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled Zefan Li
@ 2015-02-13  3:58   ` Zefan Li
  2 siblings, 0 replies; 7+ messages in thread
From: Zefan Li @ 2015-02-13  3:58 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Jason Low, LKML, Cgroups

From: Jason Low <jason.low2-VXdhtT5mjnY@public.gmane.org>

The cpuset.sched_relax_domain_level can control how far we do
immediate load balancing on a system. However, it was found on recent
kernels that echo'ing a value into cpuset.sched_relax_domain_level
did not reduce any immediate load balancing.

The reason this occurred was because the update_domain_attr_tree() traversal
did not update for the "top_cpuset". This resulted in nothing being changed
when modifying the sched_relax_domain_level parameter.

This patch is able to address that problem by having update_domain_attr_tree()
allow updates for the root in the cpuset traversal.

Fixes: fc560a26acce ("cpuset: replace cpuset->stack_list with cpuset_for_each_descendant_pre()")
Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # 3.9+
Signed-off-by: Jason Low <jason.low2-VXdhtT5mjnY@public.gmane.org>
Signed-off-by: Zefan Li <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---

This is a resend. I forgot to edit the subject when sending this patch...

---
 kernel/cpuset.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 29463c2..9e25599 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -548,9 +548,6 @@ static void update_domain_attr_tree(struct sched_domain_attr *dattr,
 
 	rcu_read_lock();
 	cpuset_for_each_descendant_pre(cp, pos_css, root_cs) {
-		if (cp == root_cs)
-			continue;
-
 		/* skip the whole subtree if @cp doesn't have any CPU */
 		if (cpumask_empty(cp->cpus_allowed)) {
 			pos_css = css_rightmost_descendant(pos_css);
-- 1.8.0.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled
  2015-02-13  3:19 [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled Zefan Li
       [not found] ` <54DD6D55.2070603-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2015-02-13  6:19 ` Serge E. Hallyn
  2015-03-02  6:16 ` Zefan Li
  2 siblings, 0 replies; 7+ messages in thread
From: Serge E. Hallyn @ 2015-02-13  6:19 UTC (permalink / raw)
  To: Zefan Li
  Cc: Tejun Heo, Christian Brauner, Serge Hallyn, Stéphane Graber,
	LKML, Cgroups

Quoting Zefan Li (lizefan@huawei.com):
> If clone_children is enabled, effective masks won't be initialized
> due to the bug:
> 
>   # mount -t cgroup -o cpuset xxx /mnt
>   # echo 1 > cgroup.clone_children
>   # mkdir /mnt/tmp
>   # cat /mnt/tmp/
>   # cat cpuset.effective_cpus
> 
>   # cat cpuset.cpus
>   0-15
> 
> And then this cpuset won't constrain the tasks in it.
> 
> Either the bug or the fix has no effect on unified hierarchy, as
> there's no clone_chidren flag there any more.
> 
> Reported-by: Christian Brauner <christianvanbrauner@gmail.com>
> Reported-by: Serge Hallyn <serge.hallyn@ubuntu.com>

Thanks - this give sme the correct output in /proc/self/status and
cpuest.cpus.  (I didn't do a stress test but that seems unlikely to
be broken)

Tested-by: Serge Hallyn <serge.hallyn@canonical.com>

> Cc: <stable@vger.kernel.org> # 3.17+
> Signed-off-by: Zefan Li <lizefan@huawei.com>
> ---
>  kernel/cpuset.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/cpuset.c b/kernel/cpuset.c
> index 64b257f..7e9d711 100644
> --- a/kernel/cpuset.c
> +++ b/kernel/cpuset.c
> @@ -1992,7 +1992,9 @@ static int cpuset_css_online(struct cgroup_subsys_state *css)
>  
>  	spin_lock_irq(&callback_lock);
>  	cs->mems_allowed = parent->mems_allowed;
> +	cs->effective_mems = parent->mems_allowed;
>  	cpumask_copy(cs->cpus_allowed, parent->cpus_allowed);
> +	cpumask_copy(cs->effective_cpus, parent->cpus_allowed);
>  	spin_unlock_irq(&callback_lock);
>  out_unlock:
>  	mutex_unlock(&cpuset_mutex);
> -- 
> 1.8.0.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled
  2015-02-13  3:19 [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled Zefan Li
       [not found] ` <54DD6D55.2070603-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
  2015-02-13  6:19 ` [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled Serge E. Hallyn
@ 2015-03-02  6:16 ` Zefan Li
  2015-03-02 16:55   ` Tejun Heo
  2 siblings, 1 reply; 7+ messages in thread
From: Zefan Li @ 2015-03-02  6:16 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Christian Brauner, Serge Hallyn, Stéphane Graber, LKML,
	Cgroups

Hi Tejun,

Could you pick up those bug fixes? Or should I ask Ingo/akpm to take
care of them?

On 2015/2/13 11:19, Zefan Li wrote:
> If clone_children is enabled, effective masks won't be initialized
> due to the bug:
> 
>   # mount -t cgroup -o cpuset xxx /mnt
>   # echo 1 > cgroup.clone_children
>   # mkdir /mnt/tmp
>   # cat /mnt/tmp/
>   # cat cpuset.effective_cpus
> 
>   # cat cpuset.cpus
>   0-15
> 
> And then this cpuset won't constrain the tasks in it.
> 
> Either the bug or the fix has no effect on unified hierarchy, as
> there's no clone_chidren flag there any more.
> 
> Reported-by: Christian Brauner <christianvanbrauner@gmail.com>
> Reported-by: Serge Hallyn <serge.hallyn@ubuntu.com>
> Cc: <stable@vger.kernel.org> # 3.17+
> Signed-off-by: Zefan Li <lizefan@huawei.com>
> ---
>  kernel/cpuset.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/cpuset.c b/kernel/cpuset.c
> index 64b257f..7e9d711 100644
> --- a/kernel/cpuset.c
> +++ b/kernel/cpuset.c
> @@ -1992,7 +1992,9 @@ static int cpuset_css_online(struct cgroup_subsys_state *css)
>  
>  	spin_lock_irq(&callback_lock);
>  	cs->mems_allowed = parent->mems_allowed;
> +	cs->effective_mems = parent->mems_allowed;
>  	cpumask_copy(cs->cpus_allowed, parent->cpus_allowed);
> +	cpumask_copy(cs->effective_cpus, parent->cpus_allowed);
>  	spin_unlock_irq(&callback_lock);
>  out_unlock:
>  	mutex_unlock(&cpuset_mutex);
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled
  2015-03-02  6:16 ` Zefan Li
@ 2015-03-02 16:55   ` Tejun Heo
  0 siblings, 0 replies; 7+ messages in thread
From: Tejun Heo @ 2015-03-02 16:55 UTC (permalink / raw)
  To: Zefan Li
  Cc: Christian Brauner, Serge Hallyn, Stéphane Graber, LKML,
	Cgroups

On Mon, Mar 02, 2015 at 02:16:35PM +0800, Zefan Li wrote:
> Hi Tejun,
> 
> Could you pick up those bug fixes? Or should I ask Ingo/akpm to take
> care of them?

Sorry about the delay.  Applied to cgroup/for-4.0-fixes.  Will push
out in a week.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-03-02 16:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-13  3:19 [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled Zefan Li
     [not found] ` <54DD6D55.2070603-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-02-13  3:20   ` [PATCH 2/3] cpuset: fix a warning when clearing configured masks in old hierarchy Zefan Li
2015-02-13  3:21   ` [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled Zefan Li
2015-02-13  3:58   ` [PATCH 3/3] cpuset: Fix cpuset sched_relax_domain_level Zefan Li
2015-02-13  6:19 ` [PATCH 1/3] cpuset: initialize effective masks when clone_children is enabled Serge E. Hallyn
2015-03-02  6:16 ` Zefan Li
2015-03-02 16:55   ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).