[WIP 0/3] Memory model and atomic API in Rust

Al Viro viro at zeniv.linux.org.uk
Mon Apr 8 11:14:36 PDT 2024


On Mon, Apr 08, 2024 at 10:01:32AM -0700, Linus Torvalds wrote:

> For our own historical reasons, while we have a few generic atomic
> operations: bit operations, cmpxchg, etc, most of our arithmetic and
> logical ops all rely on a special "atomic_t" type (later extended with
> "atomic_long_t").
> 
> The reason? The garbage that is legacy Sparc atomics.
> 
> Sparc historically basically didn't have any atomics outside of the
> 'test and set byte' one, so if you wanted an atomic counter thing, and
> you cared about sparc, you had to play games with "some bits of the
> counter are the atomic byte lock".
> 
> And we do not care about that Sparc horror any *more*, but we used to.

FWIW, PA-RISC is no better - the same "fetch and replace with constant"
kind of primitive as for sparc32, only the constant is (u32)0 instead
of (u8)~0.  And unlike sparc64, 64bit variant didn't get better.



More information about the linux-arm-kernel mailing list