* [PATCH] memcg: fix use_hierarchy css_is_ancestor oops regression
@ 2012-06-10 18:54 Hugh Dickins
2012-06-10 22:15 ` Johannes Weiner
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Hugh Dickins @ 2012-06-10 18:54 UTC (permalink / raw)
To: Andrew Morton
Cc: Johannes Weiner, Konstantin Khlebnikov, KAMEZAWA Hiroyuki,
Michal Hocko, linux-kernel, linux-mm
If use_hierarchy is set, reclaim testing soon oopses in css_is_ancestor()
called from __mem_cgroup_same_or_subtree() called from page_referenced():
when processes are exiting, it's easy for mm_match_cgroup() to pass along
a NULL memcg coming from a NULL mm->owner.
Check for that in __mem_cgroup_same_or_subtree(). Return true or false?
False because we cannot know if it was in the hierarchy, but also false
because it's better not to count a reference from an exiting process.
Signed-off-by: Hugh Dickins <hughd@google.com>
---
This a 3.5-rc issue: not needed for stable.
mm/memcontrol.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- 3.5-rc2/mm/memcontrol.c 2012-05-30 08:17:19.400008280 -0700
+++ linux/mm/memcontrol.c 2012-06-10 08:39:39.618182396 -0700
@@ -1148,7 +1148,7 @@ bool __mem_cgroup_same_or_subtree(const
{
if (root_memcg == memcg)
return true;
- if (!root_memcg->use_hierarchy)
+ if (!root_memcg->use_hierarchy || !memcg)
return false;
return css_is_ancestor(&memcg->css, &root_memcg->css);
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memcg: fix use_hierarchy css_is_ancestor oops regression
2012-06-10 18:54 [PATCH] memcg: fix use_hierarchy css_is_ancestor oops regression Hugh Dickins
@ 2012-06-10 22:15 ` Johannes Weiner
2012-06-10 22:53 ` Hugh Dickins
2012-06-11 7:29 ` Konstantin Khlebnikov
2012-06-11 7:05 ` Kamezawa Hiroyuki
2012-06-11 7:34 ` Michal Hocko
2 siblings, 2 replies; 6+ messages in thread
From: Johannes Weiner @ 2012-06-10 22:15 UTC (permalink / raw)
To: Hugh Dickins
Cc: Andrew Morton, Konstantin Khlebnikov, KAMEZAWA Hiroyuki,
Michal Hocko, linux-kernel, linux-mm
On Sun, Jun 10, 2012 at 11:54:47AM -0700, Hugh Dickins wrote:
> If use_hierarchy is set, reclaim testing soon oopses in css_is_ancestor()
> called from __mem_cgroup_same_or_subtree() called from page_referenced():
> when processes are exiting, it's easy for mm_match_cgroup() to pass along
> a NULL memcg coming from a NULL mm->owner.
>
> Check for that in __mem_cgroup_same_or_subtree(). Return true or false?
> False because we cannot know if it was in the hierarchy, but also false
> because it's better not to count a reference from an exiting process.
>
> Signed-off-by: Hugh Dickins <hughd@google.com>
Looks like an older version of the patch that introduced it slipped
into the tree, Konstantin noted this problem during review. The final
version did
match = memcg && __mem_cgroup_same_or_subtree(root, memcg);
in the caller because of it.
Do you think it would be cleaner this way, since this is also the
place where that memcg is looked up, and so the "can return NULL"
handling after mem_cgroup_from_task() would be in the same place?
But either way,
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Thanks, Hugh!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memcg: fix use_hierarchy css_is_ancestor oops regression
2012-06-10 22:15 ` Johannes Weiner
@ 2012-06-10 22:53 ` Hugh Dickins
2012-06-11 7:29 ` Konstantin Khlebnikov
1 sibling, 0 replies; 6+ messages in thread
From: Hugh Dickins @ 2012-06-10 22:53 UTC (permalink / raw)
To: Johannes Weiner
Cc: Andrew Morton, Konstantin Khlebnikov, KAMEZAWA Hiroyuki,
Michal Hocko, linux-kernel, linux-mm
On Mon, 11 Jun 2012, Johannes Weiner wrote:
> On Sun, Jun 10, 2012 at 11:54:47AM -0700, Hugh Dickins wrote:
> > If use_hierarchy is set, reclaim testing soon oopses in css_is_ancestor()
> > called from __mem_cgroup_same_or_subtree() called from page_referenced():
> > when processes are exiting, it's easy for mm_match_cgroup() to pass along
> > a NULL memcg coming from a NULL mm->owner.
> >
> > Check for that in __mem_cgroup_same_or_subtree(). Return true or false?
> > False because we cannot know if it was in the hierarchy, but also false
> > because it's better not to count a reference from an exiting process.
> >
> > Signed-off-by: Hugh Dickins <hughd@google.com>
>
> Looks like an older version of the patch that introduced it slipped
> into the tree, Konstantin noted this problem during review. The final
> version did
>
> match = memcg && __mem_cgroup_same_or_subtree(root, memcg);
>
> in the caller because of it.
>
> Do you think it would be cleaner this way, since this is also the
> place where that memcg is looked up, and so the "can return NULL"
> handling after mem_cgroup_from_task() would be in the same place?
I don't mind, either way.
It depends on whether we add more such uses which could receive a NULL
memcg. I tend to prefer dealing with rare conditions (which this is)
inside the callee, but common conditions before calling from the caller.
But let's let others decide.
>
> But either way,
>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
>
> Thanks, Hugh!
And thank you, Hannes!
Hugh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memcg: fix use_hierarchy css_is_ancestor oops regression
2012-06-10 18:54 [PATCH] memcg: fix use_hierarchy css_is_ancestor oops regression Hugh Dickins
2012-06-10 22:15 ` Johannes Weiner
@ 2012-06-11 7:05 ` Kamezawa Hiroyuki
2012-06-11 7:34 ` Michal Hocko
2 siblings, 0 replies; 6+ messages in thread
From: Kamezawa Hiroyuki @ 2012-06-11 7:05 UTC (permalink / raw)
To: Hugh Dickins
Cc: Andrew Morton, Johannes Weiner, Konstantin Khlebnikov,
Michal Hocko, linux-kernel, linux-mm
(2012/06/11 3:54), Hugh Dickins wrote:
> If use_hierarchy is set, reclaim testing soon oopses in css_is_ancestor()
> called from __mem_cgroup_same_or_subtree() called from page_referenced():
> when processes are exiting, it's easy for mm_match_cgroup() to pass along
> a NULL memcg coming from a NULL mm->owner.
>
> Check for that in __mem_cgroup_same_or_subtree(). Return true or false?
> False because we cannot know if it was in the hierarchy, but also false
> because it's better not to count a reference from an exiting process.
>
> Signed-off-by: Hugh Dickins<hughd@google.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memcg: fix use_hierarchy css_is_ancestor oops regression
2012-06-10 22:15 ` Johannes Weiner
2012-06-10 22:53 ` Hugh Dickins
@ 2012-06-11 7:29 ` Konstantin Khlebnikov
1 sibling, 0 replies; 6+ messages in thread
From: Konstantin Khlebnikov @ 2012-06-11 7:29 UTC (permalink / raw)
To: Johannes Weiner
Cc: Hugh Dickins, Andrew Morton, KAMEZAWA Hiroyuki, Michal Hocko,
linux-kernel, linux-mm
Johannes Weiner wrote:
> On Sun, Jun 10, 2012 at 11:54:47AM -0700, Hugh Dickins wrote:
>> If use_hierarchy is set, reclaim testing soon oopses in css_is_ancestor()
>> called from __mem_cgroup_same_or_subtree() called from page_referenced():
>> when processes are exiting, it's easy for mm_match_cgroup() to pass along
>> a NULL memcg coming from a NULL mm->owner.
>>
>> Check for that in __mem_cgroup_same_or_subtree(). Return true or false?
>> False because we cannot know if it was in the hierarchy, but also false
>> because it's better not to count a reference from an exiting process.
>>
>> Signed-off-by: Hugh Dickins<hughd@google.com>
>
> Looks like an older version of the patch that introduced it slipped
> into the tree, Konstantin noted this problem during review. The final
> version did
>
> match = memcg&& __mem_cgroup_same_or_subtree(root, memcg);
>
> in the caller because of it.
>
> Do you think it would be cleaner this way, since this is also the
> place where that memcg is looked up, and so the "can return NULL"
> handling after mem_cgroup_from_task() would be in the same place?
I agree, it cleaner, but nevertheless:
Acked-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Thanks, Hugh!
>
> But either way,
>
> Acked-by: Johannes Weiner<hannes@cmpxchg.org>
>
> Thanks, Hugh!
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email:<a href=mailto:"dont@kvack.org"> email@kvack.org</a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] memcg: fix use_hierarchy css_is_ancestor oops regression
2012-06-10 18:54 [PATCH] memcg: fix use_hierarchy css_is_ancestor oops regression Hugh Dickins
2012-06-10 22:15 ` Johannes Weiner
2012-06-11 7:05 ` Kamezawa Hiroyuki
@ 2012-06-11 7:34 ` Michal Hocko
2 siblings, 0 replies; 6+ messages in thread
From: Michal Hocko @ 2012-06-11 7:34 UTC (permalink / raw)
To: Hugh Dickins
Cc: Andrew Morton, Johannes Weiner, Konstantin Khlebnikov,
KAMEZAWA Hiroyuki, linux-kernel, linux-mm
On Sun 10-06-12 11:54:47, Hugh Dickins wrote:
> If use_hierarchy is set, reclaim testing soon oopses in css_is_ancestor()
> called from __mem_cgroup_same_or_subtree() called from page_referenced():
> when processes are exiting, it's easy for mm_match_cgroup() to pass along
> a NULL memcg coming from a NULL mm->owner.
>
> Check for that in __mem_cgroup_same_or_subtree(). Return true or false?
> False because we cannot know if it was in the hierarchy, but also false
> because it's better not to count a reference from an exiting process.
>
> Signed-off-by: Hugh Dickins <hughd@google.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Thanks
> ---
> This a 3.5-rc issue: not needed for stable.
>
> mm/memcontrol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- 3.5-rc2/mm/memcontrol.c 2012-05-30 08:17:19.400008280 -0700
> +++ linux/mm/memcontrol.c 2012-06-10 08:39:39.618182396 -0700
> @@ -1148,7 +1148,7 @@ bool __mem_cgroup_same_or_subtree(const
> {
> if (root_memcg == memcg)
> return true;
> - if (!root_memcg->use_hierarchy)
> + if (!root_memcg->use_hierarchy || !memcg)
> return false;
> return css_is_ancestor(&memcg->css, &root_memcg->css);
> }
--
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 majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-06-11 7:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-10 18:54 [PATCH] memcg: fix use_hierarchy css_is_ancestor oops regression Hugh Dickins
2012-06-10 22:15 ` Johannes Weiner
2012-06-10 22:53 ` Hugh Dickins
2012-06-11 7:29 ` Konstantin Khlebnikov
2012-06-11 7:05 ` Kamezawa Hiroyuki
2012-06-11 7:34 ` Michal Hocko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox