seqlock: provide the same ordering semantics as mainline
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 seqlock: provide the same ordering semantics as mainline
The mainline implementation of read_seqbegin() orders prior loads w.r.t. the read-side critical section. Fixup the RT writer-boosting implementation to provide the same guarantee.
Also, while we're here, update the usage of ACCESS_ONCE() to use READ_ONCE().
---
Found during code inspection of the RT seqlock implementation.
Julia
include/linux/seqlock.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/seqlock.h +2 -1
@@ -453,7 +453,7 @@ static inline unsigned read_seqbegin(seqlock_t *sl)unsigned ret; repeat: - ret =ACCESS_ONCE (sl->seqcount.sequence); + ret =READ_ONCE (sl->seqcount.sequence);if (unlikely (ret &1 )) {/* * Take the lock and let the writer proceed (i.e. evtl
@@ -462,6 +462,7 @@ static inline unsigned read_seqbegin(seqlock_t *sl)spin_unlock_wait (&sl->lock); goto repeat; } +smp_rmb ();return ret; }#endif
Signature · 1 line
2.16.1
Quoted 6 lines · Julia Cartwright
The mainline implementation of
read_seqbegin()orders prior loads w.r.t. the read-side critical section. Fixup the RT writer-boosting implementation to provide the same guarantee.Also, while we're here, update the usage of
ACCESS_ONCE()to useREAD_ONCE().
I'm taking this without the READ_ONCE hunk because ACCESS_ONCE is gone since v4.15 and I had to move on in v4.16.
Quoted 3 lines
Fixes e69f15cf77c23 ("seqlock: Prevent rt starvation")Signed-off-by Julia Cartwright <[email protected]>
Sebastian