From: Paul Gortmaker <paul.gortmaker@windriver.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: <linux-kernel@vger.kernel.org>,
linux-rt-users <linux-rt-users@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Carsten Emde <C.Emde@osadl.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clark.williams@gmail.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [RFC][PATCH RT 6/6] vtime: Convert vtime_seqlock into raw_spinlock_t and seqcount combo
Date: Wed, 10 Jul 2013 13:12:13 -0400 [thread overview]
Message-ID: <20130710171212.GA13553@windriver.com> (raw)
In-Reply-To: <20130626193050.529670718@goodmis.org>
[[RFC][PATCH RT 6/6] vtime: Convert vtime_seqlock into raw_spinlock_t and seqcount combo] On 26/06/2013 (Wed 15:28) Steven Rostedt wrote:
> The vtime seqlock needs to be taken in true interrupt context on -rt.
> The normal seqlocks are converted to mutexes when PREEMPT_RT_FULL is
> enabled, which will break the vtime code as the calls are done from
> interrupt context.
>
> Convert the vtime seqlock into the raw_spinlock_t and seqcount combo
> that can be done in interrupt context.
Alternatively, we could revive the raw seqlock patch from Thomas?
https://lkml.org/lkml/2010/2/17/238
Below is a version updating it to 3.8.x-RT. One downside is that
current mainline kernels have raw_seqcount_begin() function, which has
nothing to do with preempt-rt, so the seqcount function namespace can
get confusing unless we rename raw_seqcount_begin to something that
doesn't sound RT-ish.
Paul.
--
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index 939ea1a..5a3f6fd 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -185,6 +185,11 @@ static inline void write_seqcount_barrier(seqcount_t *s)
typedef struct {
struct seqcount seqcount;
+ raw_spinlock_t lock;
+} raw_seqlock_t;
+
+typedef struct {
+ struct seqcount seqcount;
spinlock_t lock;
} seqlock_t;
@@ -192,6 +197,21 @@ typedef struct {
* These macros triggered gcc-3.x compile-time problems. We think these are
* OK now. Be cautious.
*/
+#define __RAW_SEQLOCK_UNLOCKED(lockname) \
+ { \
+ .seqcount = SEQCNT_ZERO, \
+ .lock = __RAW_SPIN_LOCK_UNLOCKED(lockname) \
+ }
+
+#define raw_seqlock_init(x) \
+ do { \
+ seqcount_init(&(x)->seqcount); \
+ raw_spin_lock_init(&(x)->lock); \
+ } while (0)
+
+#define DEFINE_RAW_SEQLOCK(x) \
+ raw_seqlock_t x = __RAW_SEQLOCK_UNLOCKED(x)
+
#define __SEQLOCK_UNLOCKED(lockname) \
{ \
.seqcount = SEQCNT_ZERO, \
@@ -210,6 +230,11 @@ typedef struct {
/*
* Read side functions for starting and finalizing a read side section.
*/
+static inline unsigned read_raw_seqbegin(const raw_seqlock_t *sl)
+{
+ return read_seqcount_begin(&sl->seqcount);
+}
+
#ifndef CONFIG_PREEMPT_RT_FULL
static inline unsigned read_seqbegin(const seqlock_t *sl)
{
@@ -238,6 +263,11 @@ repeat:
}
#endif
+static inline unsigned read_raw_seqretry(const raw_seqlock_t *sl, unsigned start)
+{
+ return read_seqcount_retry(&sl->seqcount, start);
+}
+
static inline unsigned read_seqretry(const seqlock_t *sl, unsigned start)
{
return read_seqcount_retry(&sl->seqcount, start);
@@ -248,6 +278,64 @@ static inline unsigned read_seqretry(const seqlock_t *sl, unsigned start)
* Acts like a normal spin_lock/unlock.
* Don't need preempt_disable() because that is in the spin_lock already.
*/
+static inline void write_raw_seqlock(raw_seqlock_t *sl)
+{
+ raw_spin_lock(&sl->lock);
+ __write_seqcount_begin(&sl->seqcount);
+}
+
+static inline void write_raw_sequnlock(raw_seqlock_t *sl)
+{
+ __write_seqcount_end(&sl->seqcount);
+ raw_spin_unlock(&sl->lock);
+}
+
+static inline void write_raw_seqlock_bh(raw_seqlock_t *sl)
+{
+ raw_spin_lock_bh(&sl->lock);
+ __write_seqcount_begin(&sl->seqcount);
+}
+
+static inline void write_raw_sequnlock_bh(raw_seqlock_t *sl)
+{
+ __write_seqcount_end(&sl->seqcount);
+ raw_spin_unlock_bh(&sl->lock);
+}
+
+static inline void write_raw_seqlock_irq(raw_seqlock_t *sl)
+{
+ raw_spin_lock_irq(&sl->lock);
+ __write_seqcount_begin(&sl->seqcount);
+}
+
+static inline void write_raw_sequnlock_irq(raw_seqlock_t *sl)
+{
+ __write_seqcount_end(&sl->seqcount);
+ raw_spin_unlock_irq(&sl->lock);
+}
+
+static inline unsigned long __write_raw_seqlock_irqsave(raw_seqlock_t *sl)
+{
+ unsigned long flags;
+
+ raw_spin_lock_irqsave(&sl->lock, flags);
+ __write_seqcount_begin(&sl->seqcount);
+ return flags;
+}
+
+#define write_raw_seqlock_irqsave(lock, flags) \
+ do { flags = __write_raw_seqlock_irqsave(lock); } while (0)
+
+static inline void
+write_raw_sequnlock_irqrestore(raw_seqlock_t *sl, unsigned long flags)
+{
+ __write_seqcount_end(&sl->seqcount);
+ raw_spin_unlock_irqrestore(&sl->lock, flags);
+}
+
+/*
+ * non raw versions
+ */
static inline void write_seqlock(seqlock_t *sl)
{
spin_lock(&sl->lock);
next prev parent reply other threads:[~2013-07-10 17:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-26 19:28 [RFC][PATCH RT 0/6] rt: Updates to handle some 3.10 changes Steven Rostedt
2013-06-26 19:28 ` [RFC][PATCH RT 1/6] rt,rcu: Have rcu_read_lock_sched() use locks for PREEMPT_RT Steven Rostedt
2013-06-26 20:53 ` Paul E. McKenney
2013-06-26 21:32 ` Steven Rostedt
2013-06-27 3:52 ` Mike Galbraith
2013-06-27 11:28 ` Steven Rostedt
2013-06-26 19:28 ` [RFC][PATCH RT 2/6] workqueue: Use rcu_read_lock_sched() to denote RCU synchronize_sched() location Steven Rostedt
2013-06-26 19:28 ` [RFC][PATCH RT 3/6] idr: Use migrate_disable() to stay on the current CPU Steven Rostedt
2013-06-26 19:28 ` [RFC][PATCH RT 4/6] rt,workqueue: Add local_lock_irq() call to put_pwq_unlocked() Steven Rostedt
2013-06-26 19:28 ` [RFC][PATCH RT 5/6] rt,ntp: Move call to schedule_delayed_work() to helper thread Steven Rostedt
2013-06-26 19:28 ` [RFC][PATCH RT 6/6] vtime: Convert vtime_seqlock into raw_spinlock_t and seqcount combo Steven Rostedt
2013-07-10 17:12 ` Paul Gortmaker [this message]
2013-07-11 14:30 ` Steven Rostedt
2013-06-26 19:43 ` [RFC][PATCH RT 0.5/6] locallock: Add include of percpu.h Steven Rostedt
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=20130710171212.GA13553@windriver.com \
--to=paul.gortmaker@windriver.com \
--cc=C.Emde@osadl.org \
--cc=bigeasy@linutronix.de \
--cc=clark.williams@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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 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.