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 4C5D2430BB5; Sun, 1 Mar 2026 16:34:43 +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=1772382883; cv=none; b=k4DwpMcwBGola/2RCSTJgaofnBo275c4aaDUAl1306dlVrtOtexxgACISjcYaQ1OtuFmDqvb2kDm13fEO1CHNu+6dxG3CA7Ve6jTl7hhKFWEzP0Yi6iPFRcxRQ/G7iNdFzy6iEil2gnJqU9wG2a4BQfuRMco/BHJRpvr1gMdL4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772382883; c=relaxed/simple; bh=je5mLoR2Jxu2IjLDAPypnbsm91i4Kuu9GRu6352moZk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=PcIinGqutMH4jAj/WjLH85L/ZWt5bmXJkmzPSCNtkxD/RqmYzGHoKI/Ei68XgfXI8YcdtsyALTtWwsTrEoErJPhSXwnyt2jJ5k1XUqZ9/uL/z97ldP9aNm52ddSXODjGpDXP2gX2vCQUh9VnQVhWeK5eWRYUx4ZvCu3XGVSnmeA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TKgzX0hf; 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="TKgzX0hf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FC44C116C6; Sun, 1 Mar 2026 16:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772382883; bh=je5mLoR2Jxu2IjLDAPypnbsm91i4Kuu9GRu6352moZk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=TKgzX0hf3d0lhMQetjAEiiWCOKnFnzvXZWHgmPaqhbewdN3fJRosoCZCc9qBvc/po evHx93y+6jGFm1MG3XNqYQsOr8ddGPjYTtni3MBr4+Wfeg0Bdp7DgyJtpeSaRoBKsq /8EmI4goKRcWrT+Ty8VXffQn9jZgFIq3COzQDhZXz+v1zP/sZmvi7J3/9qpNTmJlXX dvga5zyWNUWjv9DVOk3rU4gbLyOte0fKmobQCF487i0iZ6UJJpeiE7pdPHIoBrDEge JZG83Fy8G1/GE+0kCzgow04ihq31SX509/egQfJwEahHcltsBfRDzs14I3kQCC0Q4D NTYljGVX/IW5w== From: Andreas Hindborg To: Gary Guo , Miguel Ojeda , Gary Guo , =?utf-8?Q?Bj=C3=B6rn?= Roy Baron , Benno Lossin , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , Dave Ertman , Ira Weiny , Leon Romanovsky , Paul Moore , Serge Hallyn , "Rafael J. Wysocki" , David Airlie , Simona Vetter , Alexander Viro , Christian Brauner , Jan Kara , Igor Korotin , Daniel Almeida , Lorenzo Stoakes , "Liam R. Howlett" , Viresh Kumar , Nishanth Menon , Stephen Boyd , Bjorn Helgaas , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Boqun Feng , Vlastimil Babka , Uladzislau Rezki Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-block@vger.kernel.org, linux-security-module@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v16 01/10] rust: alloc: add `KBox::into_nonnull` In-Reply-To: References: <20260224-unique-ref-v16-0-c21afcb118d3@kernel.org> <20260224-unique-ref-v16-1-c21afcb118d3@kernel.org> Date: Sun, 01 Mar 2026 17:34:26 +0100 Message-ID: <87ldgbbjal.fsf@t14s.mail-host-address-is-not-set> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain "Gary Guo" writes: > On Tue Feb 24, 2026 at 11:17 AM GMT, Andreas Hindborg wrote: >> Add a method to consume a `Box` and return a `NonNull`. This >> is a convenience wrapper around `Self::into_raw` for callers that need >> a `NonNull` pointer rather than a raw pointer. >> >> Signed-off-by: Andreas Hindborg >> --- >> rust/kernel/alloc/kbox.rs | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/rust/kernel/alloc/kbox.rs b/rust/kernel/alloc/kbox.rs >> index 622b3529edfcb..e6efdd572aeea 100644 >> --- a/rust/kernel/alloc/kbox.rs >> +++ b/rust/kernel/alloc/kbox.rs >> @@ -213,6 +213,14 @@ pub fn leak<'a>(b: Self) -> &'a mut T { >> // which points to an initialized instance of `T`. >> unsafe { &mut *Box::into_raw(b) } >> } >> + >> + /// Consumes the `Box` and returns a `NonNull`. >> + /// >> + /// Like [`Self::into_raw`], but returns a `NonNull`. >> + pub fn into_nonnull(b: Self) -> NonNull { >> + // SAFETY: `KBox::into_raw` returns a valid pointer. >> + unsafe { NonNull::new_unchecked(Self::into_raw(b)) } >> + } > > Hi Andreas, > > It looks like this patch and many others in the series are missing `#[inline]` > for quite a few very simple functions. Could you go through the series and mark > small functions as such? Sure. Could you remind me why we need this directive? Would the compiler not be able to decide? I know we have an issue when we have call to C function in short functions, but not in the general case? Best regards, Andreas Hindborg