Re: [PATCH v2 1/6] rust_binder: avoid allocating under node_refs for freeze listeners
From: Matthew Maurer
Date: Thu Jun 11 2026 - 18:19:25 EST
On Tue, Jun 9, 2026 at 2:46 AM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>
> The node_refs mutex needs to be changed to a spinlock, so in preparation
> for that, update freeze.rs to avoid allocating under the node_refs lock.
> This is done by adding a retry loop so that if add_freeze_listener()
> requires reallocating the KVVec<_> of freeze listeners, the caller will
> allocate a larger vector and retry.
>
> Analogously, the remove_freeze_listener() function is updated to return
> the empty KVVec<_> when it is no longer needed, to avoid calling
> kvfree() under the node_refs lock.
>
> Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
Nit: Consider moving the clone to the success path at the end, since
the cloned node is not used until then? It's probably cheap enough
that it doesn't matter though.
>
> + node = node_ref.node.clone();
This is wrapping a single line, and is only called once. Why add a
separate function for it?
> + pub(crate) fn resize_for_add_freeze_listener(
> + vec_alloc: &mut KVVec<Arc<Process>>,
> + target_size: usize,
> + ) -> Result {
> + *vec_alloc = KVVec::with_capacity(target_size.next_power_of_two(), GFP_KERNEL)?;
> + Ok(())
> }
Otherwise looks fine.
Reviewed-By: Matthew Maurer <mmaurer@xxxxxxxxxx>