From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
xemul@openvz.org
Subject: Re: [PATCH -mm] memcg: fix handling of shmem migration(v2)
Date: Wed, 17 Sep 2008 22:43:58 -0700 [thread overview]
Message-ID: <48D1EA9E.9030309@linux.vnet.ibm.com> (raw)
In-Reply-To: <20080918113851.16082bb7.kamezawa.hiroyu@jp.fujitsu.com>
KAMEZAWA Hiroyuki wrote:
> On Wed, 17 Sep 2008 15:51:12 -0700
> Andrew Morton <akpm@linux-foundation.org> wrote:
>
>> On Wed, 17 Sep 2008 16:55:44 +0900
>> Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:
>>
>>> Before this patch, if migrating shmem/tmpfs pages, newpage would be
>>> charged with PAGE_CGROUP_FLAG_FILE set, while oldpage has been charged
>>> without the flag.
>>>
>>> The problem here is mem_cgroup_move_lists doesn't clear(or set)
>>> the PAGE_CGROUP_FLAG_FILE flag, so pc->flags of the newpage
>>> remains PAGE_CGROUP_FLAG_FILE set even when the pc is moved to
>>> another lru(anon) by mem_cgroup_move_lists. And this leads to
>>> incorrect MEM_CGROUP_ZSTAT.
>>> (In my test, I see an underflow of MEM_CGROUP_ZSTAT(active_file).
>>> As a result, mem_cgroup_calc_reclaim returns very huge number and
>>> causes soft lockup on page reclaim.)
>>>
>>> I'm not sure if mem_cgroup_move_lists should handle PAGE_CGROUP_FLAG_FILE
>>> or not(I suppose it should be used to move between active <-> inactive,
>>> not anon <-> file), I added MEM_CGROUP_CHARGE_TYPE_SHMEM for precharge
>>> at shmem's page migration.
>>>
>>>
>>> ChangeLog: v1->v2
>>> - instead of modifying migrate.c, modify memcontrol.c only.
>>> - add MEM_CGROUP_CHARGE_TYPE_SHMEM.
>>>
>>>
>>> Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
>>> ---
>>> mm/memcontrol.c | 13 ++++++++++---
>>> 1 files changed, 10 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>>> index 2979d22..ef8812d 100644
>>> --- a/mm/memcontrol.c
>>> +++ b/mm/memcontrol.c
>>> @@ -179,6 +179,7 @@ enum charge_type {
>>> MEM_CGROUP_CHARGE_TYPE_CACHE = 0,
>>> MEM_CGROUP_CHARGE_TYPE_MAPPED,
>>> MEM_CGROUP_CHARGE_TYPE_FORCE, /* used by force_empty */
>>> + MEM_CGROUP_CHARGE_TYPE_SHMEM, /* used by page migration of shmem */
>>> };
>>>
>>> /*
>>> @@ -579,8 +580,10 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
>>> pc->flags |= PAGE_CGROUP_FLAG_FILE;
>>> else
>>> pc->flags |= PAGE_CGROUP_FLAG_ACTIVE;
>>> - } else
>>> + } else if (ctype == MEM_CGROUP_CHARGE_TYPE_MAPPED)
>>> pc->flags = PAGE_CGROUP_FLAG_ACTIVE;
>>> + else /* MEM_CGROUP_CHARGE_TYPE_SHMEM */
>>> + pc->flags = PAGE_CGROUP_FLAG_CACHE | PAGE_CGROUP_FLAG_ACTIVE;
>>>
>>> lock_page_cgroup(page);
>>> if (unlikely(page_get_page_cgroup(page))) {
>>> @@ -739,8 +742,12 @@ int mem_cgroup_prepare_migration(struct page *page, struct page *newpage)
>>> if (pc) {
>>> mem = pc->mem_cgroup;
>>> css_get(&mem->css);
>>> - if (pc->flags & PAGE_CGROUP_FLAG_CACHE)
>>> - ctype = MEM_CGROUP_CHARGE_TYPE_CACHE;
>>> + if (pc->flags & PAGE_CGROUP_FLAG_CACHE) {
>>> + if (page_is_file_cache(page))
>>> + ctype = MEM_CGROUP_CHARGE_TYPE_CACHE;
>>> + else
>>> + ctype = MEM_CGROUP_CHARGE_TYPE_SHMEM;
>>> + }
>>> }
>>> unlock_page_cgroup(page);
>>> if (mem) {
>> I queued this as a fix against
>> vmscan-split-lru-lists-into-anon-file-sets.patch. Was that appropriate?
>>
>> If the bug you're fixing here is also present in mainline then I'll
>> need to ask for a tested patch against mainline, please.
>>
> I think this bug depends on split-lru patch set.
> Mayne not in mainline yet...?
Yes, that sounds correct to me, this should be a -mm only patch.
--
Balbir
WARNING: multiple messages have this Message-ID (diff)
From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
xemul@openvz.org
Subject: Re: [PATCH -mm] memcg: fix handling of shmem migration(v2)
Date: Wed, 17 Sep 2008 22:43:58 -0700 [thread overview]
Message-ID: <48D1EA9E.9030309@linux.vnet.ibm.com> (raw)
In-Reply-To: <20080918113851.16082bb7.kamezawa.hiroyu@jp.fujitsu.com>
KAMEZAWA Hiroyuki wrote:
> On Wed, 17 Sep 2008 15:51:12 -0700
> Andrew Morton <akpm@linux-foundation.org> wrote:
>
>> On Wed, 17 Sep 2008 16:55:44 +0900
>> Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:
>>
>>> Before this patch, if migrating shmem/tmpfs pages, newpage would be
>>> charged with PAGE_CGROUP_FLAG_FILE set, while oldpage has been charged
>>> without the flag.
>>>
>>> The problem here is mem_cgroup_move_lists doesn't clear(or set)
>>> the PAGE_CGROUP_FLAG_FILE flag, so pc->flags of the newpage
>>> remains PAGE_CGROUP_FLAG_FILE set even when the pc is moved to
>>> another lru(anon) by mem_cgroup_move_lists. And this leads to
>>> incorrect MEM_CGROUP_ZSTAT.
>>> (In my test, I see an underflow of MEM_CGROUP_ZSTAT(active_file).
>>> As a result, mem_cgroup_calc_reclaim returns very huge number and
>>> causes soft lockup on page reclaim.)
>>>
>>> I'm not sure if mem_cgroup_move_lists should handle PAGE_CGROUP_FLAG_FILE
>>> or not(I suppose it should be used to move between active <-> inactive,
>>> not anon <-> file), I added MEM_CGROUP_CHARGE_TYPE_SHMEM for precharge
>>> at shmem's page migration.
>>>
>>>
>>> ChangeLog: v1->v2
>>> - instead of modifying migrate.c, modify memcontrol.c only.
>>> - add MEM_CGROUP_CHARGE_TYPE_SHMEM.
>>>
>>>
>>> Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
>>> ---
>>> mm/memcontrol.c | 13 ++++++++++---
>>> 1 files changed, 10 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>>> index 2979d22..ef8812d 100644
>>> --- a/mm/memcontrol.c
>>> +++ b/mm/memcontrol.c
>>> @@ -179,6 +179,7 @@ enum charge_type {
>>> MEM_CGROUP_CHARGE_TYPE_CACHE = 0,
>>> MEM_CGROUP_CHARGE_TYPE_MAPPED,
>>> MEM_CGROUP_CHARGE_TYPE_FORCE, /* used by force_empty */
>>> + MEM_CGROUP_CHARGE_TYPE_SHMEM, /* used by page migration of shmem */
>>> };
>>>
>>> /*
>>> @@ -579,8 +580,10 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
>>> pc->flags |= PAGE_CGROUP_FLAG_FILE;
>>> else
>>> pc->flags |= PAGE_CGROUP_FLAG_ACTIVE;
>>> - } else
>>> + } else if (ctype == MEM_CGROUP_CHARGE_TYPE_MAPPED)
>>> pc->flags = PAGE_CGROUP_FLAG_ACTIVE;
>>> + else /* MEM_CGROUP_CHARGE_TYPE_SHMEM */
>>> + pc->flags = PAGE_CGROUP_FLAG_CACHE | PAGE_CGROUP_FLAG_ACTIVE;
>>>
>>> lock_page_cgroup(page);
>>> if (unlikely(page_get_page_cgroup(page))) {
>>> @@ -739,8 +742,12 @@ int mem_cgroup_prepare_migration(struct page *page, struct page *newpage)
>>> if (pc) {
>>> mem = pc->mem_cgroup;
>>> css_get(&mem->css);
>>> - if (pc->flags & PAGE_CGROUP_FLAG_CACHE)
>>> - ctype = MEM_CGROUP_CHARGE_TYPE_CACHE;
>>> + if (pc->flags & PAGE_CGROUP_FLAG_CACHE) {
>>> + if (page_is_file_cache(page))
>>> + ctype = MEM_CGROUP_CHARGE_TYPE_CACHE;
>>> + else
>>> + ctype = MEM_CGROUP_CHARGE_TYPE_SHMEM;
>>> + }
>>> }
>>> unlock_page_cgroup(page);
>>> if (mem) {
>> I queued this as a fix against
>> vmscan-split-lru-lists-into-anon-file-sets.patch. Was that appropriate?
>>
>> If the bug you're fixing here is also present in mainline then I'll
>> need to ask for a tested patch against mainline, please.
>>
> I think this bug depends on split-lru patch set.
> Mayne not in mainline yet...?
Yes, that sounds correct to me, this should be a -mm only patch.
--
Balbir
--
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>
next prev parent reply other threads:[~2008-09-18 5:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-17 4:31 [PATCH -mm] memcg: fix handling of shmem migration Daisuke Nishimura
2008-09-17 4:31 ` Daisuke Nishimura
2008-09-17 5:46 ` KAMEZAWA Hiroyuki
2008-09-17 5:46 ` KAMEZAWA Hiroyuki
2008-09-17 5:50 ` KAMEZAWA Hiroyuki
2008-09-17 5:50 ` KAMEZAWA Hiroyuki
2008-09-17 6:19 ` Daisuke Nishimura
2008-09-17 6:19 ` Daisuke Nishimura
2008-09-17 6:38 ` KAMEZAWA Hiroyuki
2008-09-17 6:38 ` KAMEZAWA Hiroyuki
2008-09-17 6:45 ` Daisuke Nishimura
2008-09-17 6:45 ` Daisuke Nishimura
2008-09-17 7:55 ` [PATCH -mm] memcg: fix handling of shmem migration(v2) Daisuke Nishimura
2008-09-17 7:55 ` Daisuke Nishimura
2008-09-17 9:18 ` KAMEZAWA Hiroyuki
2008-09-17 9:18 ` KAMEZAWA Hiroyuki
2008-09-17 22:51 ` Andrew Morton
2008-09-17 22:51 ` Andrew Morton
2008-09-18 2:03 ` Daisuke Nishimura
2008-09-18 2:03 ` Daisuke Nishimura
2008-09-18 2:38 ` KAMEZAWA Hiroyuki
2008-09-18 2:38 ` KAMEZAWA Hiroyuki
2008-09-18 5:43 ` Balbir Singh [this message]
2008-09-18 5:43 ` 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=48D1EA9E.9030309@linux.vnet.ibm.com \
--to=balbir@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nishimura@mxp.nes.nec.co.jp \
--cc=xemul@openvz.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.