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 51A2FC54ED1 for ; Sat, 28 Jun 2025 15:26:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75F386B009A; Sat, 28 Jun 2025 11:26:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 710636B009B; Sat, 28 Jun 2025 11:26:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64DA46B009C; Sat, 28 Jun 2025 11:26:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 540066B009A for ; Sat, 28 Jun 2025 11:26:09 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D862C140516 for ; Sat, 28 Jun 2025 15:26:08 +0000 (UTC) X-FDA: 83605185216.16.8B8BFC2 Received: from mailrelay4-3.pub.mailoutpod3-cph3.one.com (mailrelay4-3.pub.mailoutpod3-cph3.one.com [46.30.212.3]) by imf14.hostedemail.com (Postfix) with ESMTP id 5A20710000B for ; Sat, 28 Jun 2025 15:26:06 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=konsulko.se header.s=rsa1 header.b=jzj1RZKk; dkim=pass header.d=konsulko.se header.s=ed1 header.b=OmpYaJ+y ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751124367; a=rsa-sha256; cv=none; b=vjEG349wF80unqzbPnBVFegBuSV/YTM9mW0FlRyZ+xAGQzOaoO5hLDnc4JKeeyA/TxJcIr xjm+8K2zludZyOzPAlnou5hQxgZV5XrTEyvbk3W3/di81oL1txHXzQ14ReGsNF2F4t3e5t AN8EQdC/5r27O+uPCiSmYxPtuGFxgBs= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=konsulko.se header.s=rsa1 header.b=jzj1RZKk; dkim=pass header.d=konsulko.se header.s=ed1 header.b=OmpYaJ+y; dmarc=none; spf=none (imf14.hostedemail.com: domain of vitaly.wool@konsulko.se has no SPF policy when checking 46.30.212.3) smtp.mailfrom=vitaly.wool@konsulko.se ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751124367; 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=BOIeB1Vb/vFEPkAxZTIsJPYgb2yRlv4ViGfG7pUkR5Q=; b=50T7zM8I9pOLgWK0BNgT8txaYhf2u4UnmWIyGsCiTA11uWBwI7M1WX3BeHwht5W4NLqTAr usR4NLes9CtQjoPYXnvS2/9Srf0td83AGdGsoDGBs08mjEmQW43uiroaLJLYNPmFuzvNtn mCKd3tqtAbU08hUMK9gf/qFfZ5FtWFg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1751124364; x=1751729164; d=konsulko.se; s=rsa1; h=to:references:message-id:content-transfer-encoding:cc:date:in-reply-to:from: subject:mime-version:content-type:from; bh=BOIeB1Vb/vFEPkAxZTIsJPYgb2yRlv4ViGfG7pUkR5Q=; b=jzj1RZKkozDCKaPDZKl2tY3NEVhZ5/5+gJY6UuOo7KCRvZPaOp5cMvvcNeXMnhNx/LyNWnsA4HQzP CHGt5J1WQd/TYM7s0YypOyrv0d8zfH1BE1RWvKAwq8O9y4tKDL5F9st5iR6IjUj82z6BQtV7NEvedO qemC51DxRaFd3M64TE/HUDX5PBaPbOWaJj+SA84VH5w4JAyrwhadcAYNkvm7xUjOQWg8vmq+2Hio3c NnApClLRMPNMEYOAjLSAy3MG4RsVX02yHVEWE8xIZ0BRIF0qd9q7FlLJKqvHhsj3qfjDMCRokcr7O/ NIgsCcXYBD5WfhctoYFOduUnIc3ApFQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1751124364; x=1751729164; d=konsulko.se; s=ed1; h=to:references:message-id:content-transfer-encoding:cc:date:in-reply-to:from: subject:mime-version:content-type:from; bh=BOIeB1Vb/vFEPkAxZTIsJPYgb2yRlv4ViGfG7pUkR5Q=; b=OmpYaJ+yiuelLE7861I59SxCB2SAJmAhnBMXUcSkE86lwdd2flmb8fHBnQtIcPziG463g7Ne/0/PM QB47pBlDw== X-HalOne-ID: 3315bb22-5434-11f0-8a91-29b2d794c87d Received: from smtpclient.apple (host-90-233-200-0.mobileonline.telia.com [90.233.200.0]) by mailrelay4.pub.mailoutpod3-cph3.one.com (Halon) with ESMTPSA id 3315bb22-5434-11f0-8a91-29b2d794c87d; Sat, 28 Jun 2025 15:26:03 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.200.121\)) Subject: Re: [PATCH v8 3/4] rust: add support for NUMA ids in allocations From: Vitaly Wool In-Reply-To: Date: Sat, 28 Jun 2025 17:25:52 +0200 Cc: linux-mm@kvack.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Uladzislau Rezki , Alice Ryhl , rust-for-linux@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <61DAD282-B00A-4809-B579-3F47F4781BBC@konsulko.se> References: <20250628102315.2542656-1-vitaly.wool@konsulko.se> <20250628102611.2542910-1-vitaly.wool@konsulko.se> To: Danilo Krummrich X-Mailer: Apple Mail (2.3826.200.121) X-Stat-Signature: 5b9a8e8d884hwqmszfc6qt7hjqc597wn X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5A20710000B X-Rspam-User: X-HE-Tag: 1751124366-326806 X-HE-Meta: U2FsdGVkX1/V4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VdRvmpkWnkezFx+0eUYxuZlaoyVfmtDzpVwRh7mvOsYcN9nR8W5tVFVIMmEcKN6BuCqsCH43ZRfbeSM1rZxQPYlVtK7uDSbw925JPWWswneoF7A1+4MJZGdo7aKbigoA== 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 Jun 28, 2025, at 2:21=E2=80=AFPM, Danilo Krummrich = wrote: >=20 > 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); >> + } >=20 > Should we also check for MAX_NUMNODES? Good point, thanks. >=20 >> + Ok(Self(node)) >> + } >> +} >=20 > >=20 >> + /// Re-allocate an existing memory allocation to satisfy the = requested `layout` and >> + /// optionally a specific NUMA node request to allocate the = memory for. >=20 > It's not an Option anymore, so we may want to drop 'optionally'. Also = please > leave an empty line here. >=20 >> + /// 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. >=20 > Please also explain what happens when the NumaNode changes between = calls to > realloc_node(). >=20 > Does it have to remain the same NumaNode? Do we need a safety = requirement for > that? Since we don=E2=80=99t implement that logic, we trust the C part. The = current implementation will refuse to realloc for a different node, and = I believe that is the right thing to do because transferring an = allocation to a different node doesn=E2=80=99t go well with the concept = of simple adjustment of the allocation size. Do you believe it is necessary to explicitly state it here in the = comments? =