linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julia Cartwright <julia@ni.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	John Ogness <john.ogness@linutronix.de>,
	Will Deacon <will.deacon@arm.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	Gratian Crisan <gratian.crisan@ni.com>,
	<linux-rt-users@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<stable-rt@vger.kernel.org>
Subject: [PATCH RT] seqlock: provide the same ordering semantics as mainline
Date: Thu, 26 Apr 2018 15:02:03 -0500	[thread overview]
Message-ID: <20180426200203.11560-1-julia@ni.com> (raw)
In-Reply-To: <20180426192258.GK12238@jcartwri.amer.corp.natinst.com>

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

       reply	other threads:[~2018-04-26 20:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180426192258.GK12238@jcartwri.amer.corp.natinst.com>
2018-04-26 20:02 ` Julia Cartwright [this message]
2018-05-28 15:30   ` [PATCH RT] seqlock: provide the same ordering semantics as mainline Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180426200203.11560-1-julia@ni.com \
    --to=julia@ni.com \
    --cc=bigeasy@linutronix.de \
    --cc=gratian.crisan@ni.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable-rt@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).