From: Hiroyuki Kamezawa <kamezawa.hiroyuki@gmail.com>
To: Minchan Kim <minchan.kim@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
Steven Barrett <damentz@liquorix.net>,
Ben Gamari <bgamari.foss@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Rik van Riel <riel@redhat.com>, Mel Gorman <mel@csn.ul.ie>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Wu Fengguang <fengguang.wu@intel.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Nick Piggin <npiggin@kernel.dk>,
Andrea Arcangeli <aarcange@redhat.com>,
Balbir Singh <balbir@linux.vnet.ibm.com>
Subject: Re: [PATCH v5 2/4] memcg: move memcg reclaimable page into tail of inactive list
Date: Fri, 18 Feb 2011 13:16:43 +0900 [thread overview]
Message-ID: <AANLkTinqs1+2UJzv0PUQNF95Cs1WVuOZoDa=RXzty49g@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=2s0efMsByDKAdVTWaouk0r84RQJVrwn2h6DG_@mail.gmail.com>
2011/2/18 Minchan Kim <minchan.kim@gmail.com>:
> Hi Kame,
>
> On Fri, Feb 18, 2011 at 1:04 AM, KAMEZAWA Hiroyuki
> <kamezawa.hiroyu@jp.fujitsu.com> wrote:
>> On Fri, 18 Feb 2011 00:08:20 +0900
>> Minchan Kim <minchan.kim@gmail.com> wrote:
>>
>>> The rotate_reclaimable_page function moves just written out
>>> pages, which the VM wanted to reclaim, to the end of the
>>> inactive list. That way the VM will find those pages first
>>> next time it needs to free memory.
>>> This patch apply the rule in memcg.
>>> It can help to prevent unnecessary working page eviction of memcg.
>>>
>>> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
>>> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>>> Reviewed-by: Rik van Riel <riel@redhat.com>
>>> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>>> Cc: Johannes Weiner <hannes@cmpxchg.org>
>>> Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
>>> ---
>>> Changelog since v4:
>>> - add acked-by and reviewed-by
>>> - change description - suggested by Rik
>>>
>>> include/linux/memcontrol.h | 6 ++++++
>>> mm/memcontrol.c | 27 +++++++++++++++++++++++++++
>>> mm/swap.c | 3 ++-
>>> 3 files changed, 35 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
>>> index 3da48ae..5a5ce70 100644
>>> --- a/include/linux/memcontrol.h
>>> +++ b/include/linux/memcontrol.h
>>> @@ -62,6 +62,7 @@ extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
>>> gfp_t gfp_mask);
>>> extern void mem_cgroup_add_lru_list(struct page *page, enum lru_list lru);
>>> extern void mem_cgroup_del_lru_list(struct page *page, enum lru_list lru);
>>> +extern void mem_cgroup_rotate_reclaimable_page(struct page *page);
>>> extern void mem_cgroup_rotate_lru_list(struct page *page, enum lru_list lru);
>>> extern void mem_cgroup_del_lru(struct page *page);
>>> extern void mem_cgroup_move_lists(struct page *page,
>>> @@ -215,6 +216,11 @@ static inline void mem_cgroup_del_lru_list(struct page *page, int lru)
>>> return ;
>>> }
>>>
>>> +static inline inline void mem_cgroup_rotate_reclaimable_page(struct page *page)
>>> +{
>>> + return ;
>>> +}
>>> +
>>> static inline void mem_cgroup_rotate_lru_list(struct page *page, int lru)
>>> {
>>> return ;
>>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>>> index 686f1ce..ab8bdff 100644
>>> --- a/mm/memcontrol.c
>>> +++ b/mm/memcontrol.c
>>> @@ -813,6 +813,33 @@ void mem_cgroup_del_lru(struct page *page)
>>> mem_cgroup_del_lru_list(page, page_lru(page));
>>> }
>>>
>>> +/*
>>> + * Writeback is about to end against a page which has been marked for immediate
>>> + * reclaim. If it still appears to be reclaimable, move it to the tail of the
>>> + * inactive list.
>>> + */
>>> +void mem_cgroup_rotate_reclaimable_page(struct page *page)
>>> +{
>>> + struct mem_cgroup_per_zone *mz;
>>> + struct page_cgroup *pc;
>>> + enum lru_list lru = page_lru_base_type(page);
>>> +
>>> + if (mem_cgroup_disabled())
>>> + return;
>>> +
>>> + pc = lookup_page_cgroup(page);
>>> + /*
>>> + * Used bit is set without atomic ops but after smp_wmb().
>>> + * For making pc->mem_cgroup visible, insert smp_rmb() here.
>>> + */
>>> + smp_rmb();
>>> + /* unused or root page is not rotated. */
>>> + if (!PageCgroupUsed(pc) || mem_cgroup_is_root(pc->mem_cgroup))
>>> + return;
>>> + mz = page_cgroup_zoneinfo(pc->mem_cgroup, page);
>>> + list_move_tail(&pc->lru, &mz->lists[lru]);
>>> +}
>>> +
>>
>> Hmm, I'm sorry I misunderstand this. IIUC, page_lru_base_type() always returns
>> LRU_INACTIVE_XXX and this function may move page from active LRU to inactive LRU.
>>
>> Then, LRU counters for memcg should be updated.
>
> Goal of mem_cgroup_rotate_reclaimable_page is same with rotate_reclaimable_page.
> It means the page was already in inactive list.
> Look at the check !PageActive(page).
Hmm, ok. If so, could you change
page_lru_base_type() -> page_lru() ?
It's misleading.
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 internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-02-18 4:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-17 15:08 [PATCH v5 0/4] fadvise(DONTNEED) support Minchan Kim
2011-02-17 15:08 ` [PATCH v5 1/4] deactivate invalidated pages Minchan Kim
2011-02-17 15:50 ` KAMEZAWA Hiroyuki
2011-02-18 0:33 ` Minchan Kim
2011-02-18 4:18 ` Hiroyuki Kamezawa
2011-02-18 6:29 ` Balbir Singh
2011-02-18 10:39 ` Minchan Kim
2011-02-17 15:08 ` [PATCH v5 2/4] memcg: move memcg reclaimable page into tail of inactive list Minchan Kim
2011-02-17 16:04 ` KAMEZAWA Hiroyuki
2011-02-18 0:14 ` Minchan Kim
2011-02-18 4:16 ` Hiroyuki Kamezawa [this message]
2011-02-18 11:02 ` Minchan Kim
2011-02-17 15:08 ` [PATCH v5 3/4] Reclaim invalidated page ASAP Minchan Kim
2011-02-17 16:06 ` KAMEZAWA Hiroyuki
2011-02-17 15:08 ` [PATCH v5 4/4] add profile information for invalidated page Minchan Kim
2011-02-17 16:08 ` KAMEZAWA Hiroyuki
2011-02-18 16:58 ` Mel Gorman
2011-02-18 22:07 ` Minchan Kim
2011-02-18 23:17 ` Mel Gorman
2011-02-18 23:38 ` Minchan Kim
2011-02-18 5:55 ` [PATCH v5 0/4] fadvise(DONTNEED) support 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='AANLkTinqs1+2UJzv0PUQNF95Cs1WVuOZoDa=RXzty49g@mail.gmail.com' \
--to=kamezawa.hiroyuki@gmail.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=bgamari.foss@gmail.com \
--cc=damentz@liquorix.net \
--cc=fengguang.wu@intel.com \
--cc=hannes@cmpxchg.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=npiggin@kernel.dk \
--cc=peterz@infradead.org \
--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