From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: Paul Menage <menage@google.com>
Cc: linux-mm@kvack.org, Hugh Dickins <hugh@veritas.com>,
Sudhir Kumar <skumar@linux.vnet.ibm.com>,
YAMAMOTO Takashi <yamamoto@valinux.co.jp>,
lizf@cn.fujitsu.com, linux-kernel@vger.kernel.org,
taka@valinux.co.jp, David Rientjes <rientjes@google.com>,
Pavel Emelianov <xemul@openvz.org>,
Andrew Morton <akpm@linux-foundation.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: Re: [RFC][-mm] Memory controller add mm->owner
Date: Mon, 24 Mar 2008 23:03:04 +0530 [thread overview]
Message-ID: <47E7E5D0.9020904@linux.vnet.ibm.com> (raw)
In-Reply-To: <6599ad830803240934g2a70d904m1ca5548f8644c906@mail.gmail.com>
Paul Menage wrote:
> On Mon, Mar 24, 2008 at 9:21 AM, Balbir Singh <balbir@linux.vnet.ibm.com> wrote:
>> > Also, if mm->owner exits but mm is still alive (unlikely, but could
>> > happen with weird custom threading libraries?) then we need to
>> > reassign mm->owner to one of the other users of the mm (by looking
>> > first in the thread group, then among the parents/siblings/children,
>> > and then among all processes as a last resort?)
>> >
>>
>> The comment in __exit_signal states that
>>
>> "The group leader stays around as a zombie as long
>> as there are other threads. When it gets reaped,
>> the exit.c code will add its counts into these totals."
>
> Ah, that's useful to know.
>
>> Given that the thread group leader stays around, do we need to reassign
>> mm->owner? Do you do anything special in cgroups like cleanup the
>> task_struct->css->subsys_state on exit?
>>
>
> OK, so we don't need to handle this for NPTL apps - but for anything
> still using LinuxThreads or manually constructed clone() calls that
> use CLONE_VM without CLONE_PID, this could still be an issue.
CLONE_PID?? Do you mean CLONE_THREAD?
For the case you mentioned, mm->owner is a moving target and we don't want to
spend time finding the successor, that can be expensive when threads start
exiting one-by-one quickly and when the number of threads are high. I wonder if
there is an efficient way to find mm->owner in that case.
(Also I
> guess there's the case of someone holding a reference to the mm via a
> /proc file?)
>
Yes, but in that case we'll not be charging/uncharging anything to that mm or
the cgroup to which the mm belongs.
>> >> - rcu_read_lock();
>> >> - mem = rcu_dereference(mm->mem_cgroup);
>> >> + mem = mem_cgroup_from_task(mm->owner);
>> >
>> > I think we still need the rcu_read_lock(), since mm->owner can move
>> > cgroups any time.
>> >
>>
>> OK, so cgroup task movement is protected by RCU, right? I'll check for all
>> mm->owner uses.
>>
>
> Yes - cgroup_attach() uses synchronize_rcu() before release the cgroup
> mutex. So although you can't guarantee that the cgroup set won't
> change if you're just using RCU, you can't guarantee that you're
> addressing a still-valid non-destroyed (and of course non-freed)
> cgroup set.
>
Yes, I understand that part of RCU.
--
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL
WARNING: multiple messages have this Message-ID (diff)
From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: Paul Menage <menage@google.com>
Cc: linux-mm@kvack.org, Hugh Dickins <hugh@veritas.com>,
Sudhir Kumar <skumar@linux.vnet.ibm.com>,
YAMAMOTO Takashi <yamamoto@valinux.co.jp>,
lizf@cn.fujitsu.com, linux-kernel@vger.kernel.org,
taka@valinux.co.jp, David Rientjes <rientjes@google.com>,
Pavel Emelianov <xemul@openvz.org>,
Andrew Morton <akpm@linux-foundation.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: Re: [RFC][-mm] Memory controller add mm->owner
Date: Mon, 24 Mar 2008 23:03:04 +0530 [thread overview]
Message-ID: <47E7E5D0.9020904@linux.vnet.ibm.com> (raw)
In-Reply-To: <6599ad830803240934g2a70d904m1ca5548f8644c906@mail.gmail.com>
Paul Menage wrote:
> On Mon, Mar 24, 2008 at 9:21 AM, Balbir Singh <balbir@linux.vnet.ibm.com> wrote:
>> > Also, if mm->owner exits but mm is still alive (unlikely, but could
>> > happen with weird custom threading libraries?) then we need to
>> > reassign mm->owner to one of the other users of the mm (by looking
>> > first in the thread group, then among the parents/siblings/children,
>> > and then among all processes as a last resort?)
>> >
>>
>> The comment in __exit_signal states that
>>
>> "The group leader stays around as a zombie as long
>> as there are other threads. When it gets reaped,
>> the exit.c code will add its counts into these totals."
>
> Ah, that's useful to know.
>
>> Given that the thread group leader stays around, do we need to reassign
>> mm->owner? Do you do anything special in cgroups like cleanup the
>> task_struct->css->subsys_state on exit?
>>
>
> OK, so we don't need to handle this for NPTL apps - but for anything
> still using LinuxThreads or manually constructed clone() calls that
> use CLONE_VM without CLONE_PID, this could still be an issue.
CLONE_PID?? Do you mean CLONE_THREAD?
For the case you mentioned, mm->owner is a moving target and we don't want to
spend time finding the successor, that can be expensive when threads start
exiting one-by-one quickly and when the number of threads are high. I wonder if
there is an efficient way to find mm->owner in that case.
(Also I
> guess there's the case of someone holding a reference to the mm via a
> /proc file?)
>
Yes, but in that case we'll not be charging/uncharging anything to that mm or
the cgroup to which the mm belongs.
>> >> - rcu_read_lock();
>> >> - mem = rcu_dereference(mm->mem_cgroup);
>> >> + mem = mem_cgroup_from_task(mm->owner);
>> >
>> > I think we still need the rcu_read_lock(), since mm->owner can move
>> > cgroups any time.
>> >
>>
>> OK, so cgroup task movement is protected by RCU, right? I'll check for all
>> mm->owner uses.
>>
>
> Yes - cgroup_attach() uses synchronize_rcu() before release the cgroup
> mutex. So although you can't guarantee that the cgroup set won't
> change if you're just using RCU, you can't guarantee that you're
> addressing a still-valid non-destroyed (and of course non-freed)
> cgroup set.
>
Yes, I understand that part of RCU.
--
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL
--
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>
next prev parent reply other threads:[~2008-03-24 17:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-24 14:01 [RFC][-mm] Memory controller add mm->owner Balbir Singh
2008-03-24 14:01 ` Balbir Singh
2008-03-24 15:03 ` Paul Menage
2008-03-24 15:03 ` Paul Menage
2008-03-24 16:21 ` Balbir Singh
2008-03-24 16:21 ` Balbir Singh
2008-03-24 16:34 ` Paul Menage
2008-03-24 16:34 ` Paul Menage
2008-03-24 17:33 ` Balbir Singh [this message]
2008-03-24 17:33 ` Balbir Singh
2008-03-24 17:46 ` Paul Menage
2008-03-24 17:46 ` Paul Menage
2008-03-25 11:41 ` Balbir Singh
2008-03-25 11:41 ` Balbir Singh
2008-03-26 10:29 ` Balbir Singh
2008-03-26 10:29 ` Balbir Singh
2008-03-26 11:20 ` Paul Menage
2008-03-26 11:20 ` Paul Menage
2008-03-26 11:41 ` Balbir Singh
2008-03-26 11:41 ` Balbir Singh
2008-03-26 15:21 ` Paul Menage
2008-03-26 15:21 ` Paul Menage
2008-03-25 1:26 ` Li Zefan
2008-03-25 1:26 ` Li Zefan
2008-03-25 15:48 ` Balbir Singh
2008-03-25 15:48 ` Balbir Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47E7E5D0.9020904@linux.vnet.ibm.com \
--to=balbir@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=hugh@veritas.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizf@cn.fujitsu.com \
--cc=menage@google.com \
--cc=rientjes@google.com \
--cc=skumar@linux.vnet.ibm.com \
--cc=taka@valinux.co.jp \
--cc=xemul@openvz.org \
--cc=yamamoto@valinux.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.