]> git.ipfire.org Git - thirdparty/linux.git/commit
rust: id_pool: do not immediately acquire new ids
authorAlice Ryhl <aliceryhl@google.com>
Tue, 25 Nov 2025 13:59:41 +0000 (13:59 +0000)
committerYury Norov (NVIDIA) <yury.norov@gmail.com>
Tue, 2 Dec 2025 19:17:09 +0000 (14:17 -0500)
commitf523d110a63b5b38ab5d54df1d06f1e0988c9b74
tree53b856d7973b180dbbae682afdcd60fee6543794
parent69ec6a1bed3017293a3430e2f8e3c01b29496446
rust: id_pool: do not immediately acquire new ids

When Rust Binder assigns a new ID, it performs various fallible
operations before it "commits" to actually using the new ID. To support
this pattern, change acquire_next_id() so that it does not immediately
call set_bit(), but instead returns an object that may be used to call
set_bit() later.

The UnusedId type holds a exclusive reference to the IdPool, so it's
guaranteed that nobody else can call find_unused_id() while the UnusedId
object is live.

[Miguel: rust: id_pool: fix example]

Reviewed-by: Burak Emir <bqe@google.com>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
rust/kernel/id_pool.rs