Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC] xarray: honor XA_FLAGS_ACCOUNT in xas_split_alloc()
@ 2026-07-28  1:51 Zi Yan
  2026-07-30 14:13 ` Johannes Weiner
  0 siblings, 1 reply; 3+ messages in thread
From: Zi Yan @ 2026-07-28  1:51 UTC (permalink / raw)
  To: Johannes Weiner, Andrew Morton, Matthew Wilcox, William Kucharski
  Cc: linux-kernel, linux-fsdevel, linux-mm, Zi Yan

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.

Thanks.

This patch, if necessary, should be applied on top of the
mapping_set_update() fix[1] to avoid causing the same issue for uniform
split path.

Link: https://lore.kernel.org/all/20260725101419.3938406-1-matt@readmodwrite.com/ [1]
---
 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 *entry, unsigned int order,
 	if (xas->xa_shift + XA_CHUNK_SHIFT > order)
 		return;
 
+	if (xas->xa->xa_flags & XA_FLAGS_ACCOUNT)
+		gfp |= __GFP_ACCOUNT;
+
 	do {
 		struct xa_node *node;
 

---
base-commit: 34cacd0ac7c10dc9e34e1b9f28a2b78d335cb487
change-id: 20260727-add-gfp_account-to-xas_split_alloc-83a1bc848b77

Best regards,
-- 
Yan, Zi



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-30 14:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28  1:51 [PATCH RFC] xarray: honor XA_FLAGS_ACCOUNT in xas_split_alloc() Zi Yan
2026-07-30 14:13 ` Johannes Weiner
2026-07-30 14:15   ` Zi Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox