[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2949f6dc-51fe-4a28-b44d-5a38796303e8@ralfj.de>
Date: Fri, 28 Feb 2025 08:53:11 +0100
From: Ralf Jung <post@...fj.de>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Kent Overstreet <kent.overstreet@...ux.dev>,
Martin Uecker <uecker@...raz.at>, "Paul E. McKenney" <paulmck@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Ventura Jack <venturajack85@...il.com>,
Gary Guo <gary@...yguo.net>, airlied@...il.com, boqun.feng@...il.com,
david.laight.linux@...il.com, ej@...i.de, gregkh@...uxfoundation.org,
hch@...radead.org, hpa@...or.com, ksummit@...ts.linux.dev,
linux-kernel@...r.kernel.org, miguel.ojeda.sandonis@...il.com,
rust-for-linux@...r.kernel.org
Subject: Re: C aggregate passing (Rust kernel policy)
Hi,
On 27.02.25 20:15, Linus Torvalds wrote:
> On Thu, 27 Feb 2025 at 10:33, Ralf Jung <post@...fj.de> wrote:
>>
>> The way you do global flags in Rust is like this:
>
> Note that I was really talking mainly about the unsafe cases, an din
> particular when interfacing with C code.
When Rust code and C code share memory that is concurrently accessed, all
accesses to that from the Rust side must be explicitly marked as atomic. A
pointer to such a memory should look like `&AtomicBool` in Rust, not `*mut
bool`. To my knowledge, the kernel already has appropriate APIs for that. That
will then ensure things behave like the AtomicBool example.
Kind regards,
Ralf
>
> Also, honestly:
>
>> FLAG.store(true, Ordering::SeqCst); // or release/acquire/relaxed
>
> I suspect in reality it would be hidden as accessor functions, or
> people just continue to write things in C.
>
> Yes, I know all about the C++ memory ordering. It's not only a
> standards mess, it's all very illegible code too.
>
> Linus
Powered by blists - more mailing lists