All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: "Marco Elver" <elver@google.com>, "Gary Guo" <gary@garyguo.net>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, kasan-dev@googlegroups.com,
	"Will Deacon" <will@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Elle Rhumsaa" <elle@weathered-steel.dev>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	"FUJITA Tomonori" <fujita.tomonori@gmail.com>
Subject: Re: [PATCH 2/2] rust: sync: atomic: Add atomic operation helpers over raw pointers
Date: Wed, 21 Jan 2026 13:07:34 +0000	[thread overview]
Message-ID: <aXDPliPQs8jU_wfz@google.com> (raw)
In-Reply-To: <aXDL5NUOH_qr390Q@tardis-2.local>

On Wed, Jan 21, 2026 at 08:51:48PM +0800, Boqun Feng wrote:
> On Wed, Jan 21, 2026 at 01:36:04PM +0100, Marco Elver wrote:
> [..]
> > >
> > > > However this will mean that Rust code will have one more ordering than the C
> > > > API, so I am keen on knowing how Boqun, Paul, Peter and others think about this.
> > >
> > > On that point, my suggestion would be to use the standard LKMM naming
> > > such as rcu_dereference() or READ_ONCE().
> 
> I don't think we should confuse Rust users that `READ_ONCE()` has
> dependency orderings but `atomc_load()` doesn't. They are the same on
> the aspect. One of the reasons that I don't want to introduce
> rcu_dereference() and READ_ONCE() on Rust side is exactly this, they are
> the same at LKMM level, so should not be treated differently.

That's okay with me - I just don't think "relaxed" is a good name for
atomic_load() if that's the case.

> > > I'm told that READ_ONCE() apparently has stronger guarantees than an
> > > atomic consume load, but I'm not clear on what they are.
> > 
> > It's also meant to enforce ordering through control-dependencies, such as:
> > 
> >    if (READ_ONCE(x)) WRITE_ONCE(y, 1);
> 
> Note that it also applies to atomic_read() and atomic_set() as well.

Just to be completely clear ... am I to understand this that READ_ONCE()
and the LKMM's atomic_load() *are* the exact same thing? Because if so,
then this was really confusing:

> my argument was not about naming, it's
> about READ_ONCE() being more powerful than atomic load (no, not because
> of address dependency, they are the same on that, it's because of the
> behaviors of them regarding a current access on the same memory
> location)
> https://lore.kernel.org/all/aWuV858wU3MeYeaX@tardis-2.local/

Are they the *exact* same thing or not? Do you mean that they are the
same under LKMM, but different under some other context?

Alice

  reply	other threads:[~2026-01-21 13:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-20 11:52 [PATCH 0/2] Provide Rust atomic helpers over raw pointers Boqun Feng
2026-01-20 11:52 ` [PATCH 1/2] rust: sync: atomic: Remove bound `T: Sync` for `Atomci::from_ptr()` Boqun Feng
2026-01-20 12:38   ` Alice Ryhl
2026-01-20 12:39   ` Alice Ryhl
2026-01-20 13:09   ` Gary Guo
2026-01-20 11:52 ` [PATCH 2/2] rust: sync: atomic: Add atomic operation helpers over raw pointers Boqun Feng
2026-01-20 12:40   ` Alice Ryhl
2026-01-20 13:25   ` Gary Guo
2026-01-20 13:46     ` Boqun Feng
2026-01-20 16:23   ` Marco Elver
2026-01-20 16:47     ` Gary Guo
2026-01-20 17:10       ` Marco Elver
2026-01-20 17:32         ` Gary Guo
2026-01-20 20:52         ` Boqun Feng
2026-01-21 12:13           ` Marco Elver
2026-01-21 12:58             ` Boqun Feng
2026-01-21 13:09             ` Alice Ryhl
2026-01-21 12:19       ` Alice Ryhl
2026-01-21 12:36         ` Marco Elver
2026-01-21 12:51           ` Boqun Feng
2026-01-21 13:07             ` Alice Ryhl [this message]
2026-01-21 14:04               ` Boqun Feng
2026-01-21 13:42         ` Gary Guo
2026-01-20 17:12     ` Gary Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aXDPliPQs8jU_wfz@google.com \
    --to=aliceryhl@google.com \
    --cc=a.hindborg@kernel.org \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=elle@weathered-steel.dev \
    --cc=elver@google.com \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=ojeda@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.