From: Bart Van Assche Date: Sun, 21 Jun 2020 21:24:36 +0000 (-0700) Subject: Optimize the seqlock implementation X-Git-Tag: fio-3.21~28^2~1 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=5fa0c063c6fe405200ec97e8f3703446dd8d82bc Optimize the seqlock implementation Use atomic_load_acquire() and atomic_store_release() instead of barriers where appropriate. Signed-off-by: Bart Van Assche --- diff --git a/lib/seqlock.h b/lib/seqlock.h index 762b6ec1..afa9fd31 100644 --- a/lib/seqlock.h +++ b/lib/seqlock.h @@ -18,13 +18,12 @@ static inline unsigned int read_seqlock_begin(struct seqlock *s) unsigned int seq; do { - seq = s->sequence; + seq = atomic_load_acquire(&s->sequence); if (!(seq & 1)) break; nop; } while (1); - read_barrier(); return seq; } @@ -36,14 +35,12 @@ static inline bool read_seqlock_retry(struct seqlock *s, unsigned int seq) static inline void write_seqlock_begin(struct seqlock *s) { - s->sequence++; - write_barrier(); + s->sequence = atomic_load_acquire(&s->sequence) + 1; } static inline void write_seqlock_end(struct seqlock *s) { - write_barrier(); - s->sequence++; + atomic_store_release(&s->sequence, s->sequence + 1); } #endif