Re: [PATCH v2 2/2] xarray: honor XA_FLAGS_ACCOUNT in xas_split_alloc()

"Zi Yan" <[email protected]> Mon, 03 Aug 2026 11:12:10 -0400
Newsgroups org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
On Sat Aug 1, 2026 at 5:38 AM EDT, Lorenzo Stoakes (ARM) wrote:
> On Thu, Jul 30, 2026 at 10:18:01PM -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.
>
> Nit but maybe 'split' rather than 'have'?

Yeah, the sentence is pretty vague. How about?

xas_split_alloc() does not add _GFP_ACCOUNT when XA_FLAGS_ACCOUNT is
present. Add code to do it.

>
>>
>> Fixes: 6b24ca4a1a8d4 ("mm: Use multi-index entries in the page cache")
>
> Cc: stable?

This should go along with Patch 1. So if we decided to backport Patch 1,
I will Cc: stable for this as well.

>
>> Signed-off-by: Zi Yan <[email protected]>
>
> Makes sense to me so:
>
> Reviewed-by: Lorenzo Stoakes (ARM) <[email protected]>
>
>> ---
>>  lib/xarray.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/lib/xarray.c b/lib/xarray.c
>> index 9a8b4916540cf..bfe7bef80f34e 100644
>> --- a/lib/xarray.c
>> +++ b/lib/xarray.c
>> @@ -1053,6 +1053,9 @@ void xas_split_alloc(struct xa_state *xas, void *e=
ntry, unsigned int order,
>>  	if (xas->xa_shift + XA_CHUNK_SHIFT > order)
>>  		return;
>>
>> +	if (xas->xa->xa_flags & XA_FLAGS_ACCOUNT)
>> +		gfp |=3D __GFP_ACCOUNT;
>> +
>
> This is some confluence of flags :) I wonder if there are other places we=
've
> missed setting this for?

I did check the whole lib/xarray.c. xas_nomem(), __xas_nomem(),
xas_alloc(), xas_try_split(), and xas_split_alloc() are the ones using
gfp to allocate memory. Only xas_split_alloc() does not add
__GFP_ACCOUNT for XA_FLAGS_ACCOUNT.

--=20
Best Regards,
Yan, Zi