Skip to contentSkip to conversation

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

PATCH Superseded Andreas Hindborg 3 participants 4 messages Jun 8 – Jun 10

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Andreas Hindborg

author reviewer
#0 lore raw

PATCH 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.

---
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 | 5 +++++
 1 file changed, 5 insertions(+)
rust/kernel/alloc.rs +5 -0
index e38720349dcf..c02290bb79d9 100644
@@ -126,6 +126,11 @@ pub fn new(node: i32) -> Result<Self> {
         }
         Ok(Self(node))
     }
+
+    /// Returns the raw NUMA node identifier as an `i32`.
+    pub fn id(&self) -> i32 {
+        self.0
+    }
 }
 
 /// Specify necessary constant to pass the information to Allocator that the caller doesn't care

---
base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32
change-id: 20260608-numa-node-id-85de708d4e8d

Best regards,

Signature · 1 line
Andreas Hindborg <[email protected]>
reviewer
#1 lore raw
Quoted 18 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.

---
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 | 5 +++++
 1 file changed, 5 insertions(+)
rust/kernel/alloc.rs +0 -0
index e38720349dcf..c02290bb79d9 100644

rust/kernel/alloc.rs pub fn new(node: i32) -> Result<Self> { · line 130

Quoted 5 lines
rust/kernel/alloc.rs +2 -0
@@ -126,6 +126,11 @@ pub fn new(node: i32) -> Result<Self> {
         }
         Ok(Self(node))
     }
+
+    /// Returns the raw NUMA node identifier as an `i32`.

#[inline]

Quoted 14 lines
rust/kernel/alloc.rs +3 -1
+    pub fn id(&self) -> i32 {
+        self.0
+    }
 }
 
 /// Specify necessary constant to pass the information to Allocator that the caller doesn't care
 
---

base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32
change-id: 20260608-numa-node-id-85de708d4e8d

Best regards,

Signature · 1 line
Andreas Hindborg <[email protected]>
author reviewer
#2 lore raw
Quoted 14 lines · Gary Guo
Quoted 13 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.

---
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 | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 12 lines

rust/kernel/alloc.rs pub fn new(node: i32) -> Result<Self> { · line 130

Quoted 10 lines
rust/kernel/alloc.rs +2 -0
index e38720349dcf..c02290bb79d9 100644
@@ -126,6 +126,11 @@ pub fn new(node: i32) -> Result<Self> {
         }
         Ok(Self(node))
     }
+
+    /// Returns the raw NUMA node identifier as an `i32`.

#[inline]

Sashiko will do this for you now 😆

Best regards,
Andreas Hindborg