[PATCH v7 08/10] rust: id_pool: do not round capacity up to BitmapVec::MAX_INLINE_LEN

From
Eliot Courtney <hidden>
Date
2026-08-17 07:05:02
Also in
dri-devel, lkml, nova-gpu
Reply to
Eliot Courtney, 2026-08-17
Current code in IdPool::with_capacity rounds the capacity up to
BitmapVec::MAX_INLINE_LEN, but BitmapVec::new works fine with values
smaller than this and still uses an inline representation. Remove this
behaviour.

Signed-off-by: Eliot Courtney <redacted>
---
 rust/kernel/id_pool.rs | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/rust/kernel/id_pool.rs b/rust/kernel/id_pool.rs
index 382a5645767f..3e7c3d0c9dd9 100644
--- a/rust/kernel/id_pool.rs
+++ b/rust/kernel/id_pool.rs
@@ -115,14 +115,9 @@ pub fn new() -> Self {
     }
 
     /// Constructs a new [`IdPool`] with space for a specific number of bits.
-    ///
-    /// A capacity below [`MAX_INLINE_LEN`] is adjusted to [`MAX_INLINE_LEN`].
-    ///
-    /// [`MAX_INLINE_LEN`]: BitmapVec::MAX_INLINE_LEN
     #[inline]
     pub fn with_capacity(num_ids: NonZero<usize>, flags: Flags) -> Result<Self, AllocError> {
-        let num_ids = usize::max(num_ids.get(), BitmapVec::MAX_INLINE_LEN);
-        let map = BitmapVec::new(num_ids, flags)?;
+        let map = BitmapVec::new(num_ids.get(), flags)?;
         Ok(Self { map })
     }
 
-- 
2.55.0
Thread (37 messages) 37 messages, 6 authors, last reply 2026-08-25
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help