From f344930a163d74c28b99b20f85672c7ffa0f4f14 Mon Sep 17 00:00:00 2001 From: Rafael Passos Date: Fri, 14 Aug 2026 18:50:57 -0300 Subject: [PATCH] rust_binder: speed up get_node_debug_info using lower_bound iter 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). Reviewed-by: Alice Ryhl Link: https://github.com/Rust-for-Linux/linux/issues/1249 Suggested-by: Alice Ryhl Signed-off-by: Rafael Passos Link: https://patch.msgid.link/20260814215145.2050599-1-rafael@rcpassos.me Signed-off-by: Greg Kroah-Hartman --- drivers/android/binder/process.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs index 384ce15e8a1a..451b5222b7b0 100644 --- a/drivers/android/binder/process.rs +++ b/drivers/android/binder/process.rs @@ -1216,11 +1216,10 @@ fn get_node_debug_info(&self, data: UserSlice) -> Result { { let inner = self.inner.lock(); - for (node_ptr, node) in &inner.nodes { - if *node_ptr > ptr { - node.populate_debug_info(&mut out, &inner); - break; - } + // cursor_lower_bound retrieves the "key" passed or the next existing larger key + if let Some(cursor) = inner.nodes.cursor_lower_bound(&(ptr + 1)) { + let (_, node) = cursor.current(); + node.populate_debug_info(&mut out, &inner); } }