mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zi Yan <ziy@nvidia.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Matthew Wilcox <willy@infradead.org>,
	William Kucharski <william.kucharski@oracle.com>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH RFC] xarray: honor XA_FLAGS_ACCOUNT in xas_split_alloc()
Date: Thu, 30 Jul 2026 10:15:00 -0400	[thread overview]
Message-ID: <F1505345-5A3F-4313-93A3-D80A2C0D2603@nvidia.com> (raw)
In-Reply-To: <amtcBZ-_QVRgCd6b@cmpxchg.org>

On 30 Jul 2026, at 10:13, Johannes Weiner wrote:

> Hello Zi,
>
> On Mon, Jul 27, 2026 at 09:51:40PM -0400, Zi Yan wrote:
>> XArray operations that allocate xa_nodes, such as xas_nomem() and
>> xas_alloc(), add __GFP_ACCOUNT when the array has XA_FLAGS_ACCOUNT set.
>> This charges the allocated memory and avoids the workingset convergence
>> issue described by commit 7b785645e8f13 ("mm: fix page cache convergence
>> regression").
>>
>> xas_split_alloc() does not have that flag. Add it when necessary.
>>
>> Fixes: 6b24ca4a1a8d4 ("mm: Use multi-index entries in the page cache")
>> Signed-off-by: Zi Yan <ziy@nvidia.com>
>> ---
>> Hi Johannes,
>>
>> IIUC, __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, so I imagine xa_node allocated during
>> folio split would cause a similar issue. I would like to get your
>> opinion on this.
>
> Yes, you're right!
>
> As we had discussed on the THP cabal call, we should use the memcg
> context of the folio, as that could be different from the callers'
> depending on who's doing the splitting. I.e.
>
> 	memcg = get_mem_cgroup_from_folio(x);
> 	old_memcg = set_active_memcg(memcg);
>
> 	xas_split_alloc() / xas_try_split()
>
> 	set_active_memcg(old_memcg);
> 	mem_cgroup_put(memcg);
>
> There is __folio_split() -> xas_split_alloc(). But there is also
> __folio_split() -> __folio_freeze_and_split_unmapped() ->
> __split_unmapped_folio() -> xas_try_split() -> XA_FLAGS_ACCOUNT ->
> __GFP_ACCOUNT. So it would make sense to me to set up the memcg
> context in __folio_split() already.

Thank you for the detailed analysis. Will add memcg context code
and send a new version.


Best Regards,
Yan, Zi

      reply	other threads:[~2026-07-30 14:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  1:51 Zi Yan
2026-07-30 14:13 ` Johannes Weiner
2026-07-30 14:15   ` Zi Yan [this message]

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=F1505345-5A3F-4313-93A3-D80A2C0D2603@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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

all inboxes | Powered by JetHome®