From: Alice Ryhl <aliceryhl@google.com>
To: Peder Bergan <peder.bergan@gmail.com>
Cc: "Alice Ryhl" <aliceryhl@google.com>,
"Carlos Llamas" <cmllamas@google.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Christian Brauner" <brauner@kernel.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust_binder: Reuse the free-index node in the range allocator
Date: Sun, 29 Nov 2026 13:21:36 +0000 [thread overview]
Message-ID: <20261129132136.1489927-1-aliceryhl@google.com> (raw)
In-Reply-To: <20261126-perf-binder-range-allocator-v1-1-7d924585d735@gmail.com>
On Thu, Nov 26, 2026 at 07:06:03PM +0100, Peder Bergan wrote:
> Convert the detached node into an RBTreeNodeReservation and store it
> with the buffer. The release path can initialize the key after
> coalescing the range. This reduces preparation from three fresh node
> allocations to two and avoids one free under the process spinlock
> per successful tree reservation, for both exact fits and splits.
Nice optimization, thanks!
> + // Keep the removed index node so releasing this buffer can restore a free range
> + // without allocating under the lock.
> + let free_node_res = self
> + .free_tree
> + .remove_node(&(found_size, found_off))
> + .ok_or(EINVAL)?
> + .into_reservation();
> + desc.state = Some((DescriptorState::new(is_oneway, debug_id, pid), free_node_res));
Please run `rustfmt` on drivers/android/binder/range_alloc/tree.rs.
Also, optionally, you could use `self.free_tree.cursor_lower_bound_mut()`
and `cursor.remove_current().1.into_reservation()` to avoid the second
`free_tree` lookup and the unreachable `EINVAL` path, though I'm fine
with either approach.
With the `rustfmt` diff fixed, feel free to add:
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Alice
next prev parent reply other threads:[~2026-11-29 13:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 18:06 Peder Bergan via B4 Relay
2026-11-29 13:21 ` Alice Ryhl [this message]
2026-11-29 18:50 ` Peder Bergan
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=20261129132136.1489927-1-aliceryhl@google.com \
--to=aliceryhl@google.com \
--cc=arve@android.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peder.bergan@gmail.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=tkjos@android.com \
/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
all inboxes | Powered by JetHome®