From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>, Mel Gorman <mel@csn.ul.ie>,
Rik van Riel <riel@redhat.com>,
Minchan Kim <minchan.kim@gmail.com>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Christoph Lameter <cl@linux-foundation.org>,
Andrea Arcangeli <aarcange@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC][BUGFIX][PATCH 2/2] memcg: fix file mapped underflow at migration (v3)
Date: Mon, 19 Apr 2010 17:26:29 +0900 [thread overview]
Message-ID: <20100419172629.dbf65e18.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20100419170701.3864992e.nishimura@mxp.nes.nec.co.jp>
On Mon, 19 Apr 2010 17:07:01 +0900
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:
> Thank you for explaining in detail.
>
> On Mon, 19 Apr 2010 13:18:17 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> > On Mon, 19 Apr 2010 12:42:25 +0900
> > Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:
> >
> > > Hmm, before going further, will you explain why we need a new PCG_MIGRATION flag ?
> > > What's the problem of v2 ?
> > >
> >
> > v2 can't handle migration-failure case of freed swapcache and the used page
> > was swapped-out case. I think.
> >
> > All "page" in following is ANON.
> >
> >
> > mem_cgroup_prepare_migration()
> > charge against new page.
> >
> > try_to_unmap()
> > -> mapcount goes down to 0.
> > -> an old page is unchaged
> >
> But old page isn't uncharged iff PageSwapCache, is it ?
>
yes.
> > move_to_new_page()
> > -> may fail. (in some case.) ----(*1)
> >
> > remap the old page to pte.
> >
> > mem_cgroup_end_migration()
> > (at success *1)
> > check charge for newpage is valid or not (*2)
> >
> > (at fail *1)
> > uncharge new page.
> > What we should do for an old page. ---(*3)
> >
> > At (*2). (*3), there are several cases.
> >
> > (*2) migration was succeeded.
> > 1. The new page was successfully remapped.
> > -> Nothing to do.
> > 2. The new page was remapped but finally unmapped before (*3)
> > -> page_remove_rmap() will catch the event.
> > 3. The new page was not remapped.
> > -> page_remove_rmap() can't catch the event. end_migraion() has to
> > uncharge it.
> >
> > (*3) migration was failed.
> > 1. The old page was successfully remapped.
> > -> We have to recharge against the old page. (But it may hit OOM.)
> > 2. The old page wasn't remapped.
> > -> mapcount is 0. No new charge will happen.
> > 3. The old page wasn't remapped but SwapCache.
> > -> mapcount is 0. We have to recharge against the old page (But it may hit OOM)
> >
> hmm, we've done try_charge at this point, so why can we cause oom here ?
>
v2 doesn't charge. That was the bug.
"may hit OOM" is an explanation for why current implementation is used.
(current implemnation == delayed commmit charge.)
> > Maybe other seqence I couldn't write will exist......IMHO, "we have to recharge it because
> > it's uncharged.." is bad idea. It seems hard to maintainace..
> >
> >
> > When we use MIGRATION flag.
> > After migaration.
> >
> > 1. Agaisnt new page, we remove MIGRATION flag and try to uncharge() it again.
> >
> > 2. Agaisnt old page, we remove MIGRATION flag and try to uncharge it again.
> >
> > NOTE: I noticed my v3 patch is buggy when the page-is-swapped-out case. It seems
> > mem_cgroup_uncharge_swapcache() has to wait for migration ends or some
> > other case handling. (Anyway, this race exists only after unlock_page(newpage).
> > So, wait for MIGRATION ends in spin will not be very bad.)
> >
> >
> > To me, things are much simpler than now, we have to know what kind of magics behind us...
> >
> > Maybe I can think of other tricks for handling them...but using a FLAG and prevent uncharge
> > is the simplest, I think.
> >
> Anyway, I agree that current implementation is complicated and there might be
> some cases we are missing. MIGRATION flag can make it simpler.
>
I think so.
> I have one concern for now. Reading the patch, the flag have influence on
> only anonymous pages, so we'd better to note it and I feel it strange to
> set(and clear) the flag of "old page" always(iow, even when !PageAnon)
> in prepare_migration.
>
Hmm...Checking "Only Anon" is simpler ? It will have no meanings for migrating
file caches, but it may have some meanings for easy debugging.
I think "mark it always but it's used only for anonymous page" is reasonable
(if it causes no bug.)
Thanks,
-Kame
next prev parent reply other threads:[~2010-04-19 8:30 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-13 4:42 [RFC][BUGFIX][PATCH] memcg: fix underflow of mapped_file stat Daisuke Nishimura
2010-04-13 6:14 ` KAMEZAWA Hiroyuki
2010-04-14 0:54 ` Daisuke Nishimura
2010-04-14 1:03 ` KAMEZAWA Hiroyuki
2010-04-14 1:40 ` KAMEZAWA Hiroyuki
2010-04-14 1:56 ` KAMEZAWA Hiroyuki
2010-04-14 3:06 ` KAMEZAWA Hiroyuki
2010-04-14 5:31 ` Daisuke Nishimura
2010-04-14 5:40 ` KAMEZAWA Hiroyuki
2010-04-15 2:22 ` Daisuke Nishimura
2010-04-13 6:45 ` Balbir Singh
2010-04-15 3:05 ` [RFC][BUGFIX][PATCH 1/2] memcg: fix charge bypass route of migration KAMEZAWA Hiroyuki
2010-04-15 3:06 ` [RFC][BUGFIX][PATCH 2/2] memcg: fix file mapped underflow at migration (v2) KAMEZAWA Hiroyuki
2010-04-16 10:31 ` [RFC][BUGFIX][PATCH 2/2] memcg: fix file mapped underflow at migration (v3) KAMEZAWA Hiroyuki
2010-04-19 3:42 ` Daisuke Nishimura
2010-04-19 4:18 ` KAMEZAWA Hiroyuki
2010-04-19 8:07 ` Daisuke Nishimura
2010-04-19 8:26 ` KAMEZAWA Hiroyuki [this message]
2010-04-20 4:20 ` Daisuke Nishimura
2010-04-20 4:26 ` KAMEZAWA Hiroyuki
2010-04-20 9:19 ` KAMEZAWA Hiroyuki
2010-04-23 8:08 ` Daisuke Nishimura
2010-04-23 8:23 ` KAMEZAWA Hiroyuki
2010-04-15 6:43 ` [RFC][BUGFIX][PATCH 1/2] memcg: fix charge bypass route of migration Daisuke Nishimura
2010-04-15 6:56 ` KAMEZAWA Hiroyuki
2010-04-15 8:17 ` Andrea Arcangeli
2010-04-16 16:13 ` Interleave policy on 2M pages (was Re: [RFC][BUGFIX][PATCH 1/2] memcg: fix charge bypass route of migration) Christoph Lameter
2010-04-16 17:51 ` Andrea Arcangeli
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=20100419172629.dbf65e18.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=cl@linux-foundation.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=minchan.kim@gmail.com \
--cc=nishimura@mxp.nes.nec.co.jp \
--cc=riel@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).