From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: Minchan Kim <minchan.kim@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>
Subject: Re: [BUGFIX][PATCH] memcg: fix memory migration of shmem swapcache
Date: Thu, 6 Jan 2011 09:52:11 +0900 [thread overview]
Message-ID: <20110106095211.b35f012b.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20110105154748.0a012407.nishimura@mxp.nes.nec.co.jp>
On Wed, 5 Jan 2011 15:47:48 +0900
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:
> On Wed, 5 Jan 2011 13:48:50 +0900
> Minchan Kim <minchan.kim@gmail.com> wrote:
>
> > Hi,
> >
> > On Wed, Jan 5, 2011 at 1:00 PM, Daisuke Nishimura
> > <nishimura@mxp.nes.nec.co.jp> wrote:
> > > Hi.
> > >
> > > This is a fix for a problem which has bothered me for a month.
> > >
> > > ===
> > > From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
> > >
> > > In current implimentation, mem_cgroup_end_migration() decides whether the page
> > > migration has succeeded or not by checking "oldpage->mapping".
> > >
> > > But if we are tring to migrate a shmem swapcache, the page->mapping of it is
> > > NULL from the begining, so the check would be invalid.
> > > As a result, mem_cgroup_end_migration() assumes the migration has succeeded
> > > even if it's not, so "newpage" would be freed while it's not uncharged.
> > >
> > > This patch fixes it by passing mem_cgroup_end_migration() the result of the
> > > page migration.
> > >
> > > Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
> > Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
> >
> > Nice catch. I don't oppose the patch.
> Thank you for your review.
>
Nice catch.
> > But as looking the code in unmap_and_move, I feel part of mem cgroup
> > migrate is rather awkward.
> >
> > int unmap_and_move()
> > {
> > charge = mem_cgroup_prepare_migration(xxx);
> > ..
> > BUG_ON(charge); <-- BUG if it is charged?
> > ..
> > uncharge:
> > if (!charge) <-- why do we have to uncharge !charge?
> > mem_group_end_migration(xxx);
> > ..
> > }
> >
> > 'charge' local variable isn't good. How about changing "uncharge" or whatever?
> hmm, I agree that current code seems a bit confusing, but I can't think of
> better name to imply the result of 'charge'.
>
> And considering more, I can't understand why we need to check "if (!charge)"
> before mem_cgroup_end_migration() becase it must be always true and, IMHO,
> mem_cgroup_end_migration() should do all necesarry checks to avoid double uncharge.
ok, please remove it.
Before this commit, http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=01b1ae63c2270cbacfd43fea94578c17950eb548;hp=bced0520fe462bb94021dcabd32e99630c171be2
"mem" is not passed as argument and this was the reason for the vairable "charge".
We can check "charge is in moving" by checking "mem == NULL".
> So, I think this local variable can be removed completely.
>
> rc = mem_cgroup_prepare_migration(..);
> if (rc == -ENOMEM)
> goto unlock;
> BUG_ON(rc);
> ..
> uncharge:
> mem_cgroup_end_migration(..);
>
> KAMEZAWA-san, what do you think ?
>
seems ok.
Thanks,
-Kame
--
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 policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-01-06 0:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-05 4:00 Daisuke Nishimura
2011-01-05 4:48 ` Minchan Kim
2011-01-05 6:47 ` Daisuke Nishimura
2011-01-05 7:18 ` Minchan Kim
2011-01-06 0:52 ` KAMEZAWA Hiroyuki [this message]
2011-01-06 2:51 ` Minchan Kim
2011-01-05 11:58 ` Johannes Weiner
2011-01-06 1:09 ` Daisuke Nishimura
2011-01-06 1:55 ` KAMEZAWA Hiroyuki
2011-01-06 2:49 ` Minchan Kim
2011-01-06 3:34 ` [BUGFIX][PATCH v3] " Daisuke Nishimura
2011-01-06 5:42 ` Balbir Singh
2011-01-06 6:29 ` [BUGFIX][PATCH v4] " Daisuke Nishimura
2011-01-08 9:26 ` Johannes Weiner
2011-01-10 9:05 ` 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=20110106095211.b35f012b.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan.kim@gmail.com \
--cc=nishimura@mxp.nes.nec.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