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 42765C7EE32 for ; Sat, 28 Jun 2025 12:21:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B34996B0099; Sat, 28 Jun 2025 08:21:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE5266B009A; Sat, 28 Jun 2025 08:21:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D4566B009B; Sat, 28 Jun 2025 08:21:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 86EEF6B0099 for ; Sat, 28 Jun 2025 08:21:08 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 389D21D7401 for ; Sat, 28 Jun 2025 12:21:08 +0000 (UTC) X-FDA: 83604719016.25.D172587 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf29.hostedemail.com (Postfix) with ESMTP id A8A69120005 for ; Sat, 28 Jun 2025 12:21:06 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=j2FN0Yrl; spf=pass (imf29.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=1751113266; 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=YRDMLs7sCBpDI17qY0KWMDzNbeX6s6YluVOGBUMbssE=; b=WrPgYjQHpJOmPplYAEH1OjWACS5QcASjD+SgHmw5fGmHz/5v3jKDNw5oDzge92KF3c3NMi aDW0Qi6Jj4BQg2KwQ7eISP522burDk1KVl0PyuryrAPambEvIzCgC+9BXZRd1V+8j33ZsE NoQpH/JSa/cdMNLDhCyIPvrIjNMh7u0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=j2FN0Yrl; spf=pass (imf29.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=1751113266; a=rsa-sha256; cv=none; b=x23DUcaxSTgpfbbabfphV6OuSRVdo7gDUaUOu+SeG3PhOdYq9tM341ts/sl6q+q0sgOctJ 523Ijs4Wv2h3Yz8ZhY530E2OAaVWBqRlOWLrsnmjhSsnyROJ9yFiu6AQCgJ9dyGWUW9X7S yAoJKwhfWTHtHGCMpjNwNGHc413gzV8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id AEAAF60052; Sat, 28 Jun 2025 12:21:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C89F1C4CEEA; Sat, 28 Jun 2025 12:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751113265; bh=0PMfZgVrVOhGJzluE63L4B+hXTDSgAsn2owIh7LlYxc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=j2FN0YrlWAytnO47v/Wig6KgbAnFZBd2spjfO84QK+78w05me/rXOETn9GWD7X4Uj yoN/R32FkflU77pPuLlvjBGoPTfFu8tylqbGNqxegg7OuqXqjwPMD8uCy1YEYJa+ge C+83c7r7OupaxW4/rouaOzkLsJ8xGROAvD/MOXNXCYt1K2Uiq3ec/CWZoZQ9RcYPee e8iB27VxqzgfkLn8D3ZthXrQyoZ6vGVMqEJJKyNue/I7dCURKZEFmc3X1y3brjd95Y /A2ufsq8CXAOrHFQikdS42ITHwwqU/qtd/kVqxs3YLD4jA5k94G+a+3gvhp5ZgeX8r X/m7XeQNFj/FQ== Date: Sat, 28 Jun 2025 14:21:01 +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 v8 3/4] rust: add support for NUMA ids in allocations Message-ID: References: <20250628102315.2542656-1-vitaly.wool@konsulko.se> <20250628102611.2542910-1-vitaly.wool@konsulko.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250628102611.2542910-1-vitaly.wool@konsulko.se> X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A8A69120005 X-Stat-Signature: uo8efqcyymhep4r5ac7qehjp75fioe9c X-Rspam-User: X-HE-Tag: 1751113266-238265 X-HE-Meta: U2FsdGVkX1+DF5K5B5RF1p7+T/OBWcvJFN3SgrAPDX5oQEzaLlXpeHauENydCWN6H/LjZHsuytYXbXYgDDF75RUQ9Dy9F4K+ho1XuMZ5NdEXj5u/q5uhI/CTT0HBHSFM6OQgCJUNo/nZyb/1+jE9TQ/hGQuKwqH3/cZaXph1yLxcuhC+3M4uXWAr73p3tv/stDfOFPad54Z4bncFgloiJLBHS5/7VU/8lh0PdRbPzCKSFR18PJdieMb4vNiQ8B/SsdV+E/W7nk1PQaoz7fgndNzh/+mySEIYzcWdIICXCT2cSYcchqvt3Hofn4LMV0rp8fajkfTRLJ3jH/TVN/ne2J9CBghIfoIGAVSUm8MbV9YvVRpfAZ4/N6MgVtESZgo1ccHuODAHPvGwOynxXyXf5crme3JPOtYcgOolHX0Om7Ds2Y3KXwtis+pU88KSaPJpXoYaR9Y7RIC/q6GvWT7Kx7Iyj+QTk3Wf5YuEmCfFcwBqZdRbLO540D7Sfib36SVK2NC7jVvDgSx/o8cYwyCYAgI9Z0Mb4fBbX4cr4tKUp2Kdk7qzQQZydPm3Qn7Ay7BErLTMQh2/B5Gc6GSjvl3qrhXEngybZtEpSkTcdZPU8MPFMcSAOlVyCPKMk9GV/HGOvKYaYTov+yrc2MtuRj9E0ml0N8vDSQsa4YmNBau3gzoaBeACD58EI1ALNjedEbgkNnaWiPvSpgkapOIhy7V/bgHIdIYRjd8I6dc+QARR6nTFmndkv8DWfUSJck7m/sEImqHf8Qftic2/z1j5caJxUQpB+PrWaVUD1q/HkZcg6WyBv9ggS9u112/qoz5MtxpDRCwvforOCJjsracSIDifP4JCdOofCCDSgs7GNCsgRjwAtEpekHa6jGa21upcOZn89RV1bBKSIX3HZwy6X49yAcGNAgVY0zPYMnIhMoKR20e+rTZer4eBBQmDJzmWxId5Cwj6D4GhzwfxBsELT2P +mC/kg+x NQMrhjArH0gIvAmKouBz8glRUWoxSgGbioUHDT6QaT9riOYsrnbwzIFi0j8hRRcyrmeSICHOYPDNLg+BNSGk98cdE8oN3SyOsKD5X6L9kIPXYq4/07vGpMxenFqTDWm2dmdyN9T52ryTarYR6oRWg9SGiOa0cMpkPKNVhEJS7TmUbtX2RbiWuna9rlkNMZ4YaucIyg3OekMJMhilx0lA/7iL7NtL+GiM6Vm/LoM3StGd/L92wWq4i6r6+gw== 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 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 { > + if node < 0 { > + return Err(EINVAL); > + } Should we also check for MAX_NUMNODES? > + Ok(Self(node)) > + } > +} > + /// 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, 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>, > layout: Layout, > old_layout: Layout, > flags: Flags, > + nid: NumaNode, > ) -> Result, AllocError>;