aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.cz>2013-09-12 18:13:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-12 18:38:01 -0400
commit1be171d60bddcce2602c5d009029274d67736fd7 (patch)
treedc5ae61d05ea53d0c9321494a2206d42564af8a5 /mm
parente839b6a1c8d0895803bcbd587595a54f4221a625 (diff)
memcg: track all children over limit in the root
Children in soft limit excess are currently tracked up the hierarchy in memcg->children_in_excess. Nevertheless there still might exist tons of groups that are not in hierarchy relation to the root cgroup (e.g. all first level groups if root_mem_cgroup->use_hierarchy == false). As the whole tree walk has to be done when the iteration starts at root_mem_cgroup the iterator should be able to skip the walk if there is no child above the limit without iterating them. This can be done easily if the root tracks all children rather than only hierarchical children. This is done by this patch which updates root_mem_cgroup children_in_excess if root_mem_cgroup->use_hierarchy == false so the root knows about all children in excess. Please note that this is not an issue for inner memcgs which have use_hierarchy == false because then only the single group is visited so no special optimization is necessary. Signed-off-by: Michal Hocko <mhocko@suse.cz> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Glauber Costa <glommer@openvz.org> 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: Tejun Heo <tj@kernel.org> 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.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 848fc6c195d2..46717d6c62b7 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -864,9 +864,15 @@ static void mem_cgroup_update_soft_limit(struct mem_cgroup *memcg)
864 /* 864 /*
865 * Necessary to update all ancestors when hierarchy is used 865 * Necessary to update all ancestors when hierarchy is used
866 * because their event counter is not touched. 866 * because their event counter is not touched.
867 * We track children even outside the hierarchy for the root
868 * cgroup because tree walk starting at root should visit
869 * all cgroups and we want to prevent from pointless tree
870 * walk if no children is below the limit.
867 */ 871 */
868 while (delta && (parent = parent_mem_cgroup(parent))) 872 while (delta && (parent = parent_mem_cgroup(parent)))
869 atomic_add(delta, &parent->children_in_excess); 873 atomic_add(delta, &parent->children_in_excess);
874 if (memcg != root_mem_cgroup && !root_mem_cgroup->use_hierarchy)
875 atomic_add(delta, &root_mem_cgroup->children_in_excess);
870 spin_unlock(&memcg->soft_lock); 876 spin_unlock(&memcg->soft_lock);
871} 877}
872 878
@@ -6043,6 +6049,9 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
6043 if (memcg->soft_contributed) { 6049 if (memcg->soft_contributed) {
6044 while ((memcg = parent_mem_cgroup(memcg))) 6050 while ((memcg = parent_mem_cgroup(memcg)))
6045 atomic_dec(&memcg->children_in_excess); 6051 atomic_dec(&memcg->children_in_excess);
6052
6053 if (memcg != root_mem_cgroup && !root_mem_cgroup->use_hierarchy)
6054 atomic_dec(&root_mem_cgroup->children_in_excess);
6046 } 6055 }
6047 mem_cgroup_destroy_all_caches(memcg); 6056 mem_cgroup_destroy_all_caches(memcg);
6048 vmpressure_cleanup(&memcg->vmpressure); 6057 vmpressure_cleanup(&memcg->vmpressure);