summaryrefslogtreecommitdiff
path: root/lib/seqlock.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/seqlock.h')
-rw-r--r--lib/seqlock.h9
1 files changed, 3 insertions, 6 deletions
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