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 534F6C3DA4A for ; Wed, 14 Aug 2024 14:01:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 762B26B0088; Wed, 14 Aug 2024 10:01:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 712F86B0089; Wed, 14 Aug 2024 10:01:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B3E26B008A; Wed, 14 Aug 2024 10:01:00 -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 3BDF56B0088 for ; Wed, 14 Aug 2024 10:01:00 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D086A140F8A for ; Wed, 14 Aug 2024 14:00:59 +0000 (UTC) X-FDA: 82451012238.24.01FBE89 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf04.hostedemail.com (Postfix) with ESMTP id D70D640021 for ; Wed, 14 Aug 2024 14:00:53 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oPESjOzH; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=dakr@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723644001; a=rsa-sha256; cv=none; b=IPidURH7QXFFv8YqRObi02JZRUU0E70sghJPjMuHAILBLglMlcEn0RrU+RWsjtnUq9ZwWh y6nzsAX7J+Y5t8T3x7C6TT8CwB5phomonzUAkzeLNSXixAp/PRJHYKzvzP3Qtb1KeLCGEu VgA8knkwpIFy/Yyl99bFq8f2LmLqyAI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oPESjOzH; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 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=1723644001; 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=6IweGeybwMaBNyHTHSEGCpv2v0W7obnbPt52mZf4xZc=; b=EL8KOeovG4yo16n3ZTnFsOvJLFtND+z19vm3IaSKTNoMwoR3WF6jCQD6ZLsUjFO8KJVcRX WZa08GPKaLIAZcvYTDdFfJIYyfZbqiD/A8zSnNSGpOIL7M3aqaDnbX0qKB8HM3J4qrhFHo vTwd8io9EGpqMe9zOLc/rzIdI92r8Kk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 34847CE19CF; Wed, 14 Aug 2024 14:00:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53C78C116B1; Wed, 14 Aug 2024 14:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723644048; bh=wXCjzjCYhmAe3aX6R1ETmjfHVH5+3ZkjVKvHH6sIZ5Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oPESjOzHoHyNhkpIy3ROW/GUewe4r4iTT0BejXNBScOb6V9QGcyY3Yd3Xd0VqJO0O 7rT9jJDegjr+1rAmNxZ6DTrNrJmXugZBj6OAV1mgz5Qp7prNxC3TO54s5lTWxJdnpd WZRQJSL5CNtfeISzx3SLD34C4ZUhxj3EsfdrRRDUrn8yLc54PXTtBdTPifA2YieH2L L3ZuilZfvoAPyEle4gQ7PU01tIeGJaqjo8pB0aGnwqnwZ7y9WGmNo39AdmT6tn15ie iNgol976SGbvuxtuMEtEXxn/K+CaQi/bDIN0P4PALLcMWcyZo8EMMEuoTY6OKzcr2W knCkGtRwuP8Vg== Date: Wed, 14 Aug 2024 16:00:40 +0200 From: Danilo Krummrich To: Alice Ryhl Cc: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, akpm@linux-foundation.org, daniel.almeida@collabora.com, faith.ekstrand@collabora.com, boris.brezillon@collabora.com, lina@asahilina.net, mcanal@igalia.com, zhiw@nvidia.com, cjia@nvidia.com, jhubbard@nvidia.com, airlied@redhat.com, ajanulgu@redhat.com, lyude@redhat.com, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v5 04/26] rust: alloc: implement `Allocator` for `Kmalloc` Message-ID: References: <20240812182355.11641-1-dakr@kernel.org> <20240812182355.11641-5-dakr@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: D70D640021 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: kh8gwmyncs83busm6zmmgnm1mxp8ydk3 X-HE-Tag: 1723644053-609158 X-HE-Meta: U2FsdGVkX1+f6jq4dlGV91VUQV+FlDGR/B73rFNxpEGi28sFh1WyelxUhrKveS2YTZtXhN8f4pYo2gHVpvCxXkHM1MO22+4x7rNQFPLT725ebCClHIh/LM8ssdJ5zOF+PO9YEh8B+o0m7nl/Zx0o8utmnxq3RmdmL8K84gpXGgXKS+sTNClCq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azwlaFK2WS2qC5lq96jami/5M6lrPEEEWc503azipfNsKeOerv/QkQslNG9Dj3ojut+OtmWBdY23a+rvo7V/AWx3qkFEQ== 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, Aug 14, 2024 at 03:50:27PM +0200, Alice Ryhl wrote: > On Wed, Aug 14, 2024 at 3:48 PM Danilo Krummrich wrote: > > > > On Wed, Aug 14, 2024 at 03:44:56PM +0200, Alice Ryhl wrote: > > > On Wed, Aug 14, 2024 at 3:36 PM Danilo Krummrich wrote: > > > > > > > > On Wed, Aug 14, 2024 at 09:51:34AM +0200, Alice Ryhl wrote: > > > > > On Mon, Aug 12, 2024 at 8:24 PM Danilo Krummrich wrote: > > > > > > > > > > > > Implement `Allocator` for `Kmalloc`, the kernel's default allocator, > > > > > > typically used for objects smaller than page size. > > > > > > > > > > > > All memory allocations made with `Kmalloc` end up in `krealloc()`. > > > > > > > > > > > > It serves as allocator for the subsequently introduced types `KBox` and > > > > > > `KVec`. > > > > > > > > > > > > Signed-off-by: Danilo Krummrich > > > > > > --- > > > > > > rust/helpers.c | 3 +- > > > > > > rust/kernel/alloc.rs | 2 +- > > > > > > rust/kernel/alloc/allocator.rs | 63 +++++++++++++++++++++++++++++++++- > > > > > > 3 files changed, 64 insertions(+), 4 deletions(-) > > > > > > > > > > > > diff --git a/rust/helpers.c b/rust/helpers.c > > > > > > index 92d3c03ae1bd..9f7275493365 100644 > > > > > > --- a/rust/helpers.c > > > > > > +++ b/rust/helpers.c > > > > > > @@ -193,8 +193,7 @@ void rust_helper_init_work_with_key(struct work_struct *work, work_func_t func, > > > > > > } > > > > > > EXPORT_SYMBOL_GPL(rust_helper_init_work_with_key); > > > > > > > > > > > > -void * __must_check __realloc_size(2) > > > > > > -rust_helper_krealloc(const void *objp, size_t new_size, gfp_t flags) > > > > > > +void *rust_helper_krealloc(const void *objp, size_t new_size, gfp_t flags) > > > > > > { > > > > > > return krealloc(objp, new_size, flags); > > > > > > } > > > > > > > > > > Why are the various annotations on this helper being removed? > > > > > > > > rust_helper_krealloc() is only called from Rust, hence neither __must_check nor > > > > __realloc_size() should have any effect. > > > > > > > > I also do not apply them in subsequent commits for the vrealloc() and > > > > kvrealloc() helpers for this reason and removed them here for consistency. > > > > > > > > > This deserves an explanation in the commit message. > > > > > > > > I can also add a separate commit for that. > > > > > > I think your change would be more obviously correct if you keep them. > > > > As in generally, or just for this patch? > > > > Generally, I don't think we should indicate compiler checks that actually are > > never done. > > > > For this patch, yes, it's probably better to separate it. > > In general. If you keep it, then I don't have to think about whether > it affects bindgen's output. That's the main reason. Well, it doesn't. If we keep them, we'd consequently also need to add them for vrealloc() and kvrealloc(). But again, they don't do anything for us, and hence are more misleading than helpful IMO. > > Alice >