Re: [PATCH] seqlock: Use WRITE_ONCE() when updating sequence
From: Peter Zijlstra
Date: Thu Dec 19 2024 - 12:56:43 EST
On Thu, Dec 19, 2024 at 05:45:15PM +0100, Florian Weimer wrote:
> > Peter's "(*(volatile unsigned int *)&s->sequence)++;" qualifies as sane.
>
> I think the reference was originally to machine code.
Correct; however more tinkering with godbolt got me:
https://godbolt.org/z/6xoxjdYPx
Where we can see that clang can even optimize the WRITE_ONCE(foo,
READ_ONCE(foo) + 1) case, which I though it would not be able to do.
So perhaps we just need to get GCC fixed.