The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] rust: alloc: add `NumaNode::id()` accessor
@ 2026-06-08 11:47 Andreas Hindborg
  2026-06-08 11:58 ` Gary Guo
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Hindborg @ 2026-06-08 11:47 UTC (permalink / raw)
  To: Danilo Krummrich, Lorenzo Stoakes, Vlastimil Babka,
	Liam R. Howlett, Uladzislau Rezki, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Alice Ryhl,
	Trevor Gross
  Cc: rust-for-linux, linux-kernel, 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.

Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
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(+)

diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs
index e38720349dcf..c02290bb79d9 100644
--- a/rust/kernel/alloc.rs
+++ b/rust/kernel/alloc.rs
@@ -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,
--  
Andreas Hindborg <a.hindborg@kernel.org>



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: alloc: add `NumaNode::id()` accessor
  2026-06-08 11:47 [PATCH] rust: alloc: add `NumaNode::id()` accessor Andreas Hindborg
@ 2026-06-08 11:58 ` Gary Guo
  2026-06-08 12:24   ` Andreas Hindborg
  0 siblings, 1 reply; 3+ messages in thread
From: Gary Guo @ 2026-06-08 11:58 UTC (permalink / raw)
  To: Andreas Hindborg, Danilo Krummrich, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki, Miguel Ojeda,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Alice Ryhl, Trevor Gross
  Cc: rust-for-linux, linux-kernel

On Mon Jun 8, 2026 at 12:47 PM BST, Andreas Hindborg wrote:
> `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.
>
> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
> ---
> 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(+)
>
> diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs
> index e38720349dcf..c02290bb79d9 100644
> --- a/rust/kernel/alloc.rs
> +++ b/rust/kernel/alloc.rs
> @@ -126,6 +126,11 @@ 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: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32
> change-id: 20260608-numa-node-id-85de708d4e8d
>
> Best regards,
> --  
> Andreas Hindborg <a.hindborg@kernel.org>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: alloc: add `NumaNode::id()` accessor
  2026-06-08 11:58 ` Gary Guo
@ 2026-06-08 12:24   ` Andreas Hindborg
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Hindborg @ 2026-06-08 12:24 UTC (permalink / raw)
  To: Gary Guo, Danilo Krummrich, Lorenzo Stoakes, Vlastimil Babka,
	Liam R. Howlett, Uladzislau Rezki, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Alice Ryhl,
	Trevor Gross
  Cc: rust-for-linux, linux-kernel

"Gary Guo" <gary@garyguo.net> writes:

> On Mon Jun 8, 2026 at 12:47 PM BST, Andreas Hindborg wrote:
>> `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.
>>
>> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
>> ---
>> 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(+)
>>
>> diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs
>> index e38720349dcf..c02290bb79d9 100644
>> --- a/rust/kernel/alloc.rs
>> +++ b/rust/kernel/alloc.rs
>> @@ -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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-08 12:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-08 11:47 [PATCH] rust: alloc: add `NumaNode::id()` accessor Andreas Hindborg
2026-06-08 11:58 ` Gary Guo
2026-06-08 12:24   ` Andreas Hindborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox