On Wed, Jul 09, 2025 at 07:24:58PM +0200, Vitaly Wool wrote:
> Add a new type to support specifying NUMA identifiers in Rust
> allocators and extend the allocators to have NUMA id as a
> parameter. Thus, modify ReallocFunc to use the new extended realloc
> primitives from the C side of the kernel (i. e.
> k[v]realloc_node_align/vrealloc_node_align) and add the new function
> alloc_node to the Allocator trait while keeping the existing one
> (alloc) for backward compatibility.
>
> This will allow to specify node to use for allocation of e. g.
> {KV}Box, as well as for future NUMA aware users of the API.
>
> Signed-off-by: Vitaly Wool <[email protected]>
> +/// Non Uniform Memory Access (NUMA) node identifier
Please end with a period.
> +#[derive(Clone, Copy, PartialEq)]
> +pub struct NumaNode(i32);
> +
> +impl NumaNode {
> + /// create a new NUMA node identifer (non-negative integer)
s/identifer/identifier/
Please also add an empty line in between those two.
> + /// returns EINVAL if a negative id or an id exceeding MAX_NUMNODES is
> specified
Please start with a capital letter, use markdown and end with a period.
> + pub fn new(node: i32) -> Result<Self> {
> + // SAFETY: MAX_NUMNODES never exceeds 2**10 because NODES_SHIFT is
> 0..10
This must not be a safety comment, but a normal one. Please use markdown and end
the sentence with a period.
> + if node < 0 || node >= bindings::MAX_NUMNODES as i32 {
> + return Err(EINVAL);
> + }
> + Ok(Self(node))
> + }
> +}
With that fixed,
Acked-by: Danilo Krummrich <[email protected]>