From: "Zi Yan" <ziy@nvidia.com>
To: "Sasha Levin" <sashal@kernel.org>, <stable@vger.kernel.org>
Cc: "Johannes Weiner" <hannes@cmpxchg.org>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Barry Song" <baohua@kernel.org>,
"David Hildenbrand" <david@kernel.org>,
"Dev Jain" <dev.jain@arm.com>,
"Lance Yang" <lance.yang@linux.dev>,
"Liam R . Howlett" <liam@infradead.org>,
"Matthew Wilcox" <willy@infradead.org>,
"Ryan Roberts" <ryan.roberts@arm.com>,
"William Kucharski" <william.kucharski@oracle.com>,
"Andrew Morton" <akpm@linux-foundation.org>
Subject: Re: [PATCH 6.6.y] mm/huge_memory: use folio's memcg inside __folio_split()
Date: Sun, 06 Sep 2026 18:46:55 -0400 [thread overview]
Message-ID: <DL8LKM3Q9LGZ.DENNSVG6XK1C@nvidia.com> (raw)
In-Reply-To: <2026-09-05-daily-reply-0043-folio-split-memcg-6-6-bounce-v2@kernel.org>
On Sun Sep 6, 2026 at 9:33 AM EDT, Sasha Levin wrote:
>> __GFP_ACCOUNT is needed for xarray node allocation accounting when
>> XA_FLAGS_ACCOUNT is set. Commit 7b785645e8f13 ("mm: fix page cache
>> convergence regression") fixed a workingset regression with it.
>> xas_split_alloc() does not have it and needs to be fixed.
>
> Mainline's c299a2285d9d takes a reference on the folio's memcg with
> get_mem_cgroup_from_folio() and holds it in current->active_memcg for the
> duration of __folio_split() - rcu_read_lock()+css_tryget(), released with
> mem_cgroup_put() afterwards. This 6.6.y version instead holds a bare
> folio_memcg(folio) pointer across the same window, which includes a TLB
> shootdown and several lock acquisitions - exactly the kind of window the
> upstream refcount exists to close.
>
> 6.6 already has rcu_read_lock(), css_tryget() and mem_cgroup_put() available,
> so nothing's missing to do this the same way upstream does. Could you resend a
> v2 that takes and drops the reference (under CONFIG_MEMCG, as upstream does)?
No, this is not needed. Before commit f1cf8d2f36dc3 ("mm: memcontrol:
eliminate the problem of dying memory cgroup for LRU folios"), like
v6.6, a charged folio take a ref on its memcg. During split, the folio
is locked, so will not be uncharged. As a result, its memcg will not go
away.
According to Claude, adding a ref there might cause a deadlock when a
to-be-split folio has a dying memcg, where css_tryget() keeps failing
and folio_memcg() keeps returning the same memcg.
This should also apply to v6.1. I will send my version for 6.1 backport.
--
Best Regards,
Yan, Zi
next prev parent reply other threads:[~2026-09-06 22:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 10:46 FAILED: patch "[PATCH] mm/huge_memory: use folio's memcg inside __folio_split()" failed to apply to 6.6-stable tree gregkh
2026-09-04 2:26 ` [PATCH 6.6.y] mm/huge_memory: use folio's memcg inside __folio_split() Zi Yan
2026-09-06 13:33 ` Sasha Levin
2026-09-06 22:46 ` Zi Yan [this message]
2026-09-08 0:53 ` Sasha Levin
2026-09-10 19:23 ` Johannes Weiner
2026-09-12 15:26 ` Sasha Levin
2026-09-12 18:31 ` Zi Yan
2026-09-15 2:03 ` Sasha Levin
2026-09-04 2:36 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DL8LKM3Q9LGZ.DENNSVG6XK1C@nvidia.com \
--to=ziy@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=hannes@cmpxchg.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=ljs@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=william.kucharski@oracle.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox