From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) (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 8614826561A for ; Thu, 20 Feb 2025 23:18:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.40.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740093533; cv=none; b=PhkO8qiQO+/BEX7KA6R0uUjymm4Pq0/UAiZK9JtzTcpUAJNop9IQvaWL7s8OvsQmcwK5l7b9riyXhBn1gP/KaW5Dgf01Qo0a/KAaL6ASrNPw2dEXWYBTXLscGiQJtIZR8XS0qx2TZ7w8T8kGowiKY5J6rkc3ktU7ScD4Rjpxt+M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740093533; c=relaxed/simple; bh=qekYXtKUzur6RQDfjSqpA7I2U8CUtJ0pCQjlkDyL+rk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AVvT3MhhD/+5IPPp5hKvF5LymX1KgxzQ5hintiunr2Ipizl31+QU9M271YNJt45tSd3GHYCH2T7euhSFTsWTTg6E+TYbHMG3lEgcdaXZpr8989QobZknrOZzgi9rW46X0S3BeUsn+4f3WryAORk39pUOcmHnzo3Fup9VSXZkdxg= 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=DrIlFi7T; arc=none smtp.client-ip=185.70.40.134 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="DrIlFi7T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=6xsbb6fazjaphi6ls2p4sq5lzq.protonmail; t=1740093523; x=1740352723; bh=xBQAiFiI1yIVO0u4bFT+4KE+i0yQ/3TAu9mAqC+PYkY=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=DrIlFi7TxaAkgKZLu7kjtdgvh1bQEboPQwtYIZe2nq2ARp3BxZZXJGO1Vo1TPTr5u RAmRbdJidSVqVTd/qrfYtzDHBgXHln5xNmSJrC/umA09qvTa30Q4CcGcEnI7H8vaVo 1Pk5CYpQuA4WGuMPT219qFMoEYl3KY/GHaIwfHR9KARZr80cabpAd2sCyUwmuVTff9 lrMPN3EPYg0viAm0Uk6Re3ev6W/MUQeFuBVY661cufAdSQJb+eZX//4cCXUUqFmISK d9Wm5vqWfNpPehuzz6v4qI+BKPcOsli031+jhuP/zOxPRGNdE1hUUbqWuEMtrZdx7T 21BNUsjGjhh9w== Date: Thu, 20 Feb 2025 23:18:36 +0000 To: Andreas Hindborg , Miguel Ojeda , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Danilo Krummrich From: Benno Lossin Cc: Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Alice Ryhl , Trevor Gross , Lyude Paul , Guangbo Cui <2407018371@qq.com>, Dirk Behme , Daniel Almeida , Tamir Duberstein , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 03/14] rust: sync: add `Arc::as_ptr` Message-ID: <59064411-ae6c-4adb-8b3a-186f8004c2a0@proton.me> In-Reply-To: <20250218-hrtimer-v3-v6-12-rc2-v8-3-48dedb015eb3@kernel.org> References: <20250218-hrtimer-v3-v6-12-rc2-v8-0-48dedb015eb3@kernel.org> <20250218-hrtimer-v3-v6-12-rc2-v8-3-48dedb015eb3@kernel.org> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 8ef93b80597a1bd31e1f6b807ae9da724a7d71a3 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 18.02.25 14:27, Andreas Hindborg wrote: > Add a method to get a pointer to the data contained in an `Arc`. >=20 > Reviewed-by: Lyude Paul > Reviewed-by: Alice Ryhl > Signed-off-by: Andreas Hindborg > --- Reviewed-by: Benno Lossin --- Cheers, Benno >=20 > This is a dependency for: >=20 > rust: hrtimer: implement `HrTimerPointer` for `Arc` > --- > rust/kernel/sync/arc.rs | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) >=20 > diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs > index 3cefda7a43725..1dfa75714f9d6 100644 > --- a/rust/kernel/sync/arc.rs > +++ b/rust/kernel/sync/arc.rs > @@ -246,6 +246,15 @@ pub fn into_raw(self) -> *const T { > unsafe { core::ptr::addr_of!((*ptr).data) } > } >=20 > + /// Return a raw pointer to the data in this arc. > + pub fn as_ptr(this: &Self) -> *const T { > + let ptr =3D this.ptr.as_ptr(); > + > + // SAFETY: As `ptr` points to a valid allocation of type `ArcInn= er`, > + // field projection to `data`is within bounds of the allocation. > + unsafe { core::ptr::addr_of!((*ptr).data) } > + } > + > /// Recreates an [`Arc`] instance previously deconstructed via [`Arc= ::into_raw`]. > /// > /// # Safety > @@ -539,11 +548,11 @@ unsafe fn new(inner: NonNull>) -> Self = { > } >=20 > /// Creates an [`ArcBorrow`] to an [`Arc`] that has previously been = deconstructed with > - /// [`Arc::into_raw`]. > + /// [`Arc::into_raw`] or [`Arc::as_ptr`]. > /// > /// # Safety > /// > - /// * The provided pointer must originate from a call to [`Arc::into= _raw`]. > + /// * The provided pointer must originate from a call to [`Arc::into= _raw`] or [`Arc::as_ptr`]. > /// * For the duration of the lifetime annotated on this `ArcBorrow`= , the reference count must > /// not hit zero. > /// * For the duration of the lifetime annotated on this `ArcBorrow`= , there must not be a >=20 > -- > 2.47.0 >=20 >=20