aboutsummaryrefslogtreecommitdiffstats
path: root/mm/vmscan.c
diff options
context:
space:
mode:
authorJohannes Weiner <jweiner@redhat.com>2012-01-12 20:17:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-12 23:13:05 -0500
commit5660048ccac8735d9bc0a46325a02e6a6518b5b2 (patch)
tree4b2269ddd6ca001843187a89fb91278192028d87 /mm/vmscan.c
parent527a5ec9a53471d855291ba9f1fdf1dd4e12a184 (diff)
mm: move memcg hierarchy reclaim to generic reclaim code
Memory cgroup limit reclaim and traditional global pressure reclaim will soon share the same code to reclaim from a hierarchical tree of memory cgroups. In preparation of this, move the two right next to each other in shrink_zone(). The mem_cgroup_hierarchical_reclaim() polymath is split into a soft limit reclaim function, which still does hierarchy walking on its own, and a limit (shrinking) reclaim function, which relies on generic reclaim code to walk the hierarchy. Signed-off-by: Johannes Weiner <jweiner@redhat.com> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Reviewed-by: Michal Hocko <mhocko@suse.cz> Reviewed-by: Kirill A. Shutemov <kirill@shutemov.name> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Ying Han <yinghan@google.com> Cc: Greg Thelen <gthelen@google.com> Cc: Michel Lespinasse <walken@google.com> Cc: Rik van Riel <riel@redhat.com> Cc: Minchan Kim <minchan.kim@gmail.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Hugh Dickins <hughd@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmscan.c')
-rw-r--r--mm/vmscan.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index e0627d07c3ac..136c7eb0ad88 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2104,12 +2104,43 @@ restart:
2104static void shrink_zone(int priority, struct zone *zone, 2104static void shrink_zone(int priority, struct zone *zone,
2105 struct scan_control *sc) 2105 struct scan_control *sc)
2106{ 2106{
2107 struct mem_cgroup_zone mz = { 2107 struct mem_cgroup *root = sc->target_mem_cgroup;
2108 .mem_cgroup = sc->target_mem_cgroup, 2108 struct mem_cgroup_reclaim_cookie reclaim = {
2109 .zone = zone, 2109 .zone = zone,
2110 .priority = priority,
2110 }; 2111 };
2112 struct mem_cgroup *memcg;
2113
2114 if (global_reclaim(sc)) {
2115 struct mem_cgroup_zone mz = {
2116 .mem_cgroup = NULL,
2117 .zone = zone,
2118 };
2119
2120 shrink_mem_cgroup_zone(priority, &mz, sc);
2121 return;
2122 }
2123
2124 memcg = mem_cgroup_iter(root, NULL, &reclaim);
2125 do {
2126 struct mem_cgroup_zone mz = {
2127 .mem_cgroup = memcg,
2128 .zone = zone,
2129 };
2111 2130
2112 shrink_mem_cgroup_zone(priority, &mz, sc); 2131 shrink_mem_cgroup_zone(priority, &mz, sc);
2132 /*
2133 * Limit reclaim has historically picked one memcg and
2134 * scanned it with decreasing priority levels until
2135 * nr_to_reclaim had been reclaimed. This priority
2136 * cycle is thus over after a single memcg.
2137 */
2138 if (!global_reclaim(sc)) {
2139 mem_cgroup_iter_break(root, memcg);
2140 break;
2141 }
2142 memcg = mem_cgroup_iter(root, memcg, &reclaim);
2143 } while (memcg);
2113} 2144}
2114 2145
2115/* 2146/*
@@ -2374,6 +2405,10 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
2374 .order = 0, 2405 .order = 0,
2375 .target_mem_cgroup = mem, 2406 .target_mem_cgroup = mem,
2376 }; 2407 };
2408 struct mem_cgroup_zone mz = {
2409 .mem_cgroup = mem,
2410 .zone = zone,
2411 };
2377 2412
2378 sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) | 2413 sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) |
2379 (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK); 2414 (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK);
@@ -2389,7 +2424,7 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
2389 * will pick up pages from other mem cgroup's as well. We hack 2424 * will pick up pages from other mem cgroup's as well. We hack
2390 * the priority and make it zero. 2425 * the priority and make it zero.
2391 */ 2426 */
2392 shrink_zone(0, zone, &sc); 2427 shrink_mem_cgroup_zone(0, &mz, &sc);
2393 2428
2394 trace_mm_vmscan_memcg_softlimit_reclaim_end(sc.nr_reclaimed); 2429 trace_mm_vmscan_memcg_softlimit_reclaim_end(sc.nr_reclaimed);
2395 2430