linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: Vitaly Wool <vitaly.wool@konsulko.se>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, Uladzislau Rezki <urezki@gmail.com>,
	Alice Ryhl <aliceryhl@google.com>,
	rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v8 3/4] rust: add support for NUMA ids in allocations
Date: Sat, 28 Jun 2025 14:21:01 +0200	[thread overview]
Message-ID: <aF_eLTlirxl-1jPP@pollux> (raw)
In-Reply-To: <20250628102611.2542910-1-vitaly.wool@konsulko.se>

On Sat, Jun 28, 2025 at 12:26:11PM +0200, Vitaly Wool wrote:
> +/// Non Uniform Memory Access (NUMA) node identifier
> +#[derive(Clone, Copy, PartialEq)]
> +pub struct NumaNode(i32);
> +
> +impl NumaNode {
> +    /// create a new NUMA node identifer (non-negative integer)
> +    /// returns EINVAL if a negative id is specified
> +    pub fn new(node: i32) -> Result<Self> {
> +        if node < 0 {
> +            return Err(EINVAL);
> +        }

Should we also check for MAX_NUMNODES?

> +        Ok(Self(node))
> +    }
> +}

<snip>

> +    /// Re-allocate an existing memory allocation to satisfy the requested `layout` and
> +    /// optionally a specific NUMA node request to allocate the memory for.

It's not an Option anymore, so we may want to drop 'optionally'. Also please
leave an empty line here.

> +    /// Systems employing a Non Uniform Memory Access (NUMA) architecture contain
> +    /// collections of hardware resources including processors, memory, and I/O buses,
> +    /// that comprise what is commonly known as a NUMA node.
> +    /// `nid` stands for NUMA id, i. e. NUMA node identifier, which is a non-negative
> +    /// integer if a node needs to be specified, or NUMA_NO_NODE if the caller doesn't care.

Please also explain what happens when the NumaNode changes between calls to
realloc_node().

Does it have to remain the same NumaNode? Do we need a safety requirement for
that?

(Btw. no need to send a new version right away, leave a few days for people to
catch up and comment on this one or the other patches before resending.)

>      ///
>      /// If the requested size is zero, `realloc` behaves equivalent to `free`.
>      ///
> @@ -191,13 +246,29 @@ fn alloc(layout: Layout, flags: Flags) -> Result<NonNull<[u8]>, AllocError> {
>      ///   and old size, i.e. `ret_ptr[0..min(layout.size(), old_layout.size())] ==
>      ///   p[0..min(layout.size(), old_layout.size())]`.
>      /// - when the return value is `Err(AllocError)`, then `ptr` is still valid.
> -    unsafe fn realloc(
> +    unsafe fn realloc_node(
>          ptr: Option<NonNull<u8>>,
>          layout: Layout,
>          old_layout: Layout,
>          flags: Flags,
> +        nid: NumaNode,
>      ) -> Result<NonNull<[u8]>, AllocError>;


  reply	other threads:[~2025-06-28 12:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-28 10:23 [PATCH v8 0/4] support large align and nid in Rust allocators Vitaly Wool
2025-06-28 10:25 ` [PATCH v8 1/4] mm/vmalloc: allow to set node and align in vrealloc Vitaly Wool
2025-06-30 10:30   ` Uladzislau Rezki
2025-06-30 11:50     ` Vitaly Wool
2025-06-30 16:39       ` Uladzislau Rezki
2025-06-28 10:25 ` [PATCH v8 2/4] mm/slub: allow to set node and align in k[v]realloc Vitaly Wool
2025-06-28 10:26 ` [PATCH v8 3/4] rust: add support for NUMA ids in allocations Vitaly Wool
2025-06-28 12:21   ` Danilo Krummrich [this message]
2025-06-28 15:25     ` Vitaly Wool
2025-06-28 15:33       ` Danilo Krummrich
2025-06-28 10:26 ` [PATCH v8 4/4] rust: support large alignments " Vitaly Wool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aF_eLTlirxl-1jPP@pollux \
    --to=dakr@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=aliceryhl@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=urezki@gmail.com \
    --cc=vitaly.wool@konsulko.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox