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 0FFAAC83F17 for ; Thu, 10 Jul 2025 14:07:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A88466B0092; Thu, 10 Jul 2025 10:07:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5FCB6B0093; Thu, 10 Jul 2025 10:07:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9760D6B0095; Thu, 10 Jul 2025 10:07:35 -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 8B44D6B0092 for ; Thu, 10 Jul 2025 10:07:35 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3E87D160131 for ; Thu, 10 Jul 2025 14:07:35 +0000 (UTC) X-FDA: 83648532870.13.5AE0247 Received: from mailrelay-egress16.pub.mailoutpod3-cph3.one.com (mailrelay-egress16.pub.mailoutpod3-cph3.one.com [46.30.212.3]) by imf09.hostedemail.com (Postfix) with ESMTP id C3EA414000C for ; Thu, 10 Jul 2025 14:07:32 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=konsulko.se header.s=rsa1 header.b=VHpubo+O; dkim=pass header.d=konsulko.se header.s=ed1 header.b=71llo6v6 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752156453; 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=z6CYkY/mnHsPc1zlAI1YQ9WMPDSlzYrFWMeZlYj4cpw=; b=JK22NawLDJxVnp9O2dGg/xouXJGchnksuOhhZndliwqL3ErHKVISk51s4GlhacXVrLtgTe Knuz+n9mHVeDz+JWXgwiqEew3bcFvdS6O6OBqsXDqlNQ4QReMxiBUumlrLfnmMdU9nS/T3 Y7PA7Su5rkXHTl7TxbcDFlJ8DxAV5z0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752156453; a=rsa-sha256; cv=none; b=LuCv7KuuOjBXZwi/HIsPzZgIEGZ4/eMHd1BIpzL4i19qxLagW7ARnO3zghjIbBrdUEahmJ i9xbxOpTbb/RtPRXcHZhzDhtyLAknqv9MQ57lH/s0NnR7nnKa1D8f0R0qkeCQoQlQdwJSO HVKdrHDxBJdipWEx2BfbR+rKVOe37qs= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=konsulko.se header.s=rsa1 header.b=VHpubo+O; dkim=pass header.d=konsulko.se header.s=ed1 header.b=71llo6v6; dmarc=none; spf=none (imf09.hostedemail.com: domain of vitaly.wool@konsulko.se has no SPF policy when checking 46.30.212.3) smtp.mailfrom=vitaly.wool@konsulko.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1752156450; x=1752761250; 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=z6CYkY/mnHsPc1zlAI1YQ9WMPDSlzYrFWMeZlYj4cpw=; b=VHpubo+OBZhzjd4PXBL2vtOFLMM2bRHh5EeEz+IBCjXyVL4Ukh6jyp1csiboGxXQ1tLHFoINMJ5C4 1ctcoTuCpgQyNoAT2oGWAp0T0NmCmxu63oSdgyLLwlpIjYGksuqtkH5l39quLXxeJSQOPmZ8U4wiAE /hNmU9nqubJ0lOMKO6+bRyz+c9m0eXYUBliSymIBdoTt4jyKXhqNh75iley3u6crCOjr+Sxk4ex/4c g97BlnCT9qmhal31kJyh9KRJvuigslwTrELthNmRmAmMLWHIAWkJPj69oMzx/eRYQJJ65LtLzrGnrY r+ABRS9dN1OjMes5PM4HJ3WcgJdb/Mw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1752156450; x=1752761250; 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=z6CYkY/mnHsPc1zlAI1YQ9WMPDSlzYrFWMeZlYj4cpw=; b=71llo6v6/l7OTXw3SNLSRYkfbg1Wmiisu+BttGsr8RLc6NHuwz5OHPiG6WSlNgNzzVcW0wzjID+ca FxpPsbOAg== X-HalOne-ID: 363fb403-5d97-11f0-9d28-c9fa7b04d629 Received: from smtpclient.apple (c188-150-224-8.bredband.tele2.se [188.150.224.8]) by mailrelay1.pub.mailoutpod3-cph3.one.com (Halon) with ESMTPSA id 363fb403-5d97-11f0-9d28-c9fa7b04d629; Thu, 10 Jul 2025 14:07:30 +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 v12 1/4] mm/vmalloc: allow to set node and align in vrealloc From: Vitaly Wool In-Reply-To: Date: Thu, 10 Jul 2025 16:07:19 +0200 Cc: linux-mm@kvack.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Uladzislau Rezki , Danilo Krummrich , Alice Ryhl , Vlastimil Babka , rust-for-linux@vger.kernel.org, Lorenzo Stoakes , Kent Overstreet , linux-bcachefs@vger.kernel.org, bpf@vger.kernel.org, Herbert Xu , Jann Horn , Pedro Falcato Content-Transfer-Encoding: quoted-printable Message-Id: References: <20250709172345.1031907-1-vitaly.wool@konsulko.se> <20250709172416.1031970-1-vitaly.wool@konsulko.se> To: "Liam R. Howlett" X-Mailer: Apple Mail (2.3826.200.121) X-Rspam-User: X-Rspamd-Queue-Id: C3EA414000C X-Rspamd-Server: rspam03 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Niop6lyyWox6aCrposrlut9pmuKMZwSxOVvFVNrRZZ4rGk8AC6meDVN+F7a0UMAWb9OwFo9LhFgbWB4QwEuSiHAkCJmxZdkePnyUezCIk7Vpd4fU7YGALBDsPOiPXJ+pbX0XVpuM+wxfnmwFR+P02tBaJrabka1hJ4RBXQewP7OGsktBQooZoZgHAheJCf2cEhf0ogifkhHcPumP4XUCtMDrLKDJRxVRHfSVW7wEOSVxc= 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 Jul 9, 2025, at 9:01=E2=80=AFPM, Liam R. Howlett = wrote: >=20 > * Vitaly Wool [250709 13:24]: >> Reimplement vrealloc() to be able to set node and alignment should >> a user need to do so. Rename the function to vrealloc_node_align() >> to better match what it actually does now and introduce macros for >> vrealloc() and friends for backward compatibility. >>=20 >> With that change we also provide the ability for the Rust part of >> the kernel to set node and alignment in its allocations. >>=20 >> Signed-off-by: Vitaly Wool >> Reviewed-by: Uladzislau Rezki (Sony) >> Reviewed-by: Vlastimil Babka >> --- >> include/linux/vmalloc.h | 12 +++++++++--- >> mm/nommu.c | 3 ++- >> mm/vmalloc.c | 31 ++++++++++++++++++++++++++----- >> 3 files changed, 37 insertions(+), 9 deletions(-) >>=20 > ... >=20 >> diff --git a/mm/vmalloc.c b/mm/vmalloc.c >> index 6dbcdceecae1..03dd06097b25 100644 >> --- a/mm/vmalloc.c >> +++ b/mm/vmalloc.c >> @@ -4089,19 +4089,31 @@ void *vzalloc_node_noprof(unsigned long size, = int node) >> EXPORT_SYMBOL(vzalloc_node_noprof); >>=20 >> /** >> - * vrealloc - reallocate virtually contiguous memory; contents = remain unchanged >> + * vrealloc_node_align_noprof - reallocate virtually contiguous = memory; contents >> + * remain unchanged >> * @p: object to reallocate memory for >> * @size: the size to reallocate >> + * @align: requested alignment >> * @flags: the flags for the page level allocator >> + * @nid: node number of the target node >> + * >> + * If @p is %NULL, vrealloc_XXX() behaves exactly like vmalloc(). If = @size is >> + * 0 and @p is not a %NULL pointer, the object pointed to is freed. >> * >> - * If @p is %NULL, vrealloc() behaves exactly like vmalloc(). If = @size is 0 and >> - * @p is not a %NULL pointer, the object pointed to is freed. >> + * if @nid is not NUMA_NO_NODE, this function will try to allocate = memory on >> + * the given node. If reallocation is not necessary (e. g. the new = size is less >> + * than the current allocated size), the current allocation will be = preserved >> + * unless __GFP_THISNODE is set. In the latter case a new allocation = on the >> + * requested node will be attempted. >=20 > I am having a very hard time understanding what you mean here. What = is > the latter case? >=20 > If @nis is !NUMA_NO_NODE, the allocation will be attempted on the = given > node. Then things sort of get confusing. What is the latter case? The latter case is __GFP_THISNODE present in flags. That=E2=80=99s the = latest if-clause in this paragraph. >=20 >> * >> * If __GFP_ZERO logic is requested, callers must ensure that, = starting with the >> * initial memory allocation, every subsequent call to this API for = the same >> * memory allocation is flagged with __GFP_ZERO. Otherwise, it is = possible that >> * __GFP_ZERO is not fully honored by this API. >> * >> + * If the requested alignment is bigger than the one the *existing* = allocation >> + * has, this function will fail. >> + * >=20 > It might be better to say something like: > Requesting an alignment that is bigger than the alignment of the > *existing* allocation will fail. >=20 The whole function description in fact consists of several if-clauses = (some of which are nested) so I am just following the pattern here. ~Vitaly