From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-40133.protonmail.ch (mail-40133.protonmail.ch [185.70.40.133]) (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 97B1719DF77 for ; Thu, 25 Jul 2024 18:06:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.40.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721930775; cv=none; b=D9N/Bqxfs9EmVRioiuWjVCNLoqzKfZ405AypH7s+jrcqgVZZVOSPInvva9Jx/ZR12Tnt/l73X0OeqCUF3rotQ9zWAtWdKxm3zSn54GJupRHivI4JJCKU+b7GJgxW8ZLQY131jKQEWqDvHMDM825qtLmcaZuZJyOCidgjNMhLpnA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721930775; c=relaxed/simple; bh=dPR++PvUoyCPmtYZdQ7LKhGBEs9H2po/2npLkA6LiAg=; h=Date:To:From:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EJCam7MMc/+aFx+PL2aZM93UU14fxIFUhXbo6DiLJy0eahlYK8iYzFaysHsG3RxOT8qhs0WgLqA0K0QyK7XkVF0SPEQ4i17fSiI0j/4Fuw0byymG75uFTjHIR+PTGac25O7j7SUryv5Ukb+PzWlCGL/gHKtvRLHgd9EAN1Ym/94= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=Ppard+I/; arc=none smtp.client-ip=185.70.40.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="Ppard+I/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1721930771; x=1722189971; bh=v1XSfOC46SQD5J7rzSfoiVRwNcJgL8NSNBFuFhZJcM4=; h=Date:To:From:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Ppard+I/1RXQyHNfh5sqm6pMuNzjFOU1Rs1HSv5P2qlxOXaOxVOF7GO4PCR70qvXN tGtfMlaF+cGN6BmX/ODBRYABaIHYDa/NwBazJhT4lb4Dp/WSBHDJ/us2tQTJf2+yCC yUZFObvleQpPfLTFfgYK8y8wikGwrf3HLPGOAMeZqfbdehv0xZPZ0YaO+cVyyNu4wY c8MVd18BexLv2TVMn7ZSiI5wkiS20Q2W83bYJDsSMr0Nw95dRVFdTAORtj1FtJoOAW HL7yT0J8/9qjg8T49vReWZ3BtGj0977sVo3GLVgYoA4v9flfdbcMp7iYZwNk54ycs8 3jSxacxQWhvMw== Date: Thu, 25 Jul 2024 18:06:06 +0000 To: Alex Mantel , ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, a.hindborg@samsung.com, aliceryhl@google.com, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org From: Benno Lossin Subject: Re: [PATCH v2] rust: Implement the smart pointer `InPlaceInit` for `Arc` Message-ID: <27dad59c-ba8a-43c4-a288-870cf29fa131@proton.me> In-Reply-To: <20240719192234.330341-1-alexmantel93@mailbox.org> References: <20240719192234.330341-1-alexmantel93@mailbox.org> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 8bedcef49daeb2c7699dc9d626a3c03a5b899e97 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-Transfer-Encoding: quoted-printable On 19.07.24 21:22, Alex Mantel wrote: > diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs > index 68605b633..46f50cf12 100644 > --- a/rust/kernel/init.rs > +++ b/rust/kernel/init.rs > @@ -213,6 +213,7 @@ > use crate::{ > alloc::{box_ext::BoxExt, AllocError, Flags}, > error::{self, Error}, > + sync::Arc, > sync::UniqueArc, > types::{Opaque, ScopeGuard}, > }; > @@ -1112,11 +1113,15 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Re= sult<(), E> { >=20 > /// Smart pointer that can initialize memory in-place. > pub trait InPlaceInit: Sized { > + /// A type might be pinned implicitly. An addtional `Pin` is useless. In > + /// doubt, the type can just be set to `Pin`. This comment should better describe the purpose of this associated type, the first line could be "Pinned version of `Self`" then (with an empty line in between) you could write more explanatory stuff. I would also rephrase what you have above, for example: "If a type already implicitly pins its pointee, `Pin` is unnecessary. In this case use `Self`, otherwise just use `Pin`.". > + type PinnedResult; I don't really like the name for this, since it is not a result. What do you think of `PinnedSelf`? Otherwise this looks good! --- Cheers, Benno > + > /// Use the given pin-initializer to pin-initialize a `T` inside of = a new smart pointer of this > /// type. > /// > /// If `T: !Unpin` it will not be able to move afterwards. > - fn try_pin_init(init: impl PinInit, flags: Flags) -> Result= , E> > + fn try_pin_init(init: impl PinInit, flags: Flags) -> Result= > where > E: From; >=20