From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C8141DA5E; Wed, 14 Aug 2024 13:48:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723643316; cv=none; b=lNB5mJMMjDMbNfk6LFNr788s6xuMmTHlX7oRc09tEOtg1NjqERpgvImsUowAoCdMKkXULXrKurmlFaeu2jjkqVMttCgJwo6CQ7+iW3c1UdmNrt65H/uNhfaT2yFh3bNviuS8Ca31RMD6SKdOUPN6HE820riRWWTYmYnurquVecU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723643316; c=relaxed/simple; bh=uOgqJRsL4yJHH/Z/VgtjBcKE0By86FrGg4AHt6bS2JY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Avlsr7uDZF2py8+Xcpy0TvHAFzH1LFR6AipvM+RCsmOHOcYbdAWhVweKuDNXhAIVTjIBNN0OrqPxZjA/t7NchcVCIep6mwSrjymjj7llnPv5vTiwwcVU+H7tjLIBOZzZ0/bEv+o/u94U96fzyQsbHkGN7aXudhgQf4P+tPch1YE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NXvRYYgh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NXvRYYgh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5402EC116B1; Wed, 14 Aug 2024 13:48:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723643316; bh=uOgqJRsL4yJHH/Z/VgtjBcKE0By86FrGg4AHt6bS2JY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NXvRYYghvwBedjenwahVRJkrRV3Wn4K8smA3XuPMQ4v+EYmciTVARi/T5NLFDTi/E 4oGpX5bFyxXTrR+cI0MlndPGA6JtZguHiQ78LH/KcE4CQzfe15MOlQPyAGFYNSw38J zg2QRkas1DOSPL76H80GhBMeLxawd4gNonujw5SlIl8LJmiR40HClqJr0vfnmD92ak PWPAHThr/ZwD3FA8UP6E18w7eYOQKmfqoUGbkabWWAhIVoG7KKd7PqX2lGLdOYOGYR /2NGC34e8m0pkZo7O1RO9SG8P0o+mrAYbth5zwg5fOIMmQt0AqHyhCEu77pzQnNbJa CFbfDn3WfZqjw== Date: Wed, 14 Aug 2024 15:48:27 +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> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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. > > Alice >