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 9931CC77B7C for ; Wed, 25 Jun 2025 19:07:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 285516B0096; Wed, 25 Jun 2025 15:07:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2364E6B0098; Wed, 25 Jun 2025 15:07:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14BC06B0099; Wed, 25 Jun 2025 15:07:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 074576B0096 for ; Wed, 25 Jun 2025 15:07:47 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4FE1E1D745F for ; Wed, 25 Jun 2025 19:07:46 +0000 (UTC) X-FDA: 83594857332.30.0FCBE31 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf28.hostedemail.com (Postfix) with ESMTP id 88802C000D for ; Wed, 25 Jun 2025 19:07:44 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tnLTQT9X; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of dakr@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=dakr@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750878464; a=rsa-sha256; cv=none; b=zaj25P6JHbYwfn4lRmJDumzQo95syMOTauAcZWiNqZoTNGH6TFqmFY8wmsNDplVHioYfmo MEb2M74EVf9oJ/U5CyKcy7iAQYAZuPP6xyr+HEstpXezhyW+ojfEKLsK8H17c5ZCcjjgaj nGuahA0nGHfEwPuYMA2k0HSptsVFgOA= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tnLTQT9X; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of dakr@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=dakr@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750878464; 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=She/bBDFimA0HLnYGzEQGo03O5fcMuj8r7+Our2/+Rg=; b=OjKRrsh/Mo8Ulftk1HCbQWWA4NucdhJkBzHdCA1iAXxGUmhxAvFMjcc4q9PNbEZMwaAsul l3PshDLgmPbPkLCsUfF8Y0uu6XjQ3t6y1WRAqgviDaMxUjVWvCHv5AY2WsxocbadRqwhdn 8wPvH8EcdZPIInAsPuNVs/2Gzh+67hE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 3BFB84A4A1; Wed, 25 Jun 2025 19:07:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7745CC4CEEA; Wed, 25 Jun 2025 19:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750878463; bh=NTjjLVl+LeSllJP6R1f53QYe43vLG0TwGoSH4vgeBpU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tnLTQT9XyDCKDpGmH6TieOM5dQPInWDIgXpXHByydzTLNwqm1C3EX9AMWa5DjAuxW y/wnjIYacb/tCgGLuXP/8cwQYpCkW1eN4uPsIxUAJLUh8Frp60b+ZzSVnmh6BVnLZS u9RCORJJV7fWpihkmRjzUEa3m+bARSmow8P6HwObyFyxowoGiWRxwoBBl0MKQ+a0xG N5KMjkKPzYLRHNrXP4w3Q4KmRVbW7wBbHj6CUWyn89aJjWgyT6eGRyCTque+ahhzYC SYmg1BoTFRvaKDjhkfZGrQ4Z+rDprpAKqho3egcQ4jMBiDdTfMCiInFNKy01MAjoQi HxLxJb0Ewj8NQ== Date: Wed, 25 Jun 2025 21:07:38 +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 v3 2/2] rust: support align and NUMA id in allocations Message-ID: References: <20250625062917.3379804-1-vitaly.wool@konsulko.se> <20250625063026.3379921-1-vitaly.wool@konsulko.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Stat-Signature: od84u6r15xx5fhmpmh86mfw4qcrtwppt X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 88802C000D X-HE-Tag: 1750878464-28288 X-HE-Meta: U2FsdGVkX1845ELt1rGD+UiZPWhOP7c1hpJzLdeNXjna2n9ymL6NUDtou5WVxthntz8ISs7R21lLx8j1eTe7XS0gS9C9m07ogSZHk8oKkNBoeiubCDNTs98/uMcV5uqYz+3k90Z06sY820rnO1gS/nQijeF/auSkLK/darpqJq/HiKKbJjgozsC7Lumx0shjhwqVeCAoaIoXsbHRNjRkgyUGEhVfpu3Zra3nB2wEKpXAEcYbccc2OQ9PCjCfjcW3OOUcYu1MduTZlY3MiECE+zfqZVM5r4qqR+KnZx59ietgA2cUkKpjFxqHG338gh6Ai2dumjG9l0LRWmlXhSk3fmPxFd2LX1nC0Yl0OkiqNDhsjCduFWMYNs8Cu31oEfTl47f93qorvRNxJd0NYkKChsQ387ML7vvzZGEq4c/onCgKyFY2zqg0FyjQTXQs74nm1wJJrruc+gHx965U9Va3jJnUo6t3c0o6vpt4a38/tMs0HnSaHwPHNkugt/RR8mwr6i54VoT1pduBXcmef/UL6FuOH0LsEusXZBhDMLK1OV5q54lK+Wo6HCOF7qh8VUU9aeSx8WuMSPWUaFa49q3xce99XuBRv9gBKhs6rAHy/ph+m3MCnrA3t3kJ0tQnJtB8SQatXaWeCQx3nZTl29HCaoG6NawYfEphN6jY/bOxA2knaKhZNhieV0EwIODx2V0Tb2wn/18JQCgxKDlpp8z6sET0ifpwA0jO1xhI9EUe3fzCtC1o29hIZIiuVzzeCtZ8k8/reaUym70Mjih+e+tKTGeUHSkdj3MSQvXeZPTdrNL3LNR7anIWOkP1qUvT1B3yt0hoD+u4G1/a1Mm6OJ/GD38Sawxzi8yFgOjPrVh/ALn8vZ1h7WtLqxoGxv1lZ1Q6xVquyMedDP3RMezN22thX0U2BpK9qkg1LIQDH/Or4sxahFKLfTgLoRhbGrK5F/AUQxTKyk9xzDf3/O4CEcU P5yxFCOx Vu+/Mu2YAlWjeLFwFUHC6eVi3Jchr5JA5t1OQ31gQLZSxFSh7Q/tnamGkBQzPQ5Afz+nJxGUZinbNQ7KkhuKfTsYxMl7zwm7flaiUdxinqpPqy9n+lKTjhuD9QWFyHF5nCVZ2XpJeeVOoNwSotWw1Ye9a1ca/8p/2ZPYws3VR4sNvMt8my4knyJUtJDmZ2ZKJppYxz5Uy0LhgoIfK2LFhXOGDrelN92zcGxayZ2WSdlrxXmYLLBv+PC9hcaitVEc7PEDI 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 Wed, Jun 25, 2025 at 08:56:05PM +0200, Danilo Krummrich wrote: > On Wed, Jun 25, 2025 at 08:30:26AM +0200, Vitaly Wool wrote: > > Add support for large (> PAGE_SIZE) alignments in Rust allocators > > (Kmalloc support for large alignments is limited to the requested > > size, which is a reasonable limitation anyway). > > Please split this.. > > > Besides, add support for NUMA id to Vmalloc. > > and this into separate patches. > > Please also add some information to the commit message what you need node > support for. Do you also have patches to add node support to Box and Vec? > > > > > Signed-off-by: Vitaly Wool > > --- > > rust/helpers/slab.c | 8 +++++-- > > rust/helpers/vmalloc.c | 4 ++-- > > rust/kernel/alloc.rs | 28 ++++++++++++++++++++++-- > > rust/kernel/alloc/allocator.rs | 40 +++++++++++++++++++--------------- > > rust/kernel/alloc/kvec.rs | 3 ++- > > 5 files changed, 59 insertions(+), 24 deletions(-) > > > > diff --git a/rust/helpers/slab.c b/rust/helpers/slab.c > > index a842bfbddcba..221c517f57a1 100644 > > --- a/rust/helpers/slab.c > > +++ b/rust/helpers/slab.c > > @@ -3,13 +3,17 @@ > > #include > > > > void * __must_check __realloc_size(2) > > -rust_helper_krealloc(const void *objp, size_t new_size, gfp_t flags) > > +rust_helper_krealloc(const void *objp, size_t new_size, unsigned long align, gfp_t flags, int nid) > > This should have a comment making it obvious why the function has two arguments > that are discarded. I think we should even separate it with an additional inline > function. > > I do agree with discarding the align argument, given that it's not exposed to > users though the Allocator API. What I meant is that proper alignment is implied when krealloc() succeeds. > I do disagree with discarding the nid argument though, since you change the > generic Allocator::realloc() API to take a node argument, which for KREALLOC and > KVREALLOC is silently discarded. If we introduce it, we should do so for all > three allocators. > > > { > > + if (WARN_ON(new_size & (align - 1))) > > + return NULL; > > I don't think we should have this WARN_ON(). If we want to warn about this, we > should already do so on the Rust side. The helper functions in this file should > not contain any logic. > > > return krealloc(objp, new_size, flags); > > } > > > > void * __must_check __realloc_size(2) > > -rust_helper_kvrealloc(const void *p, size_t size, gfp_t flags) > > +rust_helper_kvrealloc(const void *p, size_t size, unsigned long align, gfp_t flags, int nid) > > { > > + if (WARN_ON(size & (align - 1))) > > + return NULL; > > return kvrealloc(p, size, flags); > > } > > Same as above. This is actually different though, here kvrealloc() may succeed even if the requested alignment is not fulfilled, so this is incorrect.