lkml.org 
[lkml]   [2011]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4] mm: add replace_page_cache_page() function
On Wed, 19 Jan 2011 09:27:33 +0900
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:

> On Tue, 18 Jan 2011 15:28:44 -0800
> Andrew Morton <akpm@linux-foundation.org> wrote:
>
> > On Tue, 18 Jan 2011 12:18:11 +0100
> > Miklos Szeredi <miklos@szeredi.hu> wrote:
> >
> > > +int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
> > > +{
> > > + int error;
> > > + struct mem_cgroup *memcg = NULL;
> >
> > I'm suspecting that the unneeded initialisation was added to suppress a
> > warning?
> >
> No.
> It's necessary for mem_cgroup_{prepare|end}_migration().
> mem_cgroup_prepare_migration() will return without doing anything in
> "if (mem_cgroup_disabled()" case(iow, "memcg" is not overwritten),
> but mem_cgroup_end_migration() depends on the value of "memcg" to decide
> whether prepare_migration has succeeded or not.
> This may not be a good implementation,

It's a *surprising* implementation, in the context of kernel
conventions. At least, it fooled me :)

Which makes it a not-good implementation, really. Also, it's
undocumented.

> but IMHO I'd like to to initialize
> valuable before using it in general.

mem_cgroup_prepare_migration() performs the initialisation! We do this
in many places - it's the basic "function with more than one return
value" mechanism.



\
 
 \ /
  Last update: 2011-01-19 01:45    [W:0.078 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site