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 898EF1FF1A0; Mon, 14 Jul 2025 15:17:06 +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=1752506226; cv=none; b=SdseNECWsTcc1V8ZDRWD3RLlKxB4ggNKUefqaSTQ0WH7mvTWIanX0NcOxQ8Fz5B/YBWWtWfnIwh72T0XRuGF6x42LoKFFhvPGbVGew5CBqEZvEXMiGpuOCarUG7DsV8g0p+0Yx85pVQsRGtjk4BmYTgdCieaI2yqcWhEtQ5KUWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752506226; c=relaxed/simple; bh=4igAOpka0ueg8YOxxmkXDIQmMsPUVxUchsQwmhh9DIQ=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=VP/zve1mgNdGoDgNCOGnk/xN0OlHHzMHd+krtrhtG01ZwaHZn6D2Qai0nID547Q8WumOxKB+LRimSQwgVAhx3ITIM3B2R5EuXDVLtLfldFbkzlt3abqKdvCTbeooiEetYSrkOllBxYkdNkx269Kq/V4Pe/y6+73MnFxAdrsj+Qk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K6C72BaY; 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="K6C72BaY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE900C4CEF0; Mon, 14 Jul 2025 15:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752506226; bh=4igAOpka0ueg8YOxxmkXDIQmMsPUVxUchsQwmhh9DIQ=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=K6C72BaY+ln7/Qi4pr0Pvo88sqkcnKsQ+wXyOvOx3IXRAiKTU/jaloK7EtjKwvJV2 uHeo6gwRKQj/DB5EqQj+hQhAYIkfBJF9CTX7AOcv7hPCGUlt9dXmUp24VQ+VOn0Tjn 9D0Hul+vnRRM8AlBQ1cKz4ZhhdfAKAZrUJ6fM8375VpEOhrhDHgNTT8U5jDplmJCTl aS+k6x+EFv3o/vXBu++qIeW3YEEBZxNfwtVXwXpYSDSafUYMVj1XBttJDC1kT/eH3j u/4kO1yrV8m/p3nLYaJAI9sQnJaA8ghRET6EeZ0JoRpuNRcBvorHf3UlzDF4BI+K1j PFZ0wkWl5G5Iw== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 14 Jul 2025 17:16:59 +0200 Message-Id: To: "Boqun Feng" , "Miguel Ojeda" Cc: , , , , "Miguel Ojeda" , "Alex Gaynor" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Danilo Krummrich" , "Will Deacon" , "Peter Zijlstra" , "Mark Rutland" , "Wedson Almeida Filho" , "Viresh Kumar" , "Lyude Paul" , "Ingo Molnar" , "Mitchell Levy" , "Paul E. McKenney" , "Greg Kroah-Hartman" , "Linus Torvalds" , "Thomas Gleixner" , "Alan Stern" Subject: Re: [PATCH v7 4/9] rust: sync: atomic: Add generic atomics From: "Benno Lossin" X-Mailer: aerc 0.20.1 References: <20250714053656.66712-1-boqun.feng@gmail.com> <20250714053656.66712-5-boqun.feng@gmail.com> In-Reply-To: On Mon Jul 14, 2025 at 4:53 PM CEST, Boqun Feng wrote: > On Mon, Jul 14, 2025 at 04:34:39PM +0200, Miguel Ojeda wrote: >> On Mon, Jul 14, 2025 at 4:22=E2=80=AFPM Boqun Feng wrote: >> > >> > Hmm.. why? This is the further information about what the above >> > "Examples" section just mentioned? >>=20 >> I think Benno may be trying to point out is may be confusing what >> "this" may be referring to, i.e. is it referring to something concrete >> about the example, or about `from_ptr` as a whole / in all cases? >>=20 > > Ok, how about I do this: > > diff --git a/rust/kernel/sync/atomic/generic.rs b/rust/kernel/sync/atomic= /generic.rs > index 26d9ff3f7c35..e40010394536 100644 > --- a/rust/kernel/sync/atomic/generic.rs > +++ b/rust/kernel/sync/atomic/generic.rs > @@ -135,6 +135,9 @@ pub const fn new(v: T) -> Self { > > /// Creates a reference to an atomic `T` from a pointer of `T`. > /// > + /// This usually is used when when communicating with C side or mani= pulating a C struct, see > + /// examples below. I don't think it's necessary to mention the examples below, but this is what I had in mind. --- Cheers, Benno > + /// > /// # Safety > /// > /// - `ptr` is aligned to `align_of::()`. > @@ -185,9 +188,6 @@ pub const fn new(v: T) -> Self { > /// // no data race. > /// unsafe { Atomic::from_ptr(foo_a_ptr) }.store(2, Release); > /// ``` > - /// > - /// However, this should be only used when communicating with C side= or manipulating a C > - /// struct. > pub unsafe fn from_ptr<'a>(ptr: *mut T) -> &'a Self > where > T: Sync, > > ? > > Regards, > Boqun > >> Cheers, >> Miguel