[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0d78a4cf-0973-4874-ab6a-978621a17068@huaweicloud.com>
Date: Thu, 20 Nov 2025 17:07:47 +0800
From: Chen Ridong <chenridong@...weicloud.com>
To: Qi Zheng <qi.zheng@...ux.dev>, hannes@...xchg.org, hughd@...gle.com,
mhocko@...e.com, roman.gushchin@...ux.dev, shakeel.butt@...ux.dev,
muchun.song@...ux.dev, david@...hat.com, lorenzo.stoakes@...cle.com,
ziy@...dia.com, harry.yoo@...cle.com, imran.f.khan@...cle.com,
kamalesh.babulal@...cle.com, axelrasmussen@...gle.com, yuanchu@...gle.com,
weixugc@...gle.com, akpm@...ux-foundation.org
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
cgroups@...r.kernel.org, Muchun Song <songmuchun@...edance.com>,
Qi Zheng <zhengqi.arch@...edance.com>
Subject: Re: [PATCH v1 01/26] mm: memcontrol: remove dead code of checking
parent memory cgroup
On 2025/10/28 21:58, Qi Zheng wrote:
> From: Muchun Song <songmuchun@...edance.com>
>
> Since the no-hierarchy mode has been deprecated after the commit:
>
> commit bef8620cd8e0 ("mm: memcg: deprecate the non-hierarchical mode").
>
> As a result, parent_mem_cgroup() will not return NULL except when passing
> the root memcg, and the root memcg cannot be offline. Hence, it's safe to
> remove the check on the returned value of parent_mem_cgroup(). Remove the
> corresponding dead code.
>
> Signed-off-by: Muchun Song <songmuchun@...edance.com>
> Acked-by: Roman Gushchin <roman.gushchin@...ux.dev>
> Acked-by: Johannes Weiner <hannes@...xchg.org>
> Signed-off-by: Qi Zheng <zhengqi.arch@...edance.com>
> ---
> mm/memcontrol.c | 5 -----
> mm/shrinker.c | 6 +-----
> 2 files changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 93f7c76f0ce96..d5257465c9d75 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -3339,9 +3339,6 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg)
> return;
>
> parent = parent_mem_cgroup(memcg);
> - if (!parent)
> - parent = root_mem_cgroup;
> -
> memcg_reparent_list_lrus(memcg, parent);
>
> /*
> @@ -3632,8 +3629,6 @@ struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg)
> break;
> }
> memcg = parent_mem_cgroup(memcg);
> - if (!memcg)
> - memcg = root_mem_cgroup;
> }
> return memcg;
> }
> diff --git a/mm/shrinker.c b/mm/shrinker.c
> index 4a93fd433689a..e8e092a2f7f41 100644
> --- a/mm/shrinker.c
> +++ b/mm/shrinker.c
> @@ -286,14 +286,10 @@ void reparent_shrinker_deferred(struct mem_cgroup *memcg)
> {
> int nid, index, offset;
> long nr;
> - struct mem_cgroup *parent;
> + struct mem_cgroup *parent = parent_mem_cgroup(memcg);
> struct shrinker_info *child_info, *parent_info;
> struct shrinker_info_unit *child_unit, *parent_unit;
>
> - parent = parent_mem_cgroup(memcg);
> - if (!parent)
> - parent = root_mem_cgroup;
> -
> /* Prevent from concurrent shrinker_info expand */
> mutex_lock(&shrinker_mutex);
> for_each_node(nid) {
LGTM.
Reviewed-by: Chen Ridong <chenridong@...wei.com>
--
Best regards,
Ridong
Powered by blists - more mailing lists