From: "Paul Menage" <menage@google.com>
To: Balbir Singh <balbir@linux.vnet.ibm.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 08:03:56 -0700 [thread overview]
Message-ID: <6599ad830803240803s5160101bi2bf68b36085f777f@mail.gmail.com> (raw)
In-Reply-To: <20080324140142.28786.97267.sendpatchset@localhost.localdomain>
On Mon, Mar 24, 2008 at 7:01 AM, Balbir Singh <balbir@linux.vnet.ibm.com> wrote:
> --- linux-2.6.25-rc5/include/linux/mm_types.h~memory-controller-add-mm-owner 2008-03-20 13:35:09.000000000 +0530
> +++ linux-2.6.25-rc5-balbir/include/linux/mm_types.h 2008-03-20 15:11:05.000000000 +0530
> @@ -228,7 +228,10 @@ struct mm_struct {
> rwlock_t ioctx_list_lock;
> struct kioctx *ioctx_list;
> #ifdef CONFIG_CGROUP_MEM_RES_CTLR
> - struct mem_cgroup *mem_cgroup;
> + struct task_struct *owner; /* The thread group leader that */
> + /* owns the mm_struct. This */
> + /* might be useful even outside */
> + /* of the config option */
> #endif
This should probably be controlled by something like a CONFIG_MM_OWNER
that's selected by any Kconfig option (mem cgroup, etc) that needs
mm->owner to be maintained.
> @@ -248,12 +248,40 @@ void mm_init_cgroup(struct mm_struct *mm
>
> mem = mem_cgroup_from_task(p);
> css_get(&mem->css);
> - mm->mem_cgroup = mem;
> + mm->owner = p;
> +}
> +
> +void mem_cgroup_fork_init(struct task_struct *p)
> +{
> + struct mm_struct *mm = get_task_mm(p);
> + struct mem_cgroup *mem, *oldmem;
> + if (!mm)
> + return;
> +
> + /*
> + * Initial owner at mm_init_cgroup() time is the task itself.
> + * The thread group leader had not been setup then
> + */
> + oldmem = mem_cgroup_from_task(mm->owner);
> + /*
> + * Override the mm->owner after we know the thread group later
> + */
> + mm->owner = p->group_leader;
> + mem = mem_cgroup_from_task(mm->owner);
> + css_get(&mem->css);
> + css_put(&oldmem->css);
> + mmput(mm);
> }
>
> void mm_free_cgroup(struct mm_struct *mm)
> {
> - css_put(&mm->mem_cgroup->css);
> + struct mem_cgroup *mem;
> +
> + /*
> + * TODO: Should we assign mm->owner to NULL here?
> + */
> + mem = mem_cgroup_from_task(mm->owner);
> + css_put(&mem->css);
> }
It seems to me that the code to setup/maintain mm->owner should be
independent of the control groups, but should be part of the generic
fork/exit code.
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?)
>
> - 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.
>
> @@ -1069,7 +1096,6 @@ static void mem_cgroup_move_task(struct
> goto out;
>
> css_get(&mem->css);
> - rcu_assign_pointer(mm->mem_cgroup, mem);
> css_put(&old_mem->css);
>
We shouldn't need reference counting on this pointer, since the
cgroups framework won't allow a subsystem to be freed while it has any
tasks in it.
Paul
--
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 15:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-24 14:01 Balbir Singh
2008-03-24 15:03 ` Paul Menage [this message]
2008-03-24 16:21 ` Balbir Singh
2008-03-24 16:34 ` Paul Menage
2008-03-24 17:33 ` Balbir Singh
2008-03-24 17:46 ` Paul Menage
2008-03-25 11:41 ` Balbir Singh
2008-03-26 10:29 ` Balbir Singh
2008-03-26 11:20 ` Paul Menage
2008-03-26 11:41 ` Balbir Singh
2008-03-26 15:21 ` Paul Menage
2008-03-25 1:26 ` Li Zefan
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=6599ad830803240803s5160101bi2bf68b36085f777f@mail.gmail.com \
--to=menage@google.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox