From: "Onur Özkan" <work@onurozkan.dev>
To: Rafael Passos <rafael@rcpassos.me>
Cc: rust-for-linux@vger.kernel.org, gregkh@linuxfoundation.org,
arve@android.com, tkjos@android.com,
Christian Brauner <brauner@kernel.org>,
cmllamas@google.com, aliceryhl@google.com
Subject: Re: [PATCH] rust_binder: speed up get_node_debug_info using lower_bound iter
Date: Tue, 28 Jul 2026 08:48:24 +0300 [thread overview]
Message-ID: <20260728054826.172328-1-work@onurozkan.dev> (raw)
In-Reply-To: <20260728012249.3084154-1-rafael@rcpassos.me>
On Mon, 27 Jul 2026 22:22:18 -0300
Rafael Passos <rafael@rcpassos.me> wrote:
> Finding the next node in the RBTree can be done more efficiently using
> the cursor_lower_bound, as it reduces cost from O(n) to O(log n).
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1249
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Rafael Passos <rafael@rcpassos.me>
> ---
>
> (Sorry for the resend, my script missed the list)
>
> Hi, I decided to use the peek_next semantic instead of a loop/break.
> Since the iterator should land directly on ptr or greater, I think this
> is more elegant this way. But I can change it otherwise.
>
> Thanks,
> Rafael
>
>
> drivers/android/binder/process.rs | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
> index cdd1a90797266..c0c2112aca1c6 100644
> --- a/drivers/android/binder/process.rs
> +++ b/drivers/android/binder/process.rs
> @@ -1174,10 +1174,15 @@ fn get_node_debug_info(&self, data: UserSlice) -> Result {
>
> {
> let inner = self.inner.lock();
> - for (node_ptr, node) in &inner.nodes {
> + let cursor = inner.nodes.cursor_lower_bound(&ptr);
> + if let Some(c) = cursor {
Why not "if let Some(cursor) = inner.nodes.cursor_lower_bound..." ?
> + let (node_ptr, node) = c.current();
> if *node_ptr > ptr {
> node.populate_debug_info(&mut out, &inner);
> - break;
> + } else if *node_ptr == ptr {
> + if let Some((_, next_node)) = c.peek_next() {
> + next_node.populate_debug_info(&mut out, &inner);
> + }
> }
> }
> }
> --
> 2.53.0
>
next prev parent reply other threads:[~2026-07-28 5:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 1:22 [PATCH] rust_binder: speed up get_node_debug_info using lower_bound iter Rafael Passos
2026-07-28 5:48 ` Onur Özkan [this message]
2026-07-28 6:07 ` Alice Ryhl
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=20260728054826.172328-1-work@onurozkan.dev \
--to=work@onurozkan.dev \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=rafael@rcpassos.me \
--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