linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Balbir Singh" <balbir@linux.vnet.ibm.com>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: linux-mm@kvack.org, Hugh Dickins <hugh@veritas.com>,
	Sudhir Kumar <skumar@linux.vnet.ibm.com>,
	YAMAMOTO Takashi <yamamoto@valinux.co.jp>,
	Paul Menage <menage@google.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: Tue, 25 Mar 2008 21:18:00 +0530	[thread overview]
Message-ID: <661de9470803250848p1ead8571ibfbe6e1196da8a89@mail.gmail.com> (raw)
In-Reply-To: <47E854CD.1090105@cn.fujitsu.com>

On Tue, Mar 25, 2008 at 6:56 AM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>
> Balbir Singh wrote:
>  > This patch removes the mem_cgroup member from mm_struct and instead adds
>  > an owner. This approach was suggested by Paul Menage. The advantage of
>  > this approach is that, once the mm->owner is known, using the subsystem
>  > id, the cgroup can be determined. It also allows several control groups
>  > that are virtually grouped by mm_struct, to exist independent of the memory
>  > controller i.e., without adding mem_cgroup's for each controller,
>  > to mm_struct.
>  >
>  > The code initially assigns mm->owner to the task and then after the
>  > thread group leader is identified. The mm->owner is changed to the thread
>  > group leader of the task later at the end of copy_process.
>  >
>  > Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
>  > ---
>  >
>  >  include/linux/memcontrol.h |   14 +++++++++++++-
>  >  include/linux/mm_types.h   |    5 ++++-
>  >  kernel/fork.c              |    4 ++++
>  >  mm/memcontrol.c            |   42 ++++++++++++++++++++++++++++++++++--------
>  >  4 files changed, 55 insertions(+), 10 deletions(-)
>  >
>  > diff -puN include/linux/mm_types.h~memory-controller-add-mm-owner include/linux/mm_types.h
>  > --- 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
>  >
>  >  #ifdef CONFIG_PROC_FS
>  > diff -puN kernel/fork.c~memory-controller-add-mm-owner kernel/fork.c
>  > --- linux-2.6.25-rc5/kernel/fork.c~memory-controller-add-mm-owner     2008-03-20 13:35:09.000000000 +0530
>  > +++ linux-2.6.25-rc5-balbir/kernel/fork.c     2008-03-24 18:49:29.000000000 +0530
>  > @@ -1357,6 +1357,10 @@ static struct task_struct *copy_process(
>  >       write_unlock_irq(&tasklist_lock);
>  >       proc_fork_connector(p);
>  >       cgroup_post_fork(p);
>  > +
>  > +     if (!(clone_flags & CLONE_VM))
>  > +             mem_cgroup_fork_init(p);
>  > +
>  >       return p;
>  >
>  >  bad_fork_free_pid:
>  > diff -puN include/linux/memcontrol.h~memory-controller-add-mm-owner include/linux/memcontrol.h
>  > --- linux-2.6.25-rc5/include/linux/memcontrol.h~memory-controller-add-mm-owner        2008-03-20 13:35:09.000000000 +0530
>  > +++ linux-2.6.25-rc5-balbir/include/linux/memcontrol.h        2008-03-24 18:49:52.000000000 +0530
>  > @@ -29,6 +29,7 @@ struct mm_struct;
>  >
>  >  extern void mm_init_cgroup(struct mm_struct *mm, struct task_struct *p);
>  >  extern void mm_free_cgroup(struct mm_struct *mm);
>  > +extern void mem_cgroup_fork_init(struct task_struct *p);
>  >
>  >  #define page_reset_bad_cgroup(page)  ((page)->page_cgroup = 0)
>  >
>  > @@ -49,7 +50,7 @@ extern void mem_cgroup_out_of_memory(str
>  >  int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
>  >
>  >  #define mm_match_cgroup(mm, cgroup)  \
>  > -     ((cgroup) == rcu_dereference((mm)->mem_cgroup))
>  > +     ((cgroup) == mem_cgroup_from_task((mm)->owner))
>  >
>  >  extern int mem_cgroup_prepare_migration(struct page *page);
>  >  extern void mem_cgroup_end_migration(struct page *page);
>  > @@ -72,6 +73,8 @@ extern long mem_cgroup_calc_reclaim_acti
>  >  extern long mem_cgroup_calc_reclaim_inactive(struct mem_cgroup *mem,
>  >                               struct zone *zone, int priority);
>  >
>  > +extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
>  > +
>  >  #else /* CONFIG_CGROUP_MEM_RES_CTLR */
>  >  static inline void mm_init_cgroup(struct mm_struct *mm,
>  >                                       struct task_struct *p)
>  > @@ -82,6 +85,10 @@ static inline void mm_free_cgroup(struct
>  >  {
>  >  }
>  >
>  > +static inline void mem_cgroup_fork_init(struct task_struct *p)
>  > +{
>  > +}
>  > +
>  >  static inline void page_reset_bad_cgroup(struct page *page)
>  >  {
>  >  }
>  > @@ -172,6 +179,11 @@ static inline long mem_cgroup_calc_recla
>  >  {
>  >       return 0;
>  >  }
>  > +
>  > +static void mm_free_fork_cgroup(struct task_struct *p)
>  > +{
>  > +}
>  > +
>
>  Where is this function used? I don't see the corresponding one
>  with CONFIG_CGROUP_MEM_RES_CTLR enabled?
>

I kept that as a template for freeing up code. I'll remove that since
it is additional code

>
>  >  #endif /* CONFIG_CGROUP_MEM_CONT */
>  >
>  >  #endif /* _LINUX_MEMCONTROL_H */
>  > diff -puN mm/memcontrol.c~memory-controller-add-mm-owner mm/memcontrol.c
>  > --- linux-2.6.25-rc5/mm/memcontrol.c~memory-controller-add-mm-owner   2008-03-20 13:35:09.000000000 +0530
>  > +++ linux-2.6.25-rc5-balbir/mm/memcontrol.c   2008-03-24 19:04:32.000000000 +0530
>  > @@ -236,7 +236,7 @@ static struct mem_cgroup *mem_cgroup_fro
>  >                               css);
>  >  }
>  >
>  > -static struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p)
>  > +struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p)
>  >  {
>  >       return container_of(task_subsys_state(p, mem_cgroup_subsys_id),
>  >                               struct mem_cgroup, css);
>  > @@ -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;
>
>  Leave an empty line here.
>

OK


Thanks for the review
Balbir

--
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>

      reply	other threads:[~2008-03-25 15:48 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
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 [this message]

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=661de9470803250848p1ead8571ibfbe6e1196da8a89@mail.gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox