linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dev Jain <dev.jain@arm.com>
To: Ackerley Tng <ackerleytng@google.com>,
	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, vannapurve@google.com
Subject: Re: Hit an assertion within lib/xarray.c from lib/test_xarray.c, would like help debugging
Date: Sat, 15 Nov 2025 12:28:53 +0530	[thread overview]
Message-ID: <aeb5ec99-11b3-4c77-8a04-469faab4210a@arm.com> (raw)
In-Reply-To: <20251028223414.299268-1-ackerleytng@google.com>

[-- Attachment #1: Type: text/plain, Size: 2735 bytes --]


On 29/10/25 4:04 am, Ackerley Tng wrote:
> Hi!
>
> I'm trying to use multi-index xarrays and I was experimenting with
> test_xarray.c.
>
> I'm trying to use xa_erase() on every index after splitting the entry in the
> xarray. (and I commented out every other test case just to focus on this test)
>
> Should erasing every index within the xarray after splitting be a supported use
> case?
>
> Here's the diff:
>
>    diff --git i/lib/test_xarray.c w/lib/test_xarray.c
>    index 5ca0aefee9aa5..fe74f44bbbd92 100644
>    --- i/lib/test_xarray.c
>    +++ w/lib/test_xarray.c
>    @@ -1868,6 +1868,9 @@ 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++)
>    +		xa_erase(xa, index + i);
>    +
>     	xa_destroy(xa);
>    }
>
> And made a call to
>
>    check_split_1(xa, 0, 3, 2);
>
> Here's the assertion I hit:
>
>    node 0x7c4de89e01c0x offset 0 parent 0x7c4de89e0100x shift 0 count 4 values 254 array 0x55edd2dd8940x list 0x7c4de89e01d8x 0x7c4de89e01d8x marks 0 10 0
>    xarray: ../shared/../../../lib/xarray.c:764: update_node: Assertion `!(1)' failed.

I changed that function to the following:

staticvoidcheck_split_1(structxarray *xa, unsignedlongindex,

unsignedintorder, unsignedintnew_order)

{

XA_STATE_ORDER(xas, xa, index, new_order);

unsignedinti;

for(i = 0; i < (1<< order); i += (1<< new_order))

xa_store_order(xa, i, new_order, xa, GFP_KERNEL);

xas_lock(&xas);

for(i = 0; i < (1<< order); i += (1<< new_order))

__xa_store(xa, index + i, xa_mk_index(index + i), 0);

xas_unlock(&xas);

xa_erase(xa, index);

xa_destroy(xa);

} and I still hit the assertion. I think the new function is still a valid code sequence -
Store multi-indices of new_order, for length = 1 << order.  Then, replace those entries
with xa_mk_index(index + i). Then erase the first index.

>
>
> I think I've narrowed down the issue to the for (;;) loop in xas_store(), which
> I believe isn't counting the `values` to be updated in update_node() correctly.
>
> Is `values += !xa_is_value(first) - !value;` intended to compute the increase in
> number of values with replacement of every slot being iterated by the new entry?
>
> Why does the computation of `count` involve next and entry, and why does the
> computation for `values` only statically depend on the initial value of entry,
> and on first instead of next?

Yeah there is some issue here only - but the code seems to work, tried a lot of
different combinations in my head like throwing out a non-value and putting in
a value, then vice-versa, then putting a NULL entry - can't figure out the problem :(

>
> Thanks,
>
>
> Ackerley
>

[-- Attachment #2: Type: text/html, Size: 7176 bytes --]

      parent reply	other threads:[~2025-11-15  6:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-28 22:34 Ackerley Tng
2025-10-31 10:40 ` David Hildenbrand
2025-11-15  6:58 ` Dev Jain [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=aeb5ec99-11b3-4c77-8a04-469faab4210a@arm.com \
    --to=dev.jain@arm.com \
    --cc=ackerleytng@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.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