diff options
author | Filipe Brandenburger <filbranden@google.com> | 2014-03-03 18:38:25 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-03-24 00:38:20 -0400 |
commit | ba9a72974fd85701aea843b276d9773809286e74 (patch) | |
tree | dad34d0c0f0e91e9b0cdfc682aec3fe18aff68b4 /mm | |
parent | f1352fb2a38e6d57c9ec7f96c5449db616e04ef2 (diff) |
memcg: reparent charges of children before processing parent
commit 4fb1a86fb5e4209a7d4426d4e586c58e9edc74ac upstream.
Sometimes the cleanup after memcg hierarchy testing gets stuck in
mem_cgroup_reparent_charges(), unable to bring non-kmem usage down to 0.
There may turn out to be several causes, but a major cause is this: the
workitem to offline parent can get run before workitem to offline child;
parent's mem_cgroup_reparent_charges() circles around waiting for the
child's pages to be reparented to its lrus, but it's holding
cgroup_mutex which prevents the child from reaching its
mem_cgroup_reparent_charges().
Further testing showed that an ordered workqueue for cgroup_destroy_wq
is not always good enough: percpu_ref_kill_and_confirm's call_rcu_sched
stage on the way can mess up the order before reaching the workqueue.
Instead, when offlining a memcg, call mem_cgroup_reparent_charges() on
all its children (and grandchildren, in the correct order) to have their
charges reparented first.
[The version for 3.10.34 (or perhaps now 3.10.35) is this below.
Yes, more differences, and the old mem_cgroup_reparent_charges line
is intentionally left in for 3.10 whereas it was removed for 3.12+:
that's because the css/cgroup iterator changed in between, it used
not to supply the root of the subtree, but nowadays it does - Hugh]
Fixes: e5fca243abae ("cgroup: use a dedicated workqueue for cgroup destruction")
Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6115b2bbd6ea..f45e21ab9cea 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -6326,9 +6326,23 @@ static void mem_cgroup_invalidate_reclaim_iterators(struct mem_cgroup *memcg) | |||
6326 | static void mem_cgroup_css_offline(struct cgroup *cont) | 6326 | static void mem_cgroup_css_offline(struct cgroup *cont) |
6327 | { | 6327 | { |
6328 | struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); | 6328 | struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); |
6329 | struct cgroup *iter; | ||
6329 | 6330 | ||
6330 | mem_cgroup_invalidate_reclaim_iterators(memcg); | 6331 | mem_cgroup_invalidate_reclaim_iterators(memcg); |
6332 | |||
6333 | /* | ||
6334 | * This requires that offlining is serialized. Right now that is | ||
6335 | * guaranteed because css_killed_work_fn() holds the cgroup_mutex. | ||
6336 | */ | ||
6337 | rcu_read_lock(); | ||
6338 | cgroup_for_each_descendant_post(iter, cont) { | ||
6339 | rcu_read_unlock(); | ||
6340 | mem_cgroup_reparent_charges(mem_cgroup_from_cont(iter)); | ||
6341 | rcu_read_lock(); | ||
6342 | } | ||
6343 | rcu_read_unlock(); | ||
6331 | mem_cgroup_reparent_charges(memcg); | 6344 | mem_cgroup_reparent_charges(memcg); |
6345 | |||
6332 | mem_cgroup_destroy_all_caches(memcg); | 6346 | mem_cgroup_destroy_all_caches(memcg); |
6333 | } | 6347 | } |
6334 | 6348 | ||