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 A0891C83F0A for ; Tue, 8 Jul 2025 12:15:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A60B6B0318; Tue, 8 Jul 2025 08:15:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27DD56B0319; Tue, 8 Jul 2025 08:15:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BAD76B031A; Tue, 8 Jul 2025 08:15:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0D2396B0318 for ; Tue, 8 Jul 2025 08:15:55 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B5A0A1D976E for ; Tue, 8 Jul 2025 12:15:54 +0000 (UTC) X-FDA: 83640993828.25.3F49B1A Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf12.hostedemail.com (Postfix) with ESMTP id 1F5B64000F for ; Tue, 8 Jul 2025 12:15:52 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="mH1/bH1u"; spf=pass (imf12.hostedemail.com: domain of dakr@kernel.org designates 172.105.4.254 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=1751976953; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3hgql+OuHLqOY70rFpppoVC7tjGWvRX6QlJzlCpMSSs=; b=jmBa/vVf0O3JFLm1Di8BUA/PjyZzWe+XUNoa/q1T3dK1JydbH0tGwtTSvgqnoO/imcAsVD 0p9eaId1dg1awlMVRx5YkM5aiOx6q274QIHnIB8IvIrMDPd+q5ynXhAD2066Ado+aMTN4g 93Z9QY1zOFvNx9cZQ/WCQC/gaIWOrh0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="mH1/bH1u"; spf=pass (imf12.hostedemail.com: domain of dakr@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751976953; a=rsa-sha256; cv=none; b=YXSimwIkhoh+z2D2VDzle0iTJK4bbbAnWZUpq4yD3ucOBWG4UR6JhAtIimB6MCPXUi/GFY b/bq6g6a8wBuMLQsxFVk2ScYEyGJmw50Q6vLAlH1ceAMzmWIOGEuPqxnx3mZp2dnun0vN7 c/WK7lUII2Qlglz8KBQ3vEiRyQZXSaw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 869A761485; Tue, 8 Jul 2025 12:15:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4186C4CEED; Tue, 8 Jul 2025 12:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751976952; bh=m8jMT2BEQLMLsLrNG9jsh0N0UL2As4Pb8eDEvx4vGD4=; h=Date:Cc:To:From:Subject:References:In-Reply-To:From; b=mH1/bH1uyhkPjienjN6dRpgS3sSmH+GLONi2pBMMJlyv28uWczofciZYlufjnhLYN /YwzLBDZw/yhGPv21Zy0qk/GJQSYubbZBTD2LlhPv2GbPvLazPwCZnkV1h6khaYh4y sH4WmLYLG1kejyYNDQ62Wdg3Uu24UywXLtrgrKQU3m4oCNk8A2s+ffxgFuFJeI6+qD 8WvJ4jJEk7r5L5ZQNVzpMEYv8OV8kgz0ltCLslpT5rgAACskbdGT97JY6LddgHPuVI mlX6q2d4Fc45/ehgY6AJw2uar4aUrSabg0xU/s/g5PtZ+2Ya9QWv8zNhgdxm9NZlVn 3eY6y6/o7R7Qg== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 08 Jul 2025 14:15:49 +0200 Message-Id: Cc: , , , "Uladzislau Rezki" , "Alice Ryhl" , "Vlastimil Babka" , To: "Vitaly Wool" From: "Danilo Krummrich" Subject: Re: [PATCH v11 3/4] rust: add support for NUMA ids in allocations References: <20250707164755.631374-1-vitaly.wool@konsulko.se> <20250707164934.631500-1-vitaly.wool@konsulko.se> In-Reply-To: <20250707164934.631500-1-vitaly.wool@konsulko.se> X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1F5B64000F X-Rspam-User: X-Stat-Signature: x5wd8s7mxf64n9q4r8xr7s7qzx99cw8n X-HE-Tag: 1751976952-669221 X-HE-Meta: U2FsdGVkX183P6tym/LV8AR1VZ+qFAUAc87amgw1syMsGAn5UMjP9TGjsMXwITNbCr1ezudWKjmGUSeIIR7b9hW1bbxhqJmHtK0/B/kCbXmmvZmJAsWfkOV8ivuKCmXGSy9Rd3oFJWtznjhrMkhQPQ6ph4OapvaD2SDFYVcrpaJ/CLsCo2iSOKSGIfXFncD9EkFhA79wWkH9a4EPLR1f6GW1OJPoABjxg33n6bAhKyEfXT2wmsrWnUW+VTj3HQm/CotCCGQemH3yQ1Fs0B4Z/h2oLHPyhOP0voBrPS5SEV0JIk1FgcfMgeDRYULvVjNkCRbvHlskoF3o3I8NcJjNdMVPUAlYk/K2dRLnXOY4p2Qrfedx6DWXwIRQ2ekO8CuISCiQDr4AuhgqMvLJEW0l/4deE02GDS+sEo//BGSRf9B8qGmm8/rMZNrsyJXd9S+2PLXNuGTSWEqFbFMV1Xdp0y0RqOjoPdxnlGfMpEBr+YNaiyAmBeQ1aJ49OqcYCDEOh4lxvhK228Vzs6c89Dr0fhvs8NRKJXM/5AJdFLeOsNWH5b2C3APsy47o2AkiBQq2B655OdLZIt1neZWN3p5n/BhUB+MzR1xU5H2YWrV7/6+ddVTqTM9xqQYeLMatUUNbVEDEnHBSB0eE9g5UpJsae47ZCnbOhIlhKNFlyqqw7U/v/ObesQKhT4+Olt7YGQqAtaf2hxkenjh/sd4XW1djH02nHaGQ6NDm7DRkNRR/RHDh0x3zQKv7LdaT9rA6jXQmh4j+MNlWJTxNp5iSUNQLT/S7Btd/N6d8M7SWozVIQqYNQhad6TKqugv2fm3P4NzlfngrecaTWUlgZsHhYPP/pBmEiQeDoeHDGPoAatutK7xgzurAr4VVOyisvguaalE8xBPG/Thxabpcils+MX2raKeSe88RbKj5ojOIsD0/4HpMi0O5+I8i1Wr/8bAYTsphqA0p3Yryjl34PtQUY67 cslFOZAC WpGRyePY21HeqnuWfbGarRVMBDoGKjTxy31jL8CSTR6NxvLnBGOY9Y9kifyjnzzhYmgeLw2yC2HXvY9fbPPPqU7CcuYyLcU/et5AzOMzDRVuS7SzaIDMAZzNa1gWmizRF4lW8eGj6C5WNo9jrAYwzmCdznRxqmJ5WIxtNWGwZvP9AOKQGJSeo56FOXsZD4dqBSJ6Y7oCzhrT28JX9jiv9YSvpoU+lZsZQTgZfw4AzVKzvRW6BO5pLMaxq7rz0Yaxk2cWVaAH7fXZ6HjQTcSeOC5CGiN0Vb1+Jj6CevXG02Vh1QGbVd6VlrSbhWD3qmaXsj81Bcz0OT3HB8CpZpq6wU6mYsr25Pg6m0gSSyIxibRZEI5tMhwBAsPwepw== 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 Mon Jul 7, 2025 at 6:49 PM CEST, Vitaly Wool wrote: > +/// Specify necessary constant to pass the information to Allocator that= the caller doesn't care > +/// about the NUMA node to allocate memory from. > +impl NumaNode { > + /// No node preference Please end the comment with a period. > + pub const NO_NODE: NumaNode =3D NumaNode(bindings::NUMA_NO_NODE); > +} > + > /// The kernel's [`Allocator`] trait. > /// > /// An implementation of [`Allocator`] can allocate, re-allocate and fre= e memory buffers described > @@ -137,7 +162,7 @@ pub mod flags { > /// - Implementers must ensure that all trait functions abide by the gua= rantees documented in the > /// `# Guarantees` sections. > pub unsafe trait Allocator { > - /// Allocate memory based on `layout` and `flags`. > + /// 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 `la= yout`). > @@ -153,13 +178,21 @@ pub unsafe trait Allocator { > /// > /// Additionally, `Flags` are honored as documented in > /// . > - fn alloc(layout: Layout, flags: Flags) -> Result, Allo= cError> { > + fn alloc(layout: Layout, flags: Flags, nid: NumaNode) -> Result, AllocError> { > // SAFETY: Passing `None` to `realloc` is valid by its safety re= quirements and asks for a > // new memory allocation. > - unsafe { Self::realloc(None, layout, Layout::new::<()>(), flags)= } > + unsafe { Self::realloc(None, layout, Layout::new::<()>(), flags,= nid) } > } > =20 > - /// Re-allocate an existing memory allocation to satisfy the request= ed `layout`. > + /// Re-allocate an existing memory allocation to satisfy the request= ed `layout` and > + /// a specific NUMA node request to allocate the memory for. > + /// > + /// Systems employing a Non Uniform Memory Access (NUMA) architectur= e 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 s/i. e./i.e./ > + /// integer if a node needs to be specified, or NO_NODE if the calle= r doesn't care. s/NO_NODE/[`NumaNode::NO_NODE`]/ > /// > /// If the requested size is zero, `realloc` behaves equivalent to `= free`. > /// > @@ -196,6 +229,7 @@ unsafe fn realloc( > @@ -58,18 +58,23 @@ fn aligned_size(new_layout: Layout) -> usize { > /// > /// One of the following: `krealloc`, `vrealloc`, `kvrealloc`. You have to adjust those as well, given that you refer to this invariant be= low. > struct ReallocFunc( > - unsafe extern "C" fn(*const crate::ffi::c_void, usize, u32) -> *mut = crate::ffi::c_void, > + unsafe extern "C" fn( > + *const crate::ffi::c_void, > + usize, > + u32, > + crate::ffi::c_int, > + ) -> *mut crate::ffi::c_void, > ); > =20 > impl ReallocFunc { > - // INVARIANT: `krealloc` satisfies the type invariants. > - const KREALLOC: Self =3D Self(bindings::krealloc); > + // INVARIANT: `krealloc_node` satisfies the type invariants. > + const KREALLOC: Self =3D Self(bindings::krealloc_node); > =20 > - // INVARIANT: `vrealloc` satisfies the type invariants. > - const VREALLOC: Self =3D Self(bindings::vrealloc); > + // INVARIANT: `vrealloc_node` satisfies the type invariants. > + const VREALLOC: Self =3D Self(bindings::vrealloc_node); > =20 > - // INVARIANT: `kvrealloc` satisfies the type invariants. > - const KVREALLOC: Self =3D Self(bindings::kvrealloc); > + // INVARIANT: `kvrealloc_node` satisfies the type invariants. > + const KVREALLOC: Self =3D Self(bindings::kvrealloc_node);