linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	miklos@szeredi.hu,
	Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Subject: Re: [PATCH] memcg: fix to leave pages on wrong LRU with FUSE.
Date: Tue, 8 Mar 2011 11:04:43 +0900	[thread overview]
Message-ID: <20110308110443.47136fc1.nishimura@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <20110308100242.3075e2c7.kamezawa.hiroyu@jp.fujitsu.com>

On Tue, 8 Mar 2011 10:02:42 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:

> On Tue, 8 Mar 2011 09:59:39 +0900
> Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:
> 
> > On Mon, 7 Mar 2011 15:00:49 +0900
> > KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> > 
> > > At this point, I'm not sure this is a fix for 
> > >    https://bugzilla.kernel.org/show_bug.cgi?id=30432.
> > > 
> > > The behavior seems very similar to SwapCache case and this is a possible
> > > bug and this patch can be a fix. Nishimura-san, how do you think ?
> > > 
> > As long as I can read the source code, I also think this is a possible bug.
> > 
> > > But I'm not sure how to test this....please review.
> > > 
> > > =
> > > fs/fuse/dev.c::fuse_try_move_page() does
> > > 
> > >    (1) remove a page from page cache by ->steal()
> > >    (2) re-add the page to page cache 
> > >    (3) link the page to LRU if it was _not_ on LRU at (1)
> > > 
> > > 
> > > This implies the page can be _on_ LRU when add_to_page_cache_locked() is called.
> > > So, the page is added to a memory cgroup while it's on LRU.
> > > 
> > > This is the same behavior as SwapCache, 'newly charged pages may be on LRU'
> > > and needs special care as
> > >  - remove page from old memcg's LRU before overwrite pc->mem_cgroup.
> > >  - add page to new memcg's LRU after overwrite pc->mem_cgroup.
> > > 
> > > So, reusing SwapCache code with renaming for fix.
> > > 
> > > Note: a page on pagevec(LRU).
> > > 
> > > If a page is not PageLRU(page) but on pagevec(LRU), it may be added to LRU
> > > while we overwrite page->mapping. But in that case, PCG_USED bit of
> > > the page_cgroup is not set and the page_cgroup will not be added to
> > > wrong memcg's LRU. So, this patch's logic will work fine.
> > > (It has been tested with SwapCache.)
> > > 
> > As for SwapCache, mem_cgroup_lru_add_after_commit() will be allways called,
> > and it will link the page to LRU. But, if I read this patch correctly,
> > a page cache on pagevec may not be added to a *proper* memcg's LRU.
> > 
> >       lru_add_drain()           mem_cgroup_cache_charge()
> >   ----------------------------------------------------------
> >                                   if (!PageLRU())
> >     SetPageLRU()
> >     add_page_to_lru_list()
> >       mem_cgroup_add_lru_list()
> >       -> do nothing
> >                                     mem_cgroup_charge_common()
> >                                       mem_cgroup_commit_charge()
> >                                       -> set PCG_USED
> > 
> 
> Hmm, yes, that's possible case.
> 
> So, PageLRU() && !PcgAcctLru(pc) should be checked after commit ?
> 
I think so, as mem_cgroup_lru_add_after_commit() does.

> I think we can add optimization later (add per-memcg-lru-pegecgrou-vec or some)
> 
In current mmotm, fuse uses replace_page_cache(), which uses mem_cgroup_(prepare|end)_migration(),
so I think we can handle this problem in a different way instead of changing
mem_cgroup_cache_charge(), which I think is a fast-path operation.

Thanks,
Daisuke Nishimura.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-03-08  2:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-07  6:00 KAMEZAWA Hiroyuki
2011-03-08  0:59 ` Daisuke Nishimura
2011-03-08  1:02   ` KAMEZAWA Hiroyuki
2011-03-08  2:04     ` Daisuke Nishimura [this message]
2011-03-08  2:06       ` KAMEZAWA Hiroyuki

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=20110308110443.47136fc1.nishimura@mxp.nes.nec.co.jp \
    --to=nishimura@mxp.nes.nec.co.jp \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=miklos@szeredi.hu \
    /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