Re: [PATCH v3 08/30] mm: memcontrol: prevent memory cgroup release in get_mem_cgroup_from_folio()
From: Shakeel Butt
Date: Sat Jan 17 2026 - 15:01:19 EST
On Wed, Jan 14, 2026 at 07:32:35PM +0800, Qi Zheng wrote:
> From: Muchun Song <songmuchun@xxxxxxxxxxxxx>
>
> In the near future, a folio will no longer pin its corresponding
> memory cgroup. To ensure safety, it will only be appropriate to
> hold the rcu read lock or acquire a reference to the memory cgroup
> returned by folio_memcg(), thereby preventing it from being released.
>
> In the current patch, the rcu read lock is employed to safeguard
> against the release of the memory cgroup in get_mem_cgroup_from_folio().
>
> This serves as a preparatory measure for the reparenting of the
> LRU pages.
This patch is adding a retry loop as css_tryget() on folio_memcg() can
fail because after reparenting functionality the folio no longer holds
down the memcg. Please clarify this reasoning in the commit.
With that:
Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>