Re: [PATCH v6 4/6] rust: xarray: Add support for index reservations
From: Andreas Hindborg
Date: Wed Aug 05 2026 - 04:51:07 EST
"Philipp Stanner" <phasta@xxxxxxxxxx> writes:
> One often cannot allocate in the kernel with the desired flags, most
> notably in atomic context. Pre-allocating the memory is the preferred
> solution in such situations.
>
> Add support for xa_reserve() in the Rust abstractions of xarray. Create
> a Reservation object similar to a lock-guard, that can be dropped once
> the reservation is no longer needed or once the index was stored to.
>
> Signed-off-by: Philipp Stanner <phasta@xxxxxxxxxx>
> ---
> Please regard this more as an RFC.
>
> I need pre-allocating in XArray for DmaFence. How exactly we achieve
> this is open for discussion.
Do you need to actually reserve a key, or do you just need atomic
allocation?
I have a series that solves the allocation issue here [1]. Tamir did a
reservation API a while back [2].
Best regards,
Andreas Hindborg
[1] https://lore.kernel.org/r/20260604-xarray-entry-send-v4-0-965f6028790e@xxxxxxxxxx
[2] https://lore.kernel.org/r/20250701-xarray-insert-reserve-v1-0-25df2b0d706a@xxxxxxxxx