From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from m2.gw.fujitsu.co.jp ([10.0.50.72]) by fgwmail2.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id mAUB11tk032439 for (envelope-from kosaki.motohiro@jp.fujitsu.com); Sun, 30 Nov 2008 20:01:01 +0900 Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 1CA8145DE55 for ; Sun, 30 Nov 2008 20:01:01 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id D78B445DD79 for ; Sun, 30 Nov 2008 20:01:00 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id B9E801DB803F for ; Sun, 30 Nov 2008 20:01:00 +0900 (JST) Received: from ml13.s.css.fujitsu.com (ml13.s.css.fujitsu.com [10.249.87.103]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 65F6C1DB803B for ; Sun, 30 Nov 2008 20:01:00 +0900 (JST) From: KOSAKI Motohiro Subject: [PATCH 06/09] make get_scan_ratio() to memcg awareness In-Reply-To: <20081130193502.8145.KOSAKI.MOTOHIRO@jp.fujitsu.com> References: <20081130193502.8145.KOSAKI.MOTOHIRO@jp.fujitsu.com> Message-Id: <20081130195953.8157.KOSAKI.MOTOHIRO@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Sun, 30 Nov 2008 20:00:59 +0900 (JST) Sender: owner-linux-mm@kvack.org Return-Path: To: LKML , linux-mm , Andrew Morton , Balbir Singh , KAMEZAWA Hiroyuki , Rik van Riel Cc: kosaki.motohiro@jp.fujitsu.com List-ID: make mem_cgroup_zone_nr_pages() memcgroup aware and get_scan_ratio() too. this patch doesn't have any functional change. Signed-off-by: KOSAKI Motohiro --- include/linux/memcontrol.h | 7 +++++++ mm/memcontrol.c | 11 +++++++++++ mm/vmscan.c | 19 +++++++++++++------ 3 files changed, 31 insertions(+), 6 deletions(-) Index: b/include/linux/memcontrol.h =================================================================== --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -96,6 +96,9 @@ struct zone_reclaim_stat *mem_cgroup_get struct zone *zone); struct zone_reclaim_stat* mem_cgroup_get_reclaim_stat_by_page(struct page *page); +unsigned long mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg, + struct zone *zone, + enum lru_list lru); #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP extern int do_swap_account; @@ -266,6 +269,10 @@ mem_cgroup_get_reclaim_stat_by_page(stru return NULL; } +static inline unsigned long +mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg, struct zone *zone, + enum lru_list lru); + #endif /* CONFIG_CGROUP_MEM_CONT */ Index: b/mm/memcontrol.c =================================================================== --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -465,6 +465,17 @@ struct zone_reclaim_stat *mem_cgroup_get return &mz->reclaim_stat; } +unsigned long mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg, + struct zone *zone, + enum lru_list lru) +{ + int nid = zone->zone_pgdat->node_id; + int zid = zone_idx(zone); + struct mem_cgroup_per_zone *mz = mem_cgroup_zoneinfo(memcg, nid, zid); + + return MEM_CGROUP_ZSTAT(mz, lru); +} + unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, struct list_head *dst, Index: b/mm/vmscan.c =================================================================== --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -143,6 +143,9 @@ static struct zone_reclaim_stat *get_rec static unsigned long zone_nr_pages(struct zone *zone, struct scan_control *sc, enum lru_list lru) { + if (!scan_global_lru(sc)) + return mem_cgroup_zone_nr_pages(sc->mem_cgroup, zone, lru); + return zone_page_state(zone, NR_LRU_BASE + lru); } @@ -1446,13 +1449,16 @@ static void get_scan_ratio(struct zone * zone_nr_pages(zone, sc, LRU_INACTIVE_ANON); file = zone_nr_pages(zone, sc, LRU_ACTIVE_FILE) + zone_nr_pages(zone, sc, LRU_INACTIVE_FILE); - free = zone_page_state(zone, NR_FREE_PAGES); - /* If we have very few page cache pages, force-scan anon pages. */ - if (unlikely(file + free <= zone->pages_high)) { - percent[0] = 100; - percent[1] = 0; - return; + if (scan_global_lru(sc)) { + free = zone_page_state(zone, NR_FREE_PAGES); + /* If we have very few page cache pages, + force-scan anon pages. */ + if (unlikely(file + free <= zone->pages_high)) { + percent[0] = 100; + percent[1] = 0; + return; + } } /* @@ -1527,6 +1533,7 @@ static void shrink_zone(int priority, st scan >>= priority; scan = (scan * percent[file]) / 100; } + zone->lru[l].nr_scan += scan; nr[l] = zone->lru[l].nr_scan; if (nr[l] >= sc->swap_cluster_max) -- 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: email@kvack.org