Re: [PATCH] seqlock: Use WRITE_ONCE() when updating sequence

From: Daniel Xu
Date: Fri Jan 24 2025 - 19:34:38 EST


Hi all,

Thanks for the very interesting discussion - I learned quite a few things.

Please let me know if the following is a correct summary:

1. The intent of the change is valid. New compiler optimizations may break
current assumptions.

2. My proposed change is unacceptable due to bad codegen from GCC. Clang is OK
b/c it can optimize the `WRITE_ONCE(.., READ_ONCE(..) + 1)` into a single `incl`
instruction.

3. The counter-proposed INC_ONCE() change from Peter is also incorrect, despite
codegen for both clang and GCC currently being correct. There is no guarantee
that the GCC variant of INC_ONCE() will continue to work in the future.

It sounds like the next step for this is to follow up w/ GCC folks about improving
codegen for `WRITE_ONCE(.., READ_ONCE(..) + 1`)`.

Does that sound right?

Thanks,
Daniel