On Mon, 8 Apr 2024 at 11:14, Al Viro wrote: > > 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. Heh. The thing about PA-RISC is that it is actually *so* much worse that it was never useful for an arithmetic type. IOW, the fact that sparc used just a byte meant that the aotmic_t hackery on sparc still gave us 24 useful bits in a 32-bit atomic_t. So long ago, we used to have an arithmetic atomic_t that was 32-bit on all sane architectures, but only had a 24-bit range on sparc. And I know you know all this, I'm just explaining the horror for the audience. On PA-RISC you couldn't do that horrendous trick, so parist just used the "we use a hashed spinlock for all atomics", and "atomic_t" was a regular full-sized integer type. Anyway, the sparc 24-bit atomics were actually replaced by the PA-RISC version back twenty years ago (almost to the day): https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=373f1583c5c5 and while we still had some left-over of that horror in the git tree up until 2011 (until commit 348738afe530: "sparc32: drop unused atomic24 support") we probably should have made the "arch_atomic_xyz()" ops work on generic types rather than "atomic_t" for a long long time, so that you could use them on other things than "atomic_t" and friends. You can see the casting horror here, for example: include/asm-generic/bitops/atomic.h where we do that cast from "volatile unsigned long *p" to "atomic_long_t *" just to use the raw_atomic_long_xyz() operations. It would make more sense if the raw atomics took that "native" volatile unsigned long pointer directly. (And here that "volatile" is not because it's necessary used as a volatile - it is - but simply because it's the most permissive type of pointer. You can see other places using "const volatile unsigned long" pointers for the same reason: passing in a non-const or non-volatile pointer is perfectly fine). Linus