aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.cz>2013-09-12 18:13:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-12 18:38:00 -0400
commita5b7c87f92076352dbff2fe0423ec255e1c9a71b (patch)
treefbc14b98d1412a078fc570914b050cd618e359f2 /mm
parente883110aad718b65de658db77387aaa69cce996d (diff)
vmscan, memcg: do softlimit reclaim also for targeted reclaim
Soft reclaim has been done only for the global reclaim (both background and direct). Since "memcg: integrate soft reclaim tighter with zone shrinking code" there is no reason for this limitation anymore as the soft limit reclaim doesn't use any special code paths and it is a part of the zone shrinking code which is used by both global and targeted reclaims. From the semantic point of view it is natural to consider soft limit before touching all groups in the hierarchy tree which is touching the hard limit because soft limit tells us where to push back when there is a memory pressure. It is not important whether the pressure comes from the limit or imbalanced zones. This patch simply enables soft reclaim unconditionally in mem_cgroup_should_soft_reclaim so it is enabled for both global and targeted reclaim paths. mem_cgroup_soft_reclaim_eligible needs to learn about the root of the reclaim to know where to stop checking soft limit state of parents up the hierarchy. Say we have A (over soft limit) \ B (below s.l., hit the hard limit) / \ C D (below s.l.) B is the source of the outside memory pressure now for D but we shouldn't soft reclaim it because it is behaving well under B subtree and we can still reclaim from C (pressumably it is over the limit). mem_cgroup_soft_reclaim_eligible should therefore stop climbing up the hierarchy at B (root of the memory pressure). Signed-off-by: Michal Hocko <mhocko@suse.cz> Reviewed-by: Glauber Costa <glommer@openvz.org> Reviewed-by: Tejun Heo <tj@kernel.org> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Greg Thelen <gthelen@google.com> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Michel Lespinasse <walken@google.com> Cc: Ying Han <yinghan@google.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.c14
-rw-r--r--mm/vmscan.c4
2 files changed, 11 insertions, 7 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 87a448dd9c10..c016e001c5b2 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1773,11 +1773,13 @@ int mem_cgroup_select_victim_node(struct mem_cgroup *memcg)
1773#endif 1773#endif
1774 1774
1775/* 1775/*
1776 * A group is eligible for the soft limit reclaim if it is 1776 * A group is eligible for the soft limit reclaim under the given root
1777 * a) is over its soft limit 1777 * hierarchy if
1778 * a) it is over its soft limit
1778 * b) any parent up the hierarchy is over its soft limit 1779 * b) any parent up the hierarchy is over its soft limit
1779 */ 1780 */
1780bool mem_cgroup_soft_reclaim_eligible(struct mem_cgroup *memcg) 1781bool mem_cgroup_soft_reclaim_eligible(struct mem_cgroup *memcg,
1782 struct mem_cgroup *root)
1781{ 1783{
1782 struct mem_cgroup *parent = memcg; 1784 struct mem_cgroup *parent = memcg;
1783 1785
@@ -1785,12 +1787,14 @@ bool mem_cgroup_soft_reclaim_eligible(struct mem_cgroup *memcg)
1785 return true; 1787 return true;
1786 1788
1787 /* 1789 /*
1788 * If any parent up the hierarchy is over its soft limit then we 1790 * If any parent up to the root in the hierarchy is over its soft limit
1789 * have to obey and reclaim from this group as well. 1791 * then we have to obey and reclaim from this group as well.
1790 */ 1792 */
1791 while((parent = parent_mem_cgroup(parent))) { 1793 while((parent = parent_mem_cgroup(parent))) {
1792 if (res_counter_soft_limit_excess(&parent->res)) 1794 if (res_counter_soft_limit_excess(&parent->res))
1793 return true; 1795 return true;
1796 if (parent == root)
1797 break;
1794 } 1798 }
1795 1799
1796 return false; 1800 return false;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index cf4643807ec2..1896e7ca494b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -142,7 +142,7 @@ static bool global_reclaim(struct scan_control *sc)
142 142
143static bool mem_cgroup_should_soft_reclaim(struct scan_control *sc) 143static bool mem_cgroup_should_soft_reclaim(struct scan_control *sc)
144{ 144{
145 return !mem_cgroup_disabled() && global_reclaim(sc); 145 return !mem_cgroup_disabled();
146} 146}
147#else 147#else
148static bool global_reclaim(struct scan_control *sc) 148static bool global_reclaim(struct scan_control *sc)
@@ -2161,7 +2161,7 @@ __shrink_zone(struct zone *zone, struct scan_control *sc, bool soft_reclaim)
2161 struct lruvec *lruvec; 2161 struct lruvec *lruvec;
2162 2162
2163 if (soft_reclaim && 2163 if (soft_reclaim &&
2164 !mem_cgroup_soft_reclaim_eligible(memcg)) { 2164 !mem_cgroup_soft_reclaim_eligible(memcg, root)) {
2165 memcg = mem_cgroup_iter(root, memcg, &reclaim); 2165 memcg = mem_cgroup_iter(root, memcg, &reclaim);
2166 continue; 2166 continue;
2167 } 2167 }