From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2430C7EE30 for ; Thu, 26 Jun 2025 12:40:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6923F6B009B; Thu, 26 Jun 2025 08:40:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 669F26B009C; Thu, 26 Jun 2025 08:40:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 580706B009D; Thu, 26 Jun 2025 08:40:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 47E7E6B009B for ; Thu, 26 Jun 2025 08:40:30 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BC840120338 for ; Thu, 26 Jun 2025 12:40:29 +0000 (UTC) X-FDA: 83597510178.27.3832645 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf20.hostedemail.com (Postfix) with ESMTP id 1979A1C0002 for ; Thu, 26 Jun 2025 12:40:27 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Iov/UuMO"; spf=pass (imf20.hostedemail.com: domain of dakr@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750941628; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+/2mvwSMXFJeR93igPOPx9LPj47gaB5Qn5F5dI0DQLc=; b=vXr+SandFVmb0j6VFE9iibg1x89UW/VVWRTyPUDmQ2tNAE7w0JBUDYo9PuUR+tjgROA8eE HIyP2H7iVYxh9lWIHQR9r5Y/ET7YSw+h0qIT6lprTddzuhauLEhlLSpkUqp+AJKXYxqCIF QaMA+FbEIjzDbKiY9XGvlMilmSN+WG8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750941628; a=rsa-sha256; cv=none; b=ftWLeBl7FSVFeauKEeDnSegoxuJ1nSGcYZIhOAgBcxl4wgb2w1JAjKa7V5RVqbLTRje3ye 8FfCmTMe3fEN1wd8geOGqAnZsfc1Qbd/A+2AwmK6cxbVCPsdz4jJD+ke00Tb1N6j7uCUPn o5INDzE7C/MhBLynOI6GcTtcMFOTsmE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Iov/UuMO"; spf=pass (imf20.hostedemail.com: domain of dakr@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 4E984A51514; Thu, 26 Jun 2025 12:40:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75679C4CEEB; Thu, 26 Jun 2025 12:40:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750941627; bh=tjTOGPjzJnUG43hJmlfmYnj58c2q6lIlyqKtZ0yQ1RQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Iov/UuMO5gwHm/ahFOfhswkjoJiwTLF0guIiN2DoAeTvTTAIlPiojVkwzlTXYx4vQ n7c8xYy3Z5Z+WmYxcQYKD/CcUCgKC4RyMNGrtiHhPg1GVdP0R2qx5q5piZ9+1+qhB/ 5Fw8JdyvakCmqTI6tlvzPkXosO6zUtrOV4g5i02mNj0otQZVZsdK7cXoeYIRheVvQL HVC9ElJWilf+okF+PTPkAYE+OD7hSTg1awFFPF6+oU6+LRcX1xBq2rZ+fmdVt2Sl1j 9BlyLKSsrs0preOaFymh8sfhsdkm6/G0jEkq9jLK62L+9gohRBt1MC9tcMClAIDvMv TVoI95NoeUElg== Date: Thu, 26 Jun 2025 14:40:22 +0200 From: Danilo Krummrich To: Vitaly Wool Cc: linux-mm@kvack.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Uladzislau Rezki , Alice Ryhl , rust-for-linux@vger.kernel.org Subject: Re: [PATCH v4 4/4] rust: support NUMA ids in allocations Message-ID: References: <20250626083516.3596197-1-vitaly.wool@konsulko.se> <20250626083653.3596424-1-vitaly.wool@konsulko.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250626083653.3596424-1-vitaly.wool@konsulko.se> X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1979A1C0002 X-Stat-Signature: ij3sq7yaz9nru87c3irajbugoxrxtd18 X-Rspam-User: X-HE-Tag: 1750941627-626051 X-HE-Meta: U2FsdGVkX18ldOhp6+yniglMEHKv/os1DMY9VxpEvbT+SYF6I3DVculgfplqqhWJ2eXBt4Li3mKnVVx+w1ggNDKLOtGyTkaj+qZ5P7w3971c+FXuI51QQqUZcb5lVfVEZjrYt033KVq6ZksCaLxHm+D3oiPh2xfIBzIMyagcJUQ/KDTdXvU0C9Udk9MHX4P17NXHVlF9eCLHC1rG4eXc/5y0agkN7iGj1YxIxuBRclRkzldv5NwDBdv76NMqsnqh028feiVq8HdPLeB9IyXPDDGOnWP3OF8P4T1sLAvFGsEeyYU6DNBIBhwXudagTqm8c3DaAWoZtLR0hEhcV0jy98cIHcjjtTxvPrGYpok6Wo0c20GqpfKb9y+88ReJT0XCsUsG/u0pXmgS5rtF37BAzwXbdbuQYJmhWAQ8DtHykNSiEspOI6X4p3fXvKhHVAVMHaJkLm7azLlnf0rK1tFkZa726iFelBt8Jnzitfs9dtunR9KUgYZ65X1H2RFbRlo1wN7E0s4pDjSjLEg0zs4Yo/dsk2bznBAulk6YvNxgUBx3aUz17sHvNP9IvcGjBtkc1SMNZ9yOuD/Ybe26Dny9e4k8Bz1rEluhRyiZyTqoL+gyCv81Ctq4cTnRalNUHXGro/GIv6b+5gvAdRl4IaF7QZoFo9q3ji6b9hO26jXifHPA9QC1UpTVKacOZJtlu//F+v8r36XfJWF402L0PhBQN5sU4Hrbv8wzoHIf9y7j8Pp/Wx9yT+Ho9LCINQ1sfQXYqaouAp9lyF5JOumdlWaaMJimoVN+qgCMJVuaxXntcBSNE2+/4ySN+OCTxdEyLirOCttTNWuGE1LyyorI4djJJW0mLJOiqt/yxWsSfAVoVjvWH99CFwJoN5vBrviHNxNcX7Vzwh1/RWwHGFCu3T2dflKOt/neNpH9thYlWVAuwaAyUUR+Zej2FnpJun0ajeRG/3ue/W5JL1H+Y0/5fXY LffaobcK 7fccQY5SopWalUFHXSC8ww4KvyAqq9EBe2kymyhmEkhLRlWX0mwoWeyPSEao9M92hwtQuzsGAYGVF2kFNR28vzQtEtb3O+RFE9YOx+PY+up6qr8qaLhMhbTT3yixUcHhV6cBzewJfjt1bXVk2FERzqTCmX6ji+ZYhf4OhH4rXK0PS3KhPawiHs0o96RvUiLS7XON0Zm5XK5JkJG9TKNxkL0LWlaYM9qzgZ9b/7GGNpHBgcHnVToncjwOFOt8vnM1eF0OivKy/2DjvLVN5GfaWFeNiix13u39+AF1lD87mi9fLF5k= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Jun 26, 2025 at 10:36:53AM +0200, Vitaly Wool wrote: > Add support for specifying NUMA ids in Rust allocators as an Option > (i. e. providing `None` as nid corresponds to NUMA_NO_NODE). This > will allow to specify node to use for allocation of e. g. {KV}Box. > > Signed-off-by: Vitaly Wool > --- > rust/helpers/slab.c | 9 +++++---- > rust/helpers/vmalloc.c | 4 ++-- > rust/kernel/alloc.rs | 28 ++++++++++++++++++++++++++-- > rust/kernel/alloc/allocator.rs | 26 ++++++++++++++++++-------- > rust/kernel/alloc/kvec.rs | 3 ++- > 5 files changed, 53 insertions(+), 17 deletions(-) > > diff --git a/rust/helpers/slab.c b/rust/helpers/slab.c > index 5e9e8dd2bba0..ab1cf72f8353 100644 > --- a/rust/helpers/slab.c > +++ b/rust/helpers/slab.c > @@ -3,13 +3,14 @@ > #include > > void * __must_check __realloc_size(2) > -rust_helper_krealloc(const void *objp, size_t new_size, unsigned long align, gfp_t flags) > +rust_helper_krealloc_node(const void *objp, size_t new_size, unsigned long align, gfp_t flags, > + int nid) > { > - return krealloc(objp, new_size, flags); > + return krealloc_node(objp, new_size, flags, nid); > } > > void * __must_check __realloc_size(2) > -rust_helper_kvrealloc(const void *p, size_t size, unsigned long align, gfp_t flags) > +rust_helper_kvrealloc_node(const void *p, size_t size, unsigned long align, gfp_t flags, int nid) > { > - return kvrealloc(p, size, flags); > + return kvrealloc_node(p, size, flags, nid); > } Same as in the previous patch, please keep those as "normal" helpers for *realloc_node() and create the corresponding *realloc_node_align() helpers discarding the argument on the Rust side. > diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs > index a2c49e5494d3..1e26c2a7f47c 100644 > --- a/rust/kernel/alloc.rs > +++ b/rust/kernel/alloc.rs > @@ -156,7 +156,30 @@ pub unsafe trait Allocator { > fn alloc(layout: Layout, flags: Flags) -> Result, AllocError> { > // SAFETY: Passing `None` to `realloc` is valid by its safety requirements and asks for a > // new memory allocation. > - unsafe { Self::realloc(None, layout, Layout::new::<()>(), flags) } > + unsafe { Self::realloc(None, layout, Layout::new::<()>(), flags, None) } > + } > + > + /// Allocate memory based on `layout`, `flags` and `nid`. > + /// > + /// On success, returns a buffer represented as `NonNull<[u8]>` that satisfies the layout > + /// constraints (i.e. minimum size and alignment as specified by `layout`). > + /// > + /// This function is equivalent to `realloc` when called with `None`. > + /// > + /// # Guarantees > + /// > + /// When the return value is `Ok(ptr)`, then `ptr` is > + /// - valid for reads and writes for `layout.size()` bytes, until it is passed to > + /// [`Allocator::free`] or [`Allocator::realloc`], > + /// - aligned to `layout.align()`, > + /// > + /// Additionally, `Flags` are honored as documented in > + /// . > + fn alloc_node(layout: Layout, flags: Flags, nid: Option) > + -> Result, AllocError> { > + // SAFETY: Passing `None` to `realloc` is valid by its safety requirements and asks for a > + // new memory allocation. > + unsafe { Self::realloc(None, layout, Layout::new::<()>(), flags, nid) } > } > > /// Re-allocate an existing memory allocation to satisfy the requested `layout`. > @@ -196,6 +219,7 @@ unsafe fn realloc( > layout: Layout, > old_layout: Layout, > flags: Flags, > + nid: Option, > ) -> Result, AllocError>; I think you did forget to add realloc_node() as requested in the last iteration.