]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
rust: add dynamic ID pool abstraction for bitmap
authorBurak Emir <bqe@google.com>
Mon, 8 Sep 2025 07:21:55 +0000 (07:21 +0000)
committerYury Norov (NVIDIA) <yury.norov@gmail.com>
Mon, 22 Sep 2025 19:52:44 +0000 (15:52 -0400)
commit2cdae413cd3ee6aad782cf4bce8c10fdb0f0657c
treee52bf5c28008be98cadc968d23c61ce35d66dd41
parent38cc91db2e87ab55bfca2b194e791867b77f9e55
rust: add dynamic ID pool abstraction for bitmap

This is a port of the Binder data structure introduced in commit
15d9da3f818c ("binder: use bitmap for faster descriptor lookup") to
Rust.

Like drivers/android/dbitmap.h, the ID pool abstraction lets
clients acquire and release IDs. The implementation uses a bitmap to
know what IDs are in use, and gives clients fine-grained control over
the time of allocation. This fine-grained control is needed in the
Android Binder. We provide an example that release a spinlock for
allocation and unit tests (rustdoc examples).

The implementation does not permit shrinking below capacity below
BITS_PER_LONG.

Suggested-by: Alice Ryhl <aliceryhl@google.com>
Suggested-by: Yury Norov <yury.norov@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Burak Emir <bqe@google.com>
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
MAINTAINERS
rust/kernel/id_pool.rs [new file with mode: 0644]
rust/kernel/lib.rs