From: Balbir Singh <balbir@linux.vnet.ibm.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>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.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] memcg: fix underflow of mapped_file stat
Date: Tue, 13 Apr 2010 12:15:46 +0530 [thread overview]
Message-ID: <20100413064546.GG3994@balbir.in.ibm.com> (raw)
In-Reply-To: <20100413134207.f12cdc9c.nishimura@mxp.nes.nec.co.jp>
* nishimura@mxp.nes.nec.co.jp <nishimura@mxp.nes.nec.co.jp> [2010-04-13 13:42:07]:
> Hi.
>
> When I was testing page migration, I found underflow problem of "mapped_file" field
> in memory.stat. This is a fix for the problem.
>
> This patch is based on mmotm-2010-04-05-16-09, and IIUC it conflicts with Mel's
> compaction patches, so I send it as RFC for now. After next mmotm, which will
> include those patches, I'll update and resend this patch.
>
> ===
> From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
>
> page_add_file_rmap(), which can be called from remove_migration_ptes(), is
> assumed to increment memcg's stat of mapped file. But on success of page
> migration, the newpage(mapped file) has not been charged yet, so the stat will
> not be incremented. This behavior leads to underflow of memcg's stat because
> when the newpage is unmapped afterwards, page_remove_rmap() decrements the stat.
> This problem doesn't happen on failure path of page migration, because the old
> page(mapped file) hasn't been uncharge at the point of remove_migration_ptes().
> This patch fixes this problem by calling commit_charge(mem_cgroup_end_migration)
> before remove_migration_ptes().
>
> Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
> ---
> mm/migrate.c | 19 ++++++++++++++-----
> 1 files changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 5938db5..915c35e 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -485,7 +485,8 @@ static int fallback_migrate_page(struct address_space *mapping,
> * < 0 - error code
> * == 0 - success
> */
> -static int move_to_new_page(struct page *newpage, struct page *page)
> +static int move_to_new_page(struct page *newpage, struct page *page,
> + struct mem_cgroup *mem)
> {
> struct address_space *mapping;
> int rc;
> @@ -520,9 +521,16 @@ static int move_to_new_page(struct page *newpage, struct page *page)
> else
> rc = fallback_migrate_page(mapping, newpage, page);
>
> - if (!rc)
> + if (!rc) {
> + /*
> + * On success of page migration, the newpage has not been
> + * charged yet, so we must call end_migration() before
> + * remove_migration_ptes() to update stats of mapped file
> + * properly.
> + */
> + mem_cgroup_end_migration(mem, page, newpage);
> remove_migration_ptes(page, newpage);
> - else
> + } else
> newpage->mapping = NULL;
>
> unlock_page(newpage);
> @@ -633,7 +641,7 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
>
> skip_unmap:
> if (!page_mapped(page))
> - rc = move_to_new_page(newpage, page);
> + rc = move_to_new_page(newpage, page, mem);
Why do we need to pass mem, won't try_get_mem_cgroup_from_page() help?
Is it cost versus space tradeoff.
>
> if (rc)
> remove_migration_ptes(page, page);
> @@ -641,7 +649,8 @@ rcu_unlock:
> if (rcu_locked)
> rcu_read_unlock();
> uncharge:
> - if (!charge)
> + if (rc)
> + /* On success of page migration, we've alread called it */
Comment is not clear to me, but the code is :)
> mem_cgroup_end_migration(mem, page, newpage);
> unlock:
> unlock_page(page);
> --
> 1.6.4
>
> --
> 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>
--
Three Cheers,
Balbir
next prev parent reply other threads:[~2010-04-13 6:45 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 [this message]
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
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=20100413064546.GG3994@balbir.in.ibm.com \
--to=balbir@linux.vnet.ibm.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--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).