mm: memcg: keep root group unchanged if fail to create new
Subsystems (2)
PATCH 1/1 mm: memcg: keep root group unchanged if fail to create new
If the request is not to create root group and we fail to meet it, we'd leave the root unchanged.
---
mm/memcontrol.c +3 -2
@@ -4849,8 +4849,10 @@ mem_cgroup_create(struct cgroup_subsys *enable_swap_cgroup (); parent =NULL ; root_mem_cgroup = memcg; -if (mem_cgroup_soft_limit_tree_init ()) +if (mem_cgroup_soft_limit_tree_init ()) { + root_mem_cgroup =NULL ; goto free_out; + }for_each_possible_cpu (cpu) {struct memcg_stock_pcp *stock = &per_cpu (memcg_stock, cpu);
@@ -4888,7 +4890,6 @@ mem_cgroup_create(struct cgroup_subsys *return &memcg->css; free_out:__mem_cgroup_free (memcg); - root_mem_cgroup =NULL ;return ERR_PTR (error); }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 2 lines · Hillf Danton
If the request is not to create root group and we fail to meet it, we'd leave the root unchanged.
I didn't understand that at first: please say "we should" rather than "we'd", which I take to be an abbreviation for "we would".
Quoted 2 lines
Signed-off-by Hillf Danton <[email protected]>
Yes indeed, well caught:
I wonder what was going through the author's mind when he wrote it that way? I wonder if it's one of those bugs that creeps in when you start from a perfectly functional patch, then make refinements to suit feedback from reviewers.
On which topic: wouldn't this patch be better just to move the "root_mem_cgroup = memcg;" two lines lower down (and of course remove free_out's "root_mem_cgroup = NULL;" as you already did)? I can't see mem_cgroup_soft_limit_tree_init() relying on root_mem_cgroup at all.
Should your patch go to stable, even to 2.6.32-longterm? Matter of taste, really: while it's not quite impossible for alloc_mem_cgroup_per_zone_info() to fail, it is very unlikely.
Quoted 17 lines
---
mm/memcontrol.c +3
-1@@ -4849,8 +4849,10 @@ mem_cgroup_create(struct cgroup_subsys *enable_swap_cgroup (); parent =NULL ; root_mem_cgroup = memcg; -if (mem_cgroup_soft_limit_tree_init ()) +if (mem_cgroup_soft_limit_tree_init ()) { + root_mem_cgroup =NULL ; goto free_out; + }for_each_possible_cpu (cpu) {struct memcg_stock_pcp *stock = &per_cpu (memcg_stock, cpu);
mm/memcontrol.c mem_cgroup_create(struct cgroup_subsys * · line 4895
Quoted 7 lines
mm/memcontrol.c +0
-1@@ -4888,7 +4890,6 @@ mem_cgroup_create(struct cgroup_subsys *return &memcg->css; free_out:__mem_cgroup_free (memcg); - root_mem_cgroup =NULL ;return ERR_PTR (error); }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hello Hugh
Quoted 8 lines · Hugh Dickins
Quoted 2 lines · Hillf Danton
If the request is not to create root group and we fail to meet it, we'd leave the root unchanged.
I didn't understand that at first: please say "we should" rather than "we'd", which I take to be an abbreviation for "we would".
Thanks for correcting me.
Quoted 6 lines
I wonder what was going through the author's mind when he wrote it that way? I wonder if it's one of those bugs that creeps in when you start from a perfectly functional patch, then make refinements to suit feedback from reviewers.
Actually no such a perfectly functional patch, but I also wonder if you are likely to post and/or share your current todo list if any, then many could learn the right direction, and in turn you comment and pull acceptable works in that direction, like Linus.
Hillf
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 14 lines · Hugh Dickins
Quoted 2 lines · Hillf Danton
If the request is not to create root group and we fail to meet it, we'd leave the root unchanged.
I didn't understand that at first: please say "we should" rather than "we'd", which I take to be an abbreviation for "we would".
Quoted 2 lines
Signed-off-by Hillf Danton <[email protected]>Yes indeed, well caught:
Acked-by Hugh Dickins <[email protected]>
Quoted 8 lines
I wonder what was going through the author's mind when he wrote it that way? I wonder if it's one of those bugs that creeps in when you start from a perfectly functional patch, then make refinements to suit feedback from reviewers.
On which topic: wouldn't this patch be better just to move the "
root_mem_cgroup= memcg;" two lines lower down (and of course remove free_out's "root_mem_cgroup= NULL;" as you already did)?
Yes would look nicer.
Quoted 2 lines
I can't see
mem_cgroup_soft_limit_tree_init()relying onroot_mem_cgroupat all.
It doesn't but it still needs some love to handle error case properly AFAICS. We do not deallocate softlimit trees for nodes that succeeded.
[...]
Hilf could you update the patch please?
Signature · 13 lines
Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · Michal Hocko
Hillf could you update the patch please?
Hi Michal,
Please review again, thanks.
Hillf
===CUT HERE===
From: Hillf Danton <[email protected]>
Subject: [PATCH] mm: memcg: keep root group unchanged if fail to create new
If the request is to create non-root group and we fail to meet it, we should leave the root unchanged.
---
mm/memcontrol.c +1 -2
@@ -4848,9 +4848,9 @@ mem_cgroup_create(struct cgroup_subsys *int cpu;enable_swap_cgroup (); parent =NULL ; - root_mem_cgroup = memcg;if (mem_cgroup_soft_limit_tree_init ()) goto free_out; + root_mem_cgroup = memcg;for_each_possible_cpu (cpu) {struct memcg_stock_pcp *stock = &per_cpu (memcg_stock, cpu);
@@ -4888,7 +4888,6 @@ mem_cgroup_create(struct cgroup_subsys *return &memcg->css; free_out:__mem_cgroup_free (memcg); - root_mem_cgroup =NULL ;return ERR_PTR (error); }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Michal Hocko
Acked-byOn Mon 12-12-11 21:49:18, Hillf Danton wrote:
[...]
Quoted 9 lines
From: Hillf Danton <[email protected]>
Subject: [PATCH] mm: memcg: keep root group unchanged if fail to create newIf the request is to create non-root group and we fail to meet it, we should leave the root unchanged.
Signed-off-by Hillf Danton <[email protected]>Acked-by Hugh Dickins <[email protected]>
Thanks
Quoted 29 lines
---
mm/memcontrol.c +1
-3@@ -4848,9 +4848,9 @@ mem_cgroup_create(struct cgroup_subsys *int cpu;enable_swap_cgroup (); parent =NULL ; - root_mem_cgroup = memcg;if (mem_cgroup_soft_limit_tree_init ()) goto free_out; + root_mem_cgroup = memcg;for_each_possible_cpu (cpu) {struct memcg_stock_pcp *stock = &per_cpu (memcg_stock, cpu);@@ -4888,7 +4888,6 @@ mem_cgroup_create(struct cgroup_subsys *return &memcg->css; free_out:__mem_cgroup_free (memcg); - root_mem_cgroup =NULL ;return ERR_PTR (error); } --To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 13 lines
Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 memcg: clean up soft_limit_tree properly new
And a follow up patch for the proper clean up:
---
Re: [PATCH] memcg: clean up soft_limit_tree properly new
Quoted 7 lines · Michal Hocko
And a follow up patch for the proper clean up:
---Quoted 1 line
From
4b9f5a1e88496af9f336d1ef37cfdf3754a3ba48Mon Sep 17 00:00:00 2001From: Michal Hocko <[email protected]>
Date: Mon, 12 Dec 2011 15:04:18 +0100
Subject: [PATCH] memcg: clean upsoft_limit_treeproperly
Quoted 5 lines
If we are not able to allocate tree nodes for all NUMA nodes then we should better clean up those that were allocated otherwise we will leak a memory.
Signed-off-by Michal Hocko <[email protected]>
That being said, I think it's unlikely that the machine even boots properly if those allocations fail. But the code looks better this way and one doesn't have to double take, wondering if anyone else is taking care of the already allocated objects.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] memcg: clean up soft_limit_tree properly new
Quoted 8 lines · Johannes Weiner
Quoted 7 lines · Michal Hocko
And a follow up patch for the proper clean up:
---Quoted 1 line
From
4b9f5a1e88496af9f336d1ef37cfdf3754a3ba48Mon Sep 17 00:00:00 2001From: Michal Hocko <[email protected]>
Date: Mon, 12 Dec 2011 15:04:18 +0100
Subject: [PATCH] memcg: clean upsoft_limit_treeproperly
Quoted 7 lines
Quoted 5 lines
If we are not able to allocate tree nodes for all NUMA nodes then we should better clean up those that were allocated otherwise we will leak a memory.
Signed-off-by Michal Hocko <[email protected]>Acked-by Johannes Weiner <[email protected]>
Thanks
Quoted 5 lines
That being said, I think it's unlikely that the machine even boots properly if those allocations fail. But the code looks better this way and one doesn't have to double take, wondering if anyone else is taking care of the already allocated objects.
Yes, that was the point of the patch - just a cleanup. I do not think we want to push it into stable...
Signature · 13 lines
Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH] memcg: clean up soft_limit_tree properly new
In reply to Michal HockoQuoted 34 lines · On Mon, 12 Dec 2011 15:09:35 +0100 Michal Hocko <[email protected]> wrote:
And a follow up patch for the proper clean up:
---Quoted 1 line
From
4b9f5a1e88496af9f336d1ef37cfdf3754a3ba48Mon Sep 17 00:00:00 2001From: Michal Hocko <[email protected]>
Date: Mon, 12 Dec 2011 15:04:18 +0100
Subject: [PATCH] memcg: clean upsoft_limit_treeproperlyIf we are not able to allocate tree nodes for all NUMA nodes then we should better clean up those that were allocated otherwise we will leak a memory.
Signed-off-by Michal Hocko <[email protected]>--- mm/memcontrol.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)mm/memcontrol.c +2
-1@@ -4874,7 +4874,7 @@ static int mem_cgroup_soft_limit_tree_init(void) tmp =-1 ; rtpn =kzalloc_node (sizeof (*rtpn),GFP_KERNEL , tmp);if (!rtpn) -return 1 ; + goto err_cleanup; soft_limit_tree.rb_tree_per_node[node] = rtpn;@@ -4885,6 +4885,16 @@ static int mem_cgroup_soft_limit_tree_init(void) } }return 0 ; +
mm/memcontrol.c static int mem_cgroup_soft_limit_tree_init(void) · line 4898
Quoted 10 lines
mm/memcontrol.c +9
-0+err_cleanup: +for_each_node_state (node,N_POSSIBLE ) { +if (!soft_limit_tree.rb_tree_per_node[node]) +break ; +kfree (soft_limit_tree.rb_tree_per_node[node]); + soft_limit_tree.rb_tree_per_node[node] =NULL ; + } +return 1 ; + }
afacit the kernel never frees the soft_limit_tree.rb_tree_per_node[] entries on the mem_cgroup_destroy() path. Bug?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] memcg: clean up soft_limit_tree properly new
Quoted 42 lines · On Tue, 13 Dec 2011 17:00:12 -0800 Andrew Morton <[email protected]>…
Quoted 39 lines · On Mon, 12 Dec 2011 15:09:35 +0100 Michal Hocko <[email protected]> wrote:
And a follow up patch for the proper clean up:
---Quoted 1 line
From
4b9f5a1e88496af9f336d1ef37cfdf3754a3ba48Mon Sep 17 00:00:00 2001From: Michal Hocko <[email protected]>
Date: Mon, 12 Dec 2011 15:04:18 +0100
Subject: [PATCH] memcg: clean upsoft_limit_treeproperlyIf we are not able to allocate tree nodes for all NUMA nodes then we should better clean up those that were allocated otherwise we will leak a memory.
Signed-off-by Michal Hocko <[email protected]>--- mm/memcontrol.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)mm/memcontrol.c +7
-1@@ -4874,7 +4874,7 @@ static int mem_cgroup_soft_limit_tree_init(void) tmp =-1 ; rtpn =kzalloc_node (sizeof (*rtpn),GFP_KERNEL , tmp);if (!rtpn) -return 1 ; + goto err_cleanup; soft_limit_tree.rb_tree_per_node[node] = rtpn;@@ -4885,6 +4885,16 @@ static int mem_cgroup_soft_limit_tree_init(void) } }return 0 ; + +err_cleanup: +for_each_node_state (node,N_POSSIBLE ) { +if (!soft_limit_tree.rb_tree_per_node[node]) +break ; +kfree (soft_limit_tree.rb_tree_per_node[node]);
Quoted 9 lines
mm/memcontrol.c static int mem_cgroup_soft_limit_tree_init(void) · line 4898
Quoted 5 lines
mm/memcontrol.c +4
-0+ soft_limit_tree.rb_tree_per_node[node] =NULL ; + } +return 1 ; + }afacit the kernel never frees the soft_limit_tree.rb_tree_per_node[] entries on the
mem_cgroup_destroy()path. Bug?
soft_limit_tree.rb_tree_per_node[] is a global object and allocated once at creating root cgroup.
Nodes of rb_tree for a memcg are contained in struct mem_cgroup_per_zone and it's freed at mem_cgroup_destroy().
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 13 lines · Hillf Danton
Quoted 3 lines · Michal Hocko
Hillf could you update the patch please?
Hi Michal,
Please review again, thanks.
Hillf===CUT HERE===
From: Hillf Danton <[email protected]>
Subject: [PATCH] mm: memcg: keep root group unchanged if fail to create new
Quoted 6 lines
If the request is to create non-root group and we fail to meet it, we should leave the root unchanged.
Signed-off-by Hillf Danton <[email protected]>Acked-by Hugh Dickins <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · On Sun, 11 Dec 2011 09:19:12 +0800 Hillf Danton <[email protected]> wrote:
If the request is not to create root group and we fail to meet it, we'd leave the root unchanged.
Signed-off-by Hillf Danton <[email protected]>
Thank you.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>