From 4b34534068f6fceab57f7ad828b093c1c844ddc0 Mon Sep 17 00:00:00 2001 From: Jeffle Xu <jefflexu@linux.alibaba.com> Date: Thu, 10 Mar 2022 16:23:48 +0800 Subject: [PATCH] Revert "ck: memcg: Point wb to root memcg/blkcg when offlining to avoid zombie" ANBZ: #543 This reverts commit cd5f2e40b44e76c177c92c5c63156d78178f9225. The commit cd5f2e40b44e ("ck: memcg: Point wb to root memcg/blkcg when offlining to avoid zombie") doesn't cover all scenarios which can cause zombie memcg/blkcg. It only covers the scenario of memcg/blkcg offlining, while omitting the scenario where process is switched from one blkcg to another blkcg (refer cgwb_kill() called in cgwb_create()). Revert this commit in prep for the following patchset backported from upstream, which exactly addresses the same issue. It is worth nothing that, besides the defect described previously, there's still some visible difference between commit cd5f2e40b44e and the scheme from upstream. 1) Commit cd5f2e40b44e can only avoid zombie memcg, while it can not avoid zombie blkcg. 2) While blkcg/memcg offlining, all inodes associated with the offlining cgroup will be switched to the root memcg, while in the upstream scheme, all associated inodes will be switched to the nearest living ancestor's wb. This may affect the accounting logic after switching. Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Acked-by: Gang Deng <gavin.dg@linux.alibaba.com> --- mm/backing-dev.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index cc93e321dd8de0..f037c3f9f89199 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -964,16 +964,8 @@ void wb_memcg_offline(struct mem_cgroup *memcg) struct bdi_writeback *wb, *next; spin_lock_irq(&cgwb_lock); - list_for_each_entry_safe(wb, next, memcg_cgwb_list, memcg_node) { - percpu_ref_get(&wb->refcnt); + list_for_each_entry_safe(wb, next, memcg_cgwb_list, memcg_node) cgwb_kill(wb); - if (wb->memcg_css) { - css_put(wb->memcg_css); - wb->memcg_css = &root_mem_cgroup->css; - css_get(wb->memcg_css); - } - percpu_ref_put(&wb->refcnt); - } memcg_cgwb_list->next = NULL; /* prevent new wb's */ spin_unlock_irq(&cgwb_lock); } @@ -989,16 +981,8 @@ void wb_blkcg_offline(struct blkcg *blkcg) struct bdi_writeback *wb, *next; spin_lock_irq(&cgwb_lock); - list_for_each_entry_safe(wb, next, &blkcg->cgwb_list, blkcg_node) { - percpu_ref_get(&wb->refcnt); + list_for_each_entry_safe(wb, next, &blkcg->cgwb_list, blkcg_node) cgwb_kill(wb); - if (wb->memcg_css) { - css_put(wb->memcg_css); - wb->memcg_css = &root_mem_cgroup->css; - css_get(wb->memcg_css); - } - percpu_ref_put(&wb->refcnt); - } blkcg->cgwb_list.next = NULL; /* prevent new wb's */ spin_unlock_irq(&cgwb_lock); }