Skip to contentSkip to conversation

rust: alloc: add `NumaNode::id()` accessor

PATCH Applied Andreas Hindborg 3 participants 3 messages Sep 29

Subsystems (2)
lore
Share & tools
lore

Andreas Hindborg

author reviewer
#0 lore raw

PATCH v2 1/1 rust: alloc: add `NumaNode::id()` accessor

NumaNode wraps an i32 but offers no way to read it back. Add a trivial id() getter so callers that need to pass the node id to a C binding can recover the underlying c_int without reaching into the private field.

---
Changes in v2:
- Rebase on v7.3-rc5.
- Add #[inline] attribute (Alice, Gary).
- Link to v1: https://msgid.link/[email protected]
---
This will be used by an upcoming change that adds a home node parameter to the block layer TagSet::new() constructor.

---
 rust/kernel/alloc.rs | 6 ++++++
 1 file changed, 6 insertions(+)
rust/kernel/alloc.rs +6 -0
index 21067bde6860..68d80f3fa6c8 100644
@@ -130,6 +130,12 @@ pub fn new(node: i32) -> Result<Self> {
         }
         Ok(Self(node))
     }
+
+    /// Returns the raw NUMA node identifier as an `i32`.
+    #[inline]
+    pub fn id(&self) -> i32 {
+        self.0
+    }
 }
 
 /// Specify necessary constant to pass the information to Allocator that the caller doesn't care

---
base-commit: 72d3fcf802c45d00b300f25b848a93c3a2bd7c7e
change-id: 20260608-numa-node-id-85de708d4e8d

Best regards,

Signature · 1 line
Andreas Hindborg <[email protected]>
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Andreas Hindborg

NumaNode wraps an i32 but offers no way to read it back. Add a trivial id() getter so callers that need to pass the node id to a C binding can recover the underlying c_int without reaching into the private field.

Quoted 11 lines

---
Changes in v2:
- Rebase on v7.3-rc5.
- Add #[inline] attribute (Alice, Gary).
- Link to v1: https://msgid.link/[email protected]
---
This will be used by an upcoming change that adds a home node parameter to the block layer TagSet::new() constructor.

---
 rust/kernel/alloc.rs | 6 ++++++
 1 file changed, 6 insertions(+)
maintainer Applied
#2 lore raw
In reply to Andreas Hindborg
Quoted 1 line · Andreas Hindborg

[PATCH v2] rust: alloc: add NumaNode::id() accessor

Applied, thanks!

Branch: alloc-next
Tree: [email protected]:Rust-for-Linux/linux.git

[1/1] rust: alloc: add NumaNode::id() accessor

      commit: 6e8339118040

The patch will appear in the next linux-next integration (typically within 24 hours on weekdays).

The patch is queued up for the upcoming merge window for the next major kernel release.