Rust-for-Linux / linux

Adding support for the Rust language to the Linux kernel.
https://rust-for-linux.com
Other
3.99k stars 430 forks source link

Enhance rbtree.rs to support predecessor/successor and lower/upper bound operations #973

Open matthewtgilbride opened 1 year ago

matthewtgilbride commented 1 year ago

What

rust/kernel/rbtree.rs only provides a map-like interface over the underlying linux rbtree. Expand that binding to support a use case in the android binder driver.

Motivation

There are a number of TODOs in drivers/android/range_alloc.rs having to do with O(n) lookups on an underlying linked list. The original driver uses red-black trees to provide faster lookup, but the rust rbtree doesn't include all the operations needed to do the same.

More info

https://docs.google.com/document/d/1SRJJj8MzzyjLGfBmqaybe5AOrM_GdPZdPWBYlu3YTcI/edit?usp=sharing&resourcekey=0-AhO9TyT3L5vM5sLIOrKMQQ

matthewtgilbride commented 1 year ago

@Darksonn - please have a look at #976 if you can - I don't have access to request review, but would like to see if this draft is close to what you were thinking

frazar commented 2 months ago

If I understand correctly, most of the 4 operations mentioned in the title of this Issue have been implemented in 98c14e40e07a077827f6842e8f31d191cb82576c:

The use cases for these were the TODOs in drivers/android/range_alloc.rs, which was dropped in b8aed800814ac7fef9a346c235147f3bd7ae0451.

Should this issue be closed? Or is it desirable to also implement the last pending operation (i.e., cursor_upper_bound())?