]> Pileus Git - ~andy/linux/blobdiff - mm/memcontrol.c
vmscan, memcg: do softlimit reclaim also for targeted reclaim
[~andy/linux] / mm / memcontrol.c
index 87a448dd9c104f4833d040a51689d8346591d4ce..c016e001c5b2c732f96071669199d0e1e5f4d9f5 100644 (file)
@@ -1773,11 +1773,13 @@ int mem_cgroup_select_victim_node(struct mem_cgroup *memcg)
 #endif
 
 /*
- * A group is eligible for the soft limit reclaim if it is
- *     a) is over its soft limit
+ * A group is eligible for the soft limit reclaim under the given root
+ * hierarchy if
+ *     a) it is over its soft limit
  *     b) any parent up the hierarchy is over its soft limit
  */
-bool mem_cgroup_soft_reclaim_eligible(struct mem_cgroup *memcg)
+bool mem_cgroup_soft_reclaim_eligible(struct mem_cgroup *memcg,
+               struct mem_cgroup *root)
 {
        struct mem_cgroup *parent = memcg;
 
@@ -1785,12 +1787,14 @@ bool mem_cgroup_soft_reclaim_eligible(struct mem_cgroup *memcg)
                return true;
 
        /*
-        * If any parent up the hierarchy is over its soft limit then we
-        * have to obey and reclaim from this group as well.
+        * If any parent up to the root in the hierarchy is over its soft limit
+        * then we have to obey and reclaim from this group as well.
         */
        while((parent = parent_mem_cgroup(parent))) {
                if (res_counter_soft_limit_excess(&parent->res))
                        return true;
+               if (parent == root)
+                       break;
        }
 
        return false;