From: Ingo Molnar <mingo@elte.hu>
To: Esben Nielsen <simlo@phys.au.dk>
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>,
dipankar@in.ibm.com, shemminger@osdl.org, akpm@osdl.org,
torvalds@osdl.org, rusty@au1.ibm.com, tgall@us.ibm.com,
jim.houston@comcast.net, manfred@colorfullife.com, gh@us.ibm.com,
linux-kernel@vger.kernel.org
Subject: Re: Real-Time Preemption and RCU
Date: Tue, 22 Mar 2005 14:10:16 +0100 [thread overview]
Message-ID: <20050322131016.GA2674@elte.hu> (raw)
In-Reply-To: <Pine.OSF.4.05.10503221220500.25802-100000@da410.phys.au.dk>
[-- Attachment #1: Type: text/plain, Size: 783 bytes --]
* Esben Nielsen <simlo@phys.au.dk> wrote:
> > > +static inline void rcu_read_lock(void)
> > > +{
> > > + preempt_disable();
> > > + __get_cpu_var(rcu_data).active_readers++;
> > > + preempt_enable();
> > > +}
> >
> > this is buggy. Nothing guarantees that we'll do the rcu_read_unlock() on
> > the same CPU, and hence ->active_readers can get out of sync.
> >
>
> Ok, this have to be handled in the mitigration code somehow. I have already
> added an
> current->rcu_read_depth++
> so it ought to be painless. A simple solution would be not to
> mititagrate threads with rcu_read_depth!=0.
could you elaborate?
In any case, see the new PREEMPT_RCU code in the -40-07 patch (and
upwards). I've also attached a separate patch, it should apply cleanly
to 2.6.12-rc1.
Ingo
[-- Attachment #2: preempt-rcu-2.6.12-rc1-A0 --]
[-- Type: text/plain, Size: 3492 bytes --]
--- linux/kernel/rcupdate.c.orig
+++ linux/kernel/rcupdate.c
@@ -468,3 +468,36 @@ module_param(maxbatch, int, 0);
EXPORT_SYMBOL(call_rcu);
EXPORT_SYMBOL(call_rcu_bh);
EXPORT_SYMBOL(synchronize_kernel);
+
+#ifdef CONFIG_PREEMPT_RCU
+
+void rcu_read_lock(void)
+{
+ if (current->rcu_read_lock_nesting++ == 0) {
+ current->rcu_data = &get_cpu_var(rcu_data);
+ atomic_inc(¤t->rcu_data->active_readers);
+ put_cpu_var(rcu_data);
+ }
+}
+EXPORT_SYMBOL(rcu_read_lock);
+
+void rcu_read_unlock(void)
+{
+ int cpu;
+
+ if (--current->rcu_read_lock_nesting == 0) {
+ atomic_dec(¤t->rcu_data->active_readers);
+ /*
+ * Check whether we have reached quiescent state.
+ * Note! This is only for the local CPU, not for
+ * current->rcu_data's CPU [which typically is the
+ * current CPU, but may also be another CPU].
+ */
+ cpu = get_cpu();
+ rcu_qsctr_inc(cpu);
+ put_cpu();
+ }
+}
+EXPORT_SYMBOL(rcu_read_unlock);
+
+#endif
--- linux/include/linux/rcupdate.h.orig
+++ linux/include/linux/rcupdate.h
@@ -99,6 +99,9 @@ struct rcu_data {
struct rcu_head *donelist;
struct rcu_head **donetail;
int cpu;
+#ifdef CONFIG_PREEMPT_RCU
+ atomic_t active_readers;
+#endif
};
DECLARE_PER_CPU(struct rcu_data, rcu_data);
@@ -115,12 +118,18 @@ extern struct rcu_ctrlblk rcu_bh_ctrlblk
static inline void rcu_qsctr_inc(int cpu)
{
struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
- rdp->passed_quiesc = 1;
+#ifdef CONFIG_PREEMPT_RCU
+ if (!atomic_read(&rdp->active_readers))
+#endif
+ rdp->passed_quiesc = 1;
}
static inline void rcu_bh_qsctr_inc(int cpu)
{
struct rcu_data *rdp = &per_cpu(rcu_bh_data, cpu);
- rdp->passed_quiesc = 1;
+#ifdef CONFIG_PREEMPT_RCU
+ if (!atomic_read(&rdp->active_readers))
+#endif
+ rdp->passed_quiesc = 1;
}
static inline int __rcu_pending(struct rcu_ctrlblk *rcp,
@@ -183,14 +192,22 @@ static inline int rcu_pending(int cpu)
*
* It is illegal to block while in an RCU read-side critical section.
*/
-#define rcu_read_lock() preempt_disable()
+#ifdef CONFIG_PREEMPT_RCU
+ extern void rcu_read_lock(void);
+#else
+# define rcu_read_lock preempt_disable()
+#endif
/**
* rcu_read_unlock - marks the end of an RCU read-side critical section.
*
* See rcu_read_lock() for more information.
*/
-#define rcu_read_unlock() preempt_enable()
+#ifdef CONFIG_PREEMPT_RCU
+ extern void rcu_read_unlock(void);
+#else
+# define rcu_read_unlock preempt_enable()
+#endif
/*
* So where is rcu_write_lock()? It does not exist, as there is no
@@ -213,14 +230,16 @@ static inline int rcu_pending(int cpu)
* can use just rcu_read_lock().
*
*/
-#define rcu_read_lock_bh() local_bh_disable()
+//#define rcu_read_lock_bh() local_bh_disable()
+#define rcu_read_lock_bh() { rcu_read_lock(); local_bh_disable(); }
/*
* rcu_read_unlock_bh - marks the end of a softirq-only RCU critical section
*
* See rcu_read_lock_bh() for more information.
*/
-#define rcu_read_unlock_bh() local_bh_enable()
+//#define rcu_read_unlock_bh() local_bh_enable()
+#define rcu_read_unlock_bh() { local_bh_enable(); rcu_read_unlock(); }
/**
* rcu_dereference - fetch an RCU-protected pointer in an
--- linux/include/linux/sched.h.orig
+++ linux/include/linux/sched.h
@@ -727,6 +872,10 @@ struct task_struct {
nodemask_t mems_allowed;
int cpuset_mems_generation;
#endif
+#ifdef CONFIG_PREEMPT_RCU
+ int rcu_read_lock_nesting;
+ struct rcu_data *rcu_data;
+#endif
};
static inline pid_t process_group(struct task_struct *tsk)
next prev parent reply other threads:[~2005-03-22 13:11 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-18 0:20 Real-Time Preemption and RCU Paul E. McKenney
2005-03-18 7:49 ` Ingo Molnar
2005-03-18 16:43 ` Paul E. McKenney
2005-03-18 17:11 ` Ingo Molnar
2005-03-18 17:29 ` Paul E. McKenney
2005-03-18 20:35 ` Paul E. McKenney
2005-03-18 22:22 ` Paul E. McKenney
2005-03-19 0:48 ` Paul E. McKenney
2005-03-18 8:44 ` Ingo Molnar
2005-03-18 9:04 ` Ingo Molnar
2005-03-18 9:38 ` Ingo Molnar
2005-03-18 9:13 ` Ingo Molnar
2005-03-18 9:28 ` Ingo Molnar
2005-03-18 9:53 ` Ingo Molnar
2005-03-18 15:33 ` Paul E. McKenney
2005-03-19 5:03 ` Manfred Spraul
2005-03-19 16:26 ` Ingo Molnar
2005-03-20 6:36 ` Manfred Spraul
2005-03-20 9:25 ` Thomas Gleixner
2005-03-20 16:57 ` Manfred Spraul
2005-03-20 21:38 ` Bill Huey
2005-03-20 21:59 ` Bill Huey
2005-03-18 10:03 ` Ingo Molnar
2005-03-18 11:30 ` Ingo Molnar
2005-03-18 16:48 ` Esben Nielsen
2005-03-18 17:19 ` Ingo Molnar
2005-03-20 13:29 ` Esben Nielsen
2005-03-20 22:38 ` Paul E. McKenney
2005-03-20 23:23 ` Esben Nielsen
2005-03-22 5:53 ` Paul E. McKenney
2005-03-22 8:55 ` Esben Nielsen
2005-03-22 9:20 ` Ingo Molnar
2005-03-22 10:19 ` Esben Nielsen
2005-03-23 5:40 ` Paul E. McKenney
2005-03-23 11:44 ` Esben Nielsen
2005-03-24 7:02 ` Paul E. McKenney
2005-03-22 10:56 ` Ingo Molnar
2005-03-22 11:39 ` Esben Nielsen
2005-03-22 13:10 ` Ingo Molnar [this message]
2005-03-22 15:08 ` Esben Nielsen
2005-03-18 15:48 ` Paul E. McKenney
2005-03-18 11:38 ` Ingo Molnar
2005-03-18 12:56 ` Bill Huey
2005-03-18 13:17 ` Bill Huey
2005-03-18 15:57 ` Paul E. McKenney
2005-03-18 16:02 ` Ingo Molnar
2005-03-18 16:55 ` Esben Nielsen
2005-03-22 10:04 ` Bill Huey
2005-03-22 10:17 ` Bill Huey
2005-03-22 10:34 ` Bill Huey
2005-03-22 10:38 ` Esben Nielsen
2005-03-18 22:26 ` Herbert Xu
2005-03-19 16:31 ` Ingo Molnar
2005-03-20 8:01 ` Kyle Moffett
2005-03-22 8:08 ` Ingo Molnar
2005-03-18 15:54 ` Paul E. McKenney
2005-03-18 15:58 ` Ingo Molnar
-- strict thread matches above, loose matches on Subject: below --
2009-06-11 22:57 real-time preemption " James Huang
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=20050322131016.GA2674@elte.hu \
--to=mingo@elte.hu \
--cc=akpm@osdl.org \
--cc=dipankar@in.ibm.com \
--cc=gh@us.ibm.com \
--cc=jim.houston@comcast.net \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=paulmck@us.ibm.com \
--cc=rusty@au1.ibm.com \
--cc=shemminger@osdl.org \
--cc=simlo@phys.au.dk \
--cc=tgall@us.ibm.com \
--cc=torvalds@osdl.org \
/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