All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RT] seqlock: provide the same ordering semantics as mainline
       [not found] <20180426192258.GK12238@jcartwri.amer.corp.natinst.com>
@ 2018-04-26 20:02 ` Julia Cartwright
  2018-05-28 15:30   ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Cartwright @ 2018-04-26 20:02 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, Thomas Gleixner
  Cc: Al Viro, John Ogness, Will Deacon, Peter Zijlstra,
	Gratian Crisan, linux-rt-users, linux-kernel, stable-rt

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().

Fixes: e69f15cf77c23 ("seqlock: Prevent rt starvation")
Cc: stable-rt@vger.kernel.org
Signed-off-by: Julia Cartwright <julia@ni.com>
---
Found during code inspection of the RT seqlock implementation.

   Julia

 include/linux/seqlock.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index a59751276b94..597ce5a9e013 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -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
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH RT] seqlock: provide the same ordering semantics as mainline
  2018-04-26 20:02 ` [PATCH RT] seqlock: provide the same ordering semantics as mainline Julia Cartwright
@ 2018-05-28 15:30   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-05-28 15:30 UTC (permalink / raw)
  To: Julia Cartwright
  Cc: Thomas Gleixner, Al Viro, John Ogness, Will Deacon,
	Peter Zijlstra, Gratian Crisan, linux-rt-users, linux-kernel,
	stable-rt

On 2018-04-26 15:02:03 [-0500], Julia Cartwright wrote:
> 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().

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.

> Fixes: e69f15cf77c23 ("seqlock: Prevent rt starvation")
> Cc: stable-rt@vger.kernel.org
> Signed-off-by: Julia Cartwright <julia@ni.com>

Sebastian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-28 15:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20180426192258.GK12238@jcartwri.amer.corp.natinst.com>
2018-04-26 20:02 ` [PATCH RT] seqlock: provide the same ordering semantics as mainline Julia Cartwright
2018-05-28 15:30   ` Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.