Re: [PATCH v3 3/3] rust: alloc: move `NumaNode` to the `numa` module
From: Gary Guo
Date: Mon Nov 09 2026 - 11:56:54 EST
On Wed Oct 28, 2026 at 2:36 PM GMT, Andreas Hindborg wrote:
> "Gary Guo" <gary@xxxxxxxxxxx> writes:
>
>>> diff --git a/rust/kernel/numa.rs b/rust/kernel/numa.rs
>>> index 164e622d325f..4a3a880308f3 100644
>>> --- a/rust/kernel/numa.rs
>>> +++ b/rust/kernel/numa.rs
>>> @@ -4,12 +4,15 @@
>>> //!
>>> //! C header: [`include/linux/nodemask.h`](srctree/include/linux/nodemask.h)
>>>
>>> -use crate::bindings;
>>> #[cfg(CONFIG_NUMA)]
>>> use crate::sync::atomic::{
>>> Atomic,
>>> Relaxed, //
>>> };
>>> +use crate::{
>>> + bindings,
>>> + prelude::*, //
>>> +};
>>>
>>> /// Returns the number of online NUMA nodes.
>>> #[inline]
>>> @@ -27,3 +30,33 @@ pub fn num_online_nodes() -> u32 {
>>> bindings::nr_online_nodes
>>> }
>>> }
>>> +
>>> +/// Non Uniform Memory Access (NUMA) node identifier.
>>> +#[derive(Clone, Copy, PartialEq)]
>>> +pub struct NumaNode(i32);
>>
>> FWIW the C type is nodemask_t and this should have mask in the name too. It is
>> not an identifier. That said, this is an existing issue, so shouldn't block the
>> move.
>
> What makes you say this? This is not a mask, it is a numa node id, which
> is represented as i32. `NUMA_NO_NODE` is a valid id.
>
> I am using this to specify domain for block mq queues. If you take a
> look at the allocation path:
>
> blk_mq_alloc_queue
> blk_alloc_queue
> slab_alloc_node
>
> It's an id, named `numa_node`, `node_id`, `node`. Not a mask. Unless I
> missed something?
Right, I got myself confused because NUMA_NO_NODE is defined in
nodemask_types.h.
If it's just an ID, would it make more sense to have `Option<NumaNode>` and
`None` to represent no node preference?
Best,
Gary