Linus Torvalds writes: (Summary) wrote:
Oh, it's much worse than that.
Oh, it's much worse than that.
It's not that it would write beyond the array on big-endian, even if it were to be _in_ the array it simply writes the wrong bit entirely. The alignment may be wrong, and even on architectures that handle unaligned loads and stores perfectly well, _atomic_ unaligned may not work at all.
unaligned may not work at all.
x86 is actually unique in handling even unaligned atomics, and even on x86 it's generally something you absolutely need to avoid for performance reasons (most of the time it's fine, but atomics that cross cachelines or pages can be very very expensive).
[...]
behind the array.Oh, it's much worse than that.
Oh, it's much worse than that.
It's not that it would write beyond the array on big-endian, even if it were to be _in_ the array it simply writes the wrong bit entirely. The alignment may be wrong, and even on architectures that handle unaligned loads and stores perfectly well, _atomic_ unaligned may not work at all.
unaligned may not work at all.
x86 is actually unique in handling even unaligned atomics, and even on x86 it's generally something you absolutely need to avoid for performance reasons (most of the time it's fine, but atomics that cross cachelines or pages can be very very expensive).