From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758270Ab1F3Djt (ORCPT ); Wed, 29 Jun 2011 23:39:49 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:39065 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753921Ab1F3Djm (ORCPT ); Wed, 29 Jun 2011 23:39:42 -0400 X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.3.1 Date: Thu, 30 Jun 2011 12:32:29 +0900 From: KAMEZAWA Hiroyuki To: Andrew Morton Cc: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "nishimura@mxp.nes.nec.co.jp" , "bsingharora@gmail.com" , Michal Hocko , Ying Han Subject: Re: [PATCH] [Cleanup] memcg: export memory cgroup's swappiness v2 Message-Id: <20110630123229.37424449.kamezawa.hiroyu@jp.fujitsu.com> In-Reply-To: <20110629130043.4dc47249.akpm@linux-foundation.org> References: <20110629190325.28aa2dc6.kamezawa.hiroyu@jp.fujitsu.com> <20110629130043.4dc47249.akpm@linux-foundation.org> Organization: FUJITSU Co. LTD. X-Mailer: Sylpheed 3.1.1 (GTK+ 2.10.14; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 Jun 2011 13:00:43 -0700 Andrew Morton wrote: > On Wed, 29 Jun 2011 19:03:25 +0900 > KAMEZAWA Hiroyuki wrote: > > > Each memory cgroup has 'swappiness' value and it can be accessed by > > get_swappiness(memcg). The major user is try_to_free_mem_cgroup_pages() > > and swappiness is passed by argument. It's propagated by scan_control. > > > > get_swappiness is static function but some planned updates will need to > > get swappiness from files other than memcontrol.c > > This patch exports get_swappiness() as mem_cgroup_swappiness(). > > By this, we can remove the argument of swapiness from try_to_free... > > and drop swappiness from scan_control. only memcg uses it. > > > > > +extern unsigned int mem_cgroup_swappiness(struct mem_cgroup *mem); > > +unsigned int mem_cgroup_swappiness(struct mem_cgroup *memcg) > > +static int vmscan_swappiness(struct scan_control *sc) > > The patch seems a bit confused about the signedness of swappiness. > ok, v3 here. Now, memcg's one use "int" because vm_swapiness is "int". == >>From af1bae8f2c6a8dbff048222bb45c7162b505f38b Mon Sep 17 00:00:00 2001 From: KAMEZAWA Hiroyuki Date: Wed, 29 Jun 2011 18:24:49 +0900 Subject: [PATCH] export memory cgroup's swappines by mem_cgroup_swappiness() Each memory cgroup has 'swappiness' value and it can be accessed by get_swappiness(memcg). The major user is try_to_free_mem_cgroup_pages() and swappiness is passed by argument. It's propagated by scan_control. get_swappiness is static function but some planned updates will need to get swappiness from files other than memcontrol.c This patch exports get_swappiness() as mem_cgroup_swappiness(). By this, we can remove the argument of swapiness from try_to_free... and drop swappiness from scan_control. only memcg uses it. Signed-off-by: KAMEZAWA Hiroyuki Changelog: - adjusted signedness to vm_swappiness. - drop swappiness from scan_control --- include/linux/swap.h | 10 +++++++--- mm/memcontrol.c | 15 +++++++-------- mm/vmscan.c | 23 ++++++++++------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index a273468..0299832 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -252,11 +252,9 @@ static inline void lru_cache_add_file(struct page *page) extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, gfp_t gfp_mask, nodemask_t *mask); extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem, - gfp_t gfp_mask, bool noswap, - unsigned int swappiness); + gfp_t gfp_mask, bool noswap); extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, gfp_t gfp_mask, bool noswap, - unsigned int swappiness, struct zone *zone, unsigned long *nr_scanned); extern int __isolate_lru_page(struct page *page, int mode, int file); @@ -365,11 +363,17 @@ static inline void put_swap_token(struct mm_struct *mm) extern void mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout); extern int mem_cgroup_count_swap_user(swp_entry_t ent, struct page **pagep); +extern int mem_cgroup_swappiness(struct mem_cgroup *mem); #else static inline void mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout) { } + +static inline int mem_cgroup_swappiness(struct mem_cgroup *mem) +{ + return vm_swappiness; +} #endif #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP extern void mem_cgroup_uncharge_swap(swp_entry_t ent); diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3e7d5e6..db70176 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -249,7 +249,7 @@ struct mem_cgroup { atomic_t oom_lock; atomic_t refcnt; - unsigned int swappiness; + int swappiness; /* OOM-Killer disable */ int oom_kill_disable; @@ -1330,7 +1330,7 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *mem) return margin >> PAGE_SHIFT; } -static unsigned int get_swappiness(struct mem_cgroup *memcg) +int mem_cgroup_swappiness(struct mem_cgroup *memcg) { struct cgroup *cgrp = memcg->css.cgroup; @@ -1776,12 +1776,11 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem, /* we use swappiness of local cgroup */ if (check_soft) { ret = mem_cgroup_shrink_node_zone(victim, gfp_mask, - noswap, get_swappiness(victim), zone, - &nr_scanned); + noswap, zone, &nr_scanned); *total_scanned += nr_scanned; } else ret = try_to_free_mem_cgroup_pages(victim, gfp_mask, - noswap, get_swappiness(victim)); + noswap); css_put(&victim->css); /* * At shrinking usage, we can't check we should stop here or @@ -3826,7 +3825,7 @@ try_to_free: goto out; } progress = try_to_free_mem_cgroup_pages(mem, GFP_KERNEL, - false, get_swappiness(mem)); + false); if (!progress) { nr_retries--; /* maybe some writeback is necessary */ @@ -4288,7 +4287,7 @@ static u64 mem_cgroup_swappiness_read(struct cgroup *cgrp, struct cftype *cft) { struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); - return get_swappiness(memcg); + return mem_cgroup_swappiness(memcg); } static int mem_cgroup_swappiness_write(struct cgroup *cgrp, struct cftype *cft, @@ -4997,7 +4996,7 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) INIT_LIST_HEAD(&mem->oom_notify); if (parent) - mem->swappiness = get_swappiness(parent); + mem->swappiness = mem_cgroup_swappiness(parent); atomic_set(&mem->refcnt, 1); mem->move_charge_at_immigrate = 0; mutex_init(&mem->thresholds_lock); diff --git a/mm/vmscan.c b/mm/vmscan.c index 4f49535..fb37699 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -95,8 +95,6 @@ struct scan_control { /* Can pages be swapped as part of reclaim? */ int may_swap; - int swappiness; - int order; /* @@ -1729,6 +1727,13 @@ static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan, return shrink_inactive_list(nr_to_scan, zone, sc, priority, file); } +static int vmscan_swappiness(struct scan_control *sc) +{ + if (scanning_global_lru(sc)) + return vm_swappiness; + return mem_cgroup_swappiness(sc->mem_cgroup); +} + /* * Determine how aggressively the anon and file LRU lists should be * scanned. The relative value of each set of LRU lists is determined @@ -1789,8 +1794,8 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc, * With swappiness at 100, anonymous and file have the same priority. * This scanning priority is essentially the inverse of IO cost. */ - anon_prio = sc->swappiness; - file_prio = 200 - sc->swappiness; + anon_prio = vmscan_swappiness(sc); + file_prio = 200 - vmscan_swappiness(sc); /* * OK, so we have swap space and a fair amount of page cache @@ -2179,7 +2184,6 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .nr_to_reclaim = SWAP_CLUSTER_MAX, .may_unmap = 1, .may_swap = 1, - .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL, .nodemask = nodemask, @@ -2203,7 +2207,6 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, gfp_t gfp_mask, bool noswap, - unsigned int swappiness, struct zone *zone, unsigned long *nr_scanned) { @@ -2213,7 +2216,6 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, .may_writepage = !laptop_mode, .may_unmap = 1, .may_swap = !noswap, - .swappiness = swappiness, .order = 0, .mem_cgroup = mem, }; @@ -2242,8 +2244,7 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, gfp_t gfp_mask, - bool noswap, - unsigned int swappiness) + bool noswap) { struct zonelist *zonelist; unsigned long nr_reclaimed; @@ -2253,7 +2254,6 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, .may_unmap = 1, .may_swap = !noswap, .nr_to_reclaim = SWAP_CLUSTER_MAX, - .swappiness = swappiness, .order = 0, .mem_cgroup = mem_cont, .nodemask = NULL, /* we don't care the placement */ @@ -2403,7 +2403,6 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, * we want to put equal scanning pressure on each zone. */ .nr_to_reclaim = ULONG_MAX, - .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL, }; @@ -2862,7 +2861,6 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim) .may_writepage = 1, .nr_to_reclaim = nr_to_reclaim, .hibernation_mode = 1, - .swappiness = vm_swappiness, .order = 0, }; struct shrink_control shrink = { @@ -3049,7 +3047,6 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) .nr_to_reclaim = max_t(unsigned long, nr_pages, SWAP_CLUSTER_MAX), .gfp_mask = gfp_mask, - .swappiness = vm_swappiness, .order = order, }; struct shrink_control shrink = { -- 1.7.4.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail143.messagelabs.com (mail143.messagelabs.com [216.82.254.35]) by kanga.kvack.org (Postfix) with ESMTP id AE1B46B0092 for ; Wed, 29 Jun 2011 23:39:43 -0400 (EDT) Received: from m2.gw.fujitsu.co.jp (unknown [10.0.50.72]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 36E8F3EE0BC for ; Thu, 30 Jun 2011 12:39:40 +0900 (JST) Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 0EFC745DE7E for ; Thu, 30 Jun 2011 12:39:40 +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 E978145DE7A for ; Thu, 30 Jun 2011 12:39:39 +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 DAA481DB803C for ; Thu, 30 Jun 2011 12:39:39 +0900 (JST) Received: from ml14.s.css.fujitsu.com (ml14.s.css.fujitsu.com [10.240.81.134]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 95AC81DB803A for ; Thu, 30 Jun 2011 12:39:39 +0900 (JST) Date: Thu, 30 Jun 2011 12:32:29 +0900 From: KAMEZAWA Hiroyuki Subject: Re: [PATCH] [Cleanup] memcg: export memory cgroup's swappiness v2 Message-Id: <20110630123229.37424449.kamezawa.hiroyu@jp.fujitsu.com> In-Reply-To: <20110629130043.4dc47249.akpm@linux-foundation.org> References: <20110629190325.28aa2dc6.kamezawa.hiroyu@jp.fujitsu.com> <20110629130043.4dc47249.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "nishimura@mxp.nes.nec.co.jp" , "bsingharora@gmail.com" , Michal Hocko , Ying Han On Wed, 29 Jun 2011 13:00:43 -0700 Andrew Morton wrote: > On Wed, 29 Jun 2011 19:03:25 +0900 > KAMEZAWA Hiroyuki wrote: > > > Each memory cgroup has 'swappiness' value and it can be accessed by > > get_swappiness(memcg). The major user is try_to_free_mem_cgroup_pages() > > and swappiness is passed by argument. It's propagated by scan_control. > > > > get_swappiness is static function but some planned updates will need to > > get swappiness from files other than memcontrol.c > > This patch exports get_swappiness() as mem_cgroup_swappiness(). > > By this, we can remove the argument of swapiness from try_to_free... > > and drop swappiness from scan_control. only memcg uses it. > > > > > +extern unsigned int mem_cgroup_swappiness(struct mem_cgroup *mem); > > +unsigned int mem_cgroup_swappiness(struct mem_cgroup *memcg) > > +static int vmscan_swappiness(struct scan_control *sc) > > The patch seems a bit confused about the signedness of swappiness. > ok, v3 here. Now, memcg's one use "int" because vm_swapiness is "int". ==