* [PATCH] rust: binder: Use lower bound for node debug lookup
@ 2026-08-31 5:26 nenkov2004
2026-08-31 5:39 ` Greg Kroah-Hartman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: nenkov2004 @ 2026-08-31 5:26 UTC (permalink / raw)
To: rust-for-linux, Greg Kroah-Hartman, Alice Ryhl
Cc: Miguel Ojeda, linux-kernel, ChrisX101010
From: ChrisX101010 <nenkov2004@gmail.com>
The Binder node debug lookup currently walks the process node RBTree
from the beginning until it finds the first node pointer greater than
the requested pointer.
Use RBTree::cursor_lower_bound() to start the lookup at the relevant
tree position instead. When the lower-bound key is equal to the
requested pointer, inspect the next node to preserve the existing
strictly-greater-than semantics.
This changes the tree lookup from a linear scan to an O(log n) search
without changing the returned node semantics.
Suggested-by: Alice Ryhl <aliceryhl@google.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1249
Signed-off-by: ChrisX101010 <nenkov2004@gmail.com>
---
drivers/android/binder/process.rs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
index 5372bfbd9..8e7218ee0 100644
--- a/drivers/android/binder/process.rs
+++ b/drivers/android/binder/process.rs
@@ -1208,10 +1208,14 @@ fn get_node_debug_info(&self, data: UserSlice) -> Result {
{
let inner = self.inner.lock();
- for (node_ptr, node) in &inner.nodes {
+
+ if let Some(cursor) = inner.nodes.cursor_lower_bound(&ptr) {
+ let (node_ptr, node) = cursor.current();
+
if *node_ptr > ptr {
node.populate_debug_info(&mut out, &inner);
- break;
+ } else if let Some((_, node)) = cursor.peek_next() {
+ node.populate_debug_info(&mut out, &inner);
}
}
}
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] rust: binder: Use lower bound for node debug lookup
2026-08-31 5:26 [PATCH] rust: binder: Use lower bound for node debug lookup nenkov2004
@ 2026-08-31 5:39 ` Greg Kroah-Hartman
2026-08-31 5:49 ` [PATCH v2] " nenkov2004
2026-08-31 12:30 ` [PATCH] " Alice Ryhl
2 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-08-31 5:39 UTC (permalink / raw)
To: nenkov2004; +Cc: rust-for-linux, Alice Ryhl, Miguel Ojeda, linux-kernel
On Mon, Aug 31, 2026 at 07:26:35AM +0200, nenkov2004@gmail.com wrote:
> From: ChrisX101010 <nenkov2004@gmail.com>
We need a real name, thanks.
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] rust: binder: Use lower bound for node debug lookup
2026-08-31 5:26 [PATCH] rust: binder: Use lower bound for node debug lookup nenkov2004
2026-08-31 5:39 ` Greg Kroah-Hartman
@ 2026-08-31 5:49 ` nenkov2004
2026-08-31 12:30 ` [PATCH] " Alice Ryhl
2 siblings, 0 replies; 4+ messages in thread
From: nenkov2004 @ 2026-08-31 5:49 UTC (permalink / raw)
To: rust-for-linux, Greg Kroah-Hartman, Alice Ryhl
Cc: Miguel Ojeda, linux-kernel, Hristos Nenkov
From: Hristos Nenkov <nenkov2004@gmail.com>
The Binder node debug lookup currently walks the process node RBTree
from the beginning until it finds the first node pointer greater than
the requested pointer.
Use RBTree::cursor_lower_bound() to start the lookup at the relevant
tree position instead. When the lower-bound key is equal to the
requested pointer, inspect the next node to preserve the existing
strictly-greater-than semantics.
This changes the tree lookup from a linear scan to an O(log n) search
without changing the returned node semantics.
Suggested-by: Alice Ryhl <aliceryhl@google.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1249
Signed-off-by: Hristos Nenkov <nenkov2004@gmail.com>
---
drivers/android/binder/process.rs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
index 5372bfbd9..8e7218ee0 100644
--- a/drivers/android/binder/process.rs
+++ b/drivers/android/binder/process.rs
@@ -1208,10 +1208,14 @@ fn get_node_debug_info(&self, data: UserSlice) -> Result {
{
let inner = self.inner.lock();
- for (node_ptr, node) in &inner.nodes {
+
+ if let Some(cursor) = inner.nodes.cursor_lower_bound(&ptr) {
+ let (node_ptr, node) = cursor.current();
+
if *node_ptr > ptr {
node.populate_debug_info(&mut out, &inner);
- break;
+ } else if let Some((_, node)) = cursor.peek_next() {
+ node.populate_debug_info(&mut out, &inner);
}
}
}
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] rust: binder: Use lower bound for node debug lookup
2026-08-31 5:26 [PATCH] rust: binder: Use lower bound for node debug lookup nenkov2004
2026-08-31 5:39 ` Greg Kroah-Hartman
2026-08-31 5:49 ` [PATCH v2] " nenkov2004
@ 2026-08-31 12:30 ` Alice Ryhl
2 siblings, 0 replies; 4+ messages in thread
From: Alice Ryhl @ 2026-08-31 12:30 UTC (permalink / raw)
To: nenkov2004; +Cc: rust-for-linux, Greg Kroah-Hartman, Miguel Ojeda, linux-kernel
On Mon, Aug 31, 2026 at 07:26:35AM +0200, nenkov2004@gmail.com wrote:
> From: ChrisX101010 <nenkov2004@gmail.com>
>
> The Binder node debug lookup currently walks the process node RBTree
> from the beginning until it finds the first node pointer greater than
> the requested pointer.
>
> Use RBTree::cursor_lower_bound() to start the lookup at the relevant
> tree position instead. When the lower-bound key is equal to the
> requested pointer, inspect the next node to preserve the existing
> strictly-greater-than semantics.
>
> This changes the tree lookup from a linear scan to an O(log n) search
> without changing the returned node semantics.
>
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Link: https://github.com/Rust-for-Linux/linux/issues/1249
> Signed-off-by: ChrisX101010 <nenkov2004@gmail.com>
This is a duplicate:
https://lore.kernel.org/all/20260814215145.2050599-1-rafael@rcpassos.me/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-31 12:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-31 5:26 [PATCH] rust: binder: Use lower bound for node debug lookup nenkov2004
2026-08-31 5:39 ` Greg Kroah-Hartman
2026-08-31 5:49 ` [PATCH v2] " nenkov2004
2026-08-31 12:30 ` [PATCH] " Alice Ryhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox