[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <amebiomyty3gw7gwgpz3sbztzdac6ce2pslq3jjfe3no4w72dn@sskvzdp6l67w>
Date: Wed, 26 Feb 2025 15:25:33 -0500
From: Kent Overstreet <kent.overstreet@...ux.dev>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Ralf Jung <post@...fj.de>, 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)
On Wed, Feb 26, 2025 at 09:59:41AM -0800, Linus Torvalds wrote:
> And just as an example: threading fundamentally introduces a notion of
> "aliasing" because different *threads* can access the same location
> concurrently. And that actually has real effects that a good language
> absolutely needs to deal with, even when there is absolutely *no*
> memory ordering or locking in the source code.
>
> For example, it means that you cannot ever widen stores unless you
> know that the data you are touching is thread-local. Because the bytes
> *next* to you may not be things that you control.
In Rust, W^X references mean you know that if you're writing to an
object you've got exclusive access - the exception being across an
UnsafeCell boundary, that's where you can't widen stores.
Which means all those old problems with bitfields go away, and the
compiler people finally know what they can safely do - and we have to
properly annotate access from multiple threads.
E.g. if you're doing a ringbuffer with head and tail pointers shared
between multiple threads, you no longer do that with bare integers, you
use atomics (even if you're not actually using any atomic operations on
them).
Powered by blists - more mailing lists