aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2011-07-26 19:08:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 19:49:42 -0400
commit1f4c025b5a5520fd2571244196b1b01ad96d18f6 (patch)
treef2123a44c9e838eac7d08fe13443cfa04cc23f33 /mm
parentb830ac1d9a2262093bb0f3f6a2fd2a1c8278daf5 (diff)
memcg: export memory cgroup's swappiness with mem_cgroup_swappiness()
Each memory cgroup has a 'swappiness' value which 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 a 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(). With 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 <kamezawa.hiroyu@jp.fujitsu.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Michal Hocko <mhocko@suse.cz> Cc: Ying Han <yinghan@google.com> Cc: Shaohua Li <shaohua.li@intel.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c15
-rw-r--r--mm/vmscan.c23
2 files changed, 17 insertions, 21 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e013b8e57d25..506d116a7d33 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -249,7 +249,7 @@ struct mem_cgroup {
249 atomic_t oom_lock; 249 atomic_t oom_lock;
250 atomic_t refcnt; 250 atomic_t refcnt;
251 251
252 unsigned int swappiness; 252 int swappiness;
253 /* OOM-Killer disable */ 253 /* OOM-Killer disable */
254 int oom_kill_disable; 254 int oom_kill_disable;
255 255
@@ -1329,7 +1329,7 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *mem)
1329 return margin >> PAGE_SHIFT; 1329 return margin >> PAGE_SHIFT;
1330} 1330}
1331 1331
1332static unsigned int get_swappiness(struct mem_cgroup *memcg) 1332int mem_cgroup_swappiness(struct mem_cgroup *memcg)
1333{ 1333{
1334 struct cgroup *cgrp = memcg->css.cgroup; 1334 struct cgroup *cgrp = memcg->css.cgroup;
1335 1335
@@ -1776,12 +1776,11 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
1776 /* we use swappiness of local cgroup */ 1776 /* we use swappiness of local cgroup */
1777 if (check_soft) { 1777 if (check_soft) {
1778 ret = mem_cgroup_shrink_node_zone(victim, gfp_mask, 1778 ret = mem_cgroup_shrink_node_zone(victim, gfp_mask,
1779 noswap, get_swappiness(victim), zone, 1779 noswap, zone, &nr_scanned);
1780 &nr_scanned);
1781 *total_scanned += nr_scanned; 1780 *total_scanned += nr_scanned;
1782 } else 1781 } else
1783 ret = try_to_free_mem_cgroup_pages(victim, gfp_mask, 1782 ret = try_to_free_mem_cgroup_pages(victim, gfp_mask,
1784 noswap, get_swappiness(victim)); 1783 noswap);
1785 css_put(&victim->css); 1784 css_put(&victim->css);
1786 /* 1785 /*
1787 * At shrinking usage, we can't check we should stop here or 1786 * At shrinking usage, we can't check we should stop here or
@@ -3826,7 +3825,7 @@ try_to_free:
3826 goto out; 3825 goto out;
3827 } 3826 }
3828 progress = try_to_free_mem_cgroup_pages(mem, GFP_KERNEL, 3827 progress = try_to_free_mem_cgroup_pages(mem, GFP_KERNEL,
3829 false, get_swappiness(mem)); 3828 false);
3830 if (!progress) { 3829 if (!progress) {
3831 nr_retries--; 3830 nr_retries--;
3832 /* maybe some writeback is necessary */ 3831 /* maybe some writeback is necessary */
@@ -4288,7 +4287,7 @@ static u64 mem_cgroup_swappiness_read(struct cgroup *cgrp, struct cftype *cft)
4288{ 4287{
4289 struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); 4288 struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
4290 4289
4291 return get_swappiness(memcg); 4290 return mem_cgroup_swappiness(memcg);
4292} 4291}
4293 4292
4294static int mem_cgroup_swappiness_write(struct cgroup *cgrp, struct cftype *cft, 4293static 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)
4997 INIT_LIST_HEAD(&mem->oom_notify); 4996 INIT_LIST_HEAD(&mem->oom_notify);
4998 4997
4999 if (parent) 4998 if (parent)
5000 mem->swappiness = get_swappiness(parent); 4999 mem->swappiness = mem_cgroup_swappiness(parent);
5001 atomic_set(&mem->refcnt, 1); 5000 atomic_set(&mem->refcnt, 1);
5002 mem->move_charge_at_immigrate = 0; 5001 mem->move_charge_at_immigrate = 0;
5003 mutex_init(&mem->thresholds_lock); 5002 mutex_init(&mem->thresholds_lock);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index febbc044e792..05637491f244 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -95,8 +95,6 @@ struct scan_control {
95 /* Can pages be swapped as part of reclaim? */ 95 /* Can pages be swapped as part of reclaim? */
96 int may_swap; 96 int may_swap;
97 97
98 int swappiness;
99
100 int order; 98 int order;
101 99
102 /* 100 /*
@@ -1770,6 +1768,13 @@ static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
1770 return shrink_inactive_list(nr_to_scan, zone, sc, priority, file); 1768 return shrink_inactive_list(nr_to_scan, zone, sc, priority, file);
1771} 1769}
1772 1770
1771static int vmscan_swappiness(struct scan_control *sc)
1772{
1773 if (scanning_global_lru(sc))
1774 return vm_swappiness;
1775 return mem_cgroup_swappiness(sc->mem_cgroup);
1776}
1777
1773/* 1778/*
1774 * Determine how aggressively the anon and file LRU lists should be 1779 * Determine how aggressively the anon and file LRU lists should be
1775 * scanned. The relative value of each set of LRU lists is determined 1780 * scanned. The relative value of each set of LRU lists is determined
@@ -1830,8 +1835,8 @@ static void get_scan_count(struct zone *zone, struct scan_control *sc,
1830 * With swappiness at 100, anonymous and file have the same priority. 1835 * With swappiness at 100, anonymous and file have the same priority.
1831 * This scanning priority is essentially the inverse of IO cost. 1836 * This scanning priority is essentially the inverse of IO cost.
1832 */ 1837 */
1833 anon_prio = sc->swappiness; 1838 anon_prio = vmscan_swappiness(sc);
1834 file_prio = 200 - sc->swappiness; 1839 file_prio = 200 - vmscan_swappiness(sc);
1835 1840
1836 /* 1841 /*
1837 * OK, so we have swap space and a fair amount of page cache 1842 * OK, so we have swap space and a fair amount of page cache
@@ -2220,7 +2225,6 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
2220 .nr_to_reclaim = SWAP_CLUSTER_MAX, 2225 .nr_to_reclaim = SWAP_CLUSTER_MAX,
2221 .may_unmap = 1, 2226 .may_unmap = 1,
2222 .may_swap = 1, 2227 .may_swap = 1,
2223 .swappiness = vm_swappiness,
2224 .order = order, 2228 .order = order,
2225 .mem_cgroup = NULL, 2229 .mem_cgroup = NULL,
2226 .nodemask = nodemask, 2230 .nodemask = nodemask,
@@ -2244,7 +2248,6 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
2244 2248
2245unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, 2249unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
2246 gfp_t gfp_mask, bool noswap, 2250 gfp_t gfp_mask, bool noswap,
2247 unsigned int swappiness,
2248 struct zone *zone, 2251 struct zone *zone,
2249 unsigned long *nr_scanned) 2252 unsigned long *nr_scanned)
2250{ 2253{
@@ -2254,7 +2257,6 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
2254 .may_writepage = !laptop_mode, 2257 .may_writepage = !laptop_mode,
2255 .may_unmap = 1, 2258 .may_unmap = 1,
2256 .may_swap = !noswap, 2259 .may_swap = !noswap,
2257 .swappiness = swappiness,
2258 .order = 0, 2260 .order = 0,
2259 .mem_cgroup = mem, 2261 .mem_cgroup = mem,
2260 }; 2262 };
@@ -2283,8 +2285,7 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
2283 2285
2284unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, 2286unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
2285 gfp_t gfp_mask, 2287 gfp_t gfp_mask,
2286 bool noswap, 2288 bool noswap)
2287 unsigned int swappiness)
2288{ 2289{
2289 struct zonelist *zonelist; 2290 struct zonelist *zonelist;
2290 unsigned long nr_reclaimed; 2291 unsigned long nr_reclaimed;
@@ -2294,7 +2295,6 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
2294 .may_unmap = 1, 2295 .may_unmap = 1,
2295 .may_swap = !noswap, 2296 .may_swap = !noswap,
2296 .nr_to_reclaim = SWAP_CLUSTER_MAX, 2297 .nr_to_reclaim = SWAP_CLUSTER_MAX,
2297 .swappiness = swappiness,
2298 .order = 0, 2298 .order = 0,
2299 .mem_cgroup = mem_cont, 2299 .mem_cgroup = mem_cont,
2300 .nodemask = NULL, /* we don't care the placement */ 2300 .nodemask = NULL, /* we don't care the placement */
@@ -2445,7 +2445,6 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,
2445 * we want to put equal scanning pressure on each zone. 2445 * we want to put equal scanning pressure on each zone.
2446 */ 2446 */
2447 .nr_to_reclaim = ULONG_MAX, 2447 .nr_to_reclaim = ULONG_MAX,
2448 .swappiness = vm_swappiness,
2449 .order = order, 2448 .order = order,
2450 .mem_cgroup = NULL, 2449 .mem_cgroup = NULL,
2451 }; 2450 };
@@ -2915,7 +2914,6 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim)
2915 .may_writepage = 1, 2914 .may_writepage = 1,
2916 .nr_to_reclaim = nr_to_reclaim, 2915 .nr_to_reclaim = nr_to_reclaim,
2917 .hibernation_mode = 1, 2916 .hibernation_mode = 1,
2918 .swappiness = vm_swappiness,
2919 .order = 0, 2917 .order = 0,
2920 }; 2918 };
2921 struct shrink_control shrink = { 2919 struct shrink_control shrink = {
@@ -3102,7 +3100,6 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
3102 .nr_to_reclaim = max_t(unsigned long, nr_pages, 3100 .nr_to_reclaim = max_t(unsigned long, nr_pages,
3103 SWAP_CLUSTER_MAX), 3101 SWAP_CLUSTER_MAX),
3104 .gfp_mask = gfp_mask, 3102 .gfp_mask = gfp_mask,
3105 .swappiness = vm_swappiness,
3106 .order = order, 3103 .order = order,
3107 }; 3104 };
3108 struct shrink_control shrink = { 3105 struct shrink_control shrink = {