From: Ackerley Tng <ackerleytng@google.com>
To: willy@infradead.org, akpm@linux-foundation.org,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Cc: david@redhat.com, michael.roth@amd.com, dev.jain@arm.com,
vannapurve@google.com, Ackerley Tng <ackerleytng@google.com>
Subject: [RFC PATCH v1 2/2] XArray tests: Verify xa_erase behavior in check_split
Date: Fri, 30 Jan 2026 16:15:38 -0800 [thread overview]
Message-ID: <bed4d2436a0660cc406ef7f331e7ed5b7cce9896.1769818406.git.ackerleytng@google.com> (raw)
In-Reply-To: <cover.1769818406.git.ackerleytng@google.com>
Both __xa_store() and xa_erase() use xas_store() under the hood, but when
the entry being stored is NULL (as in the case of xa_erase()),
xas->xa_sibs (and max) is only checked if the next entry is not a sibling,
hence allowing xas_store() to keep iterating, hence updating
node->nr_values correctly.
Add xa_erase() to check_split tests that verify functionality, with the
added intent to illustrate the usage differences between __xa_store(),
xas_store() and xa_erase() with regard to multi-index XArrays.
Signed-off-by: Ackerley Tng <ackerleytng@google.com>
---
lib/test_xarray.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/test_xarray.c b/lib/test_xarray.c
index e71e8ff76900..bb9471a3df65 100644
--- a/lib/test_xarray.c
+++ b/lib/test_xarray.c
@@ -1874,6 +1874,10 @@ static void check_split_1(struct xarray *xa, unsigned long index,
rcu_read_unlock();
XA_BUG_ON(xa, found != 1 << (order - new_order));
+ for (i = 0; i < (1 << order); i += (1 << new_order))
+ xa_erase(xa, index + i);
+ XA_BUG_ON(xa, !xa_empty(xa));
+
xa_destroy(xa);
}
@@ -1926,6 +1930,10 @@ static void check_split_2(struct xarray *xa, unsigned long index,
}
rcu_read_unlock();
XA_BUG_ON(xa, found != 1 << (order - new_order));
+
+ for (i = 0; i < (1 << order); i += (1 << new_order))
+ xa_erase(xa, index + i);
+ XA_BUG_ON(xa, !xa_empty(xa));
out:
xas_destroy(&xas);
xa_destroy(xa);
--
2.53.0.rc1.225.gd81095ad13-goog
prev parent reply other threads:[~2026-01-31 0:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 19:16 [RFC PATCH v1 0/2] Fix storing in XArray check_split tests Ackerley Tng
2026-01-31 0:15 ` [RFC PATCH v1 1/2] XArray tests: Fix check_split tests to store correctly Ackerley Tng
2026-01-31 0:15 ` Ackerley Tng [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=bed4d2436a0660cc406ef7f331e7ed5b7cce9896.1769818406.git.ackerleytng@google.com \
--to=ackerleytng@google.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=michael.roth@amd.com \
--cc=vannapurve@google.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