From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Yong Zhang <yong.zhang0@gmail.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
laijs@cn.fujitsu.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca,
josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de,
peterz@infradead.org, rostedt@goodmis.org,
Valdis.Kletnieks@vt.edu, dhowells@redhat.com,
eric.dumazet@gmail.com, darren@dvhart.com, patches@linaro.org,
"Paul E. McKenney" <paul.mckenney@linaro.org>
Subject: Re: [PATCH tip/core/rcu 41/55] rcu: Permit rt_mutex_unlock() with irqs disabled
Date: Tue, 20 Sep 2011 07:57:54 -0700 [thread overview]
Message-ID: <20110920145754.GB2380@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAM2zO=B3FM3QrTB7yCTEoUZ5tF2734s8VEzgBnXLJK1uWkZdFA@mail.gmail.com>
On Mon, Sep 19, 2011 at 01:49:33PM +0800, Yong Zhang wrote:
> On Mon, Sep 19, 2011 at 12:14 PM, Paul E. McKenney
> <paulmck@linux.vnet.ibm.com> wrote:
> > On Sun, Sep 18, 2011 at 12:09:23PM +0800, Yong Zhang wrote:
> >> > diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
> >> > index d3127e8..f6c63ea 100644
> >> > --- a/kernel/rcutree_plugin.h
> >> > +++ b/kernel/rcutree_plugin.h
> >> > @@ -1149,6 +1149,8 @@ static void rcu_initiate_boost_trace(struct rcu_node *rnp)
> >> >
> >> > #endif /* #else #ifdef CONFIG_RCU_TRACE */
> >> >
> >> > +static struct lock_class_key rcu_boost_class;
> >> > +
> >> > /*
> >> > * Carry out RCU priority boosting on the task indicated by ->exp_tasks
> >> > * or ->boost_tasks, advancing the pointer to the next task in the
> >> > @@ -1211,10 +1213,14 @@ static int rcu_boost(struct rcu_node *rnp)
> >> > */
> >> > t = container_of(tb, struct task_struct, rcu_node_entry);
> >> > rt_mutex_init_proxy_locked(&mtx, t);
> >> > + /* Avoid lockdep false positives. This rt_mutex is its own thing. */
> >> > + lockdep_set_class_and_name(&mtx.wait_lock, &rcu_boost_class,
> >> > + "rcu_boost_mutex");
> >> > t->rcu_boost_mutex = &mtx;
> >>
> >> raw_spin_unlock_irqrestore(&rnp->lock, flags); <====A
> >>
> >> > rt_mutex_lock(&mtx); /* Side effect: boosts task t's priority. */
> >> > rt_mutex_unlock(&mtx); /* Keep lockdep happy. */
> >> > + local_irq_restore(flags);
> >>
> >> Does it help here?
> >> irq is enabled at A. So we still call rt_mutex_lock() with irq enabled.
> >>
> >> Seems should s/raw_spin_unlock_irqrestore/raw_spin_unlock ?
> >
> > Hmmm... The above works at least by accident, but I am clearly not
> > testing calling rt_mutex_lock(&mtx) and rt_mutex_unlock(&mtx) with
> > interrupts disabled anywhere near as heavily as I thought I was.
> >
> > I will fix this one way or the other.
>
> Forget to mention: if we want to suppress the lockdep warning on
> overlapping usage of rcu_read_*()/local_irq_*() like below:
>
> rcu_read_lock();
> ...
> local_irq_disable();
> ...
> rcu_read_unlock();
> ...
> local_irq_enable();
>
> 'rt_mutex_unlock(rbmp);' must also be surrounded by
> local_irq_irqsave()/restore().
>
> Untested patch is attached.
What I am doing for 3.2 (given that the merge window is likely very soon)
is removing the redundant local_irq_restore(). For 3.3, I will apply
something like your patch below to rcu_boost(), and will think about
what (if anything) to do about rcu_read_unlock_special(). With your
Signed-off-by either way, of course.
Thanx, Paul
> Thanks,
> Yong
>
> ---
> From: Yong Zhang <yong.zhang0@gmail.com>
> Subject: [PATCH] rcu: Permit rt_mutex_unlock() with irqs disabled take#2
>
> This make the below rcu usage really valid(AKA: lockdep
> will not warn on it):
>
> rcu_read_lock();
> local_irq_disable();
> rcu_read_unlock();
> local_irq_enable();
>
> Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
> ---
> kernel/rcutree_plugin.h | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
> index e7eea74..d41a9b0 100644
> --- a/kernel/rcutree_plugin.h
> +++ b/kernel/rcutree_plugin.h
> @@ -398,8 +398,11 @@ static noinline void
> rcu_read_unlock_special(struct task_struct *t)
>
> #ifdef CONFIG_RCU_BOOST
> /* Unboost if we were boosted. */
> - if (rbmp)
> + if (rbmp) {
> + local_irq_save(flags);
> rt_mutex_unlock(rbmp);
> + local_irq_restore(flags);
> + }
> #endif /* #ifdef CONFIG_RCU_BOOST */
>
> /*
> @@ -1225,7 +1228,7 @@ static int rcu_boost(struct rcu_node *rnp)
> lockdep_set_class_and_name(&mtx.wait_lock, &rcu_boost_class,
> "rcu_boost_mutex");
> t->rcu_boost_mutex = &mtx;
> - raw_spin_unlock_irqrestore(&rnp->lock, flags);
> + raw_spin_unlock(&rnp->lock);
> rt_mutex_lock(&mtx); /* Side effect: boosts task t's priority. */
> rt_mutex_unlock(&mtx); /* Keep lockdep happy. */
> local_irq_restore(flags);
> --
> 1.7.4.1
> From 7d74d1b89a4cd4c03b30e47044b716913f68bd1d Mon Sep 17 00:00:00 2001
> From: Yong Zhang <yong.zhang0@gmail.com>
> Date: Mon, 19 Sep 2011 13:42:32 +0800
> Subject: [PATCH] rcu: Permit rt_mutex_unlock() with irqs disabled take#2
>
> This make the below rcu usage really valid(AKA: lockdep
> will not warn on it):
>
> rcu_read_lock();
> local_irq_disable();
> rcu_read_unlock();
> local_irq_enable();
>
> Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
> ---
> kernel/rcutree_plugin.h | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
> index e7eea74..d41a9b0 100644
> --- a/kernel/rcutree_plugin.h
> +++ b/kernel/rcutree_plugin.h
> @@ -398,8 +398,11 @@ static noinline void rcu_read_unlock_special(struct task_struct *t)
>
> #ifdef CONFIG_RCU_BOOST
> /* Unboost if we were boosted. */
> - if (rbmp)
> + if (rbmp) {
> + local_irq_save(flags);
> rt_mutex_unlock(rbmp);
> + local_irq_restore(flags);
> + }
> #endif /* #ifdef CONFIG_RCU_BOOST */
>
> /*
> @@ -1225,7 +1228,7 @@ static int rcu_boost(struct rcu_node *rnp)
> lockdep_set_class_and_name(&mtx.wait_lock, &rcu_boost_class,
> "rcu_boost_mutex");
> t->rcu_boost_mutex = &mtx;
> - raw_spin_unlock_irqrestore(&rnp->lock, flags);
> + raw_spin_unlock(&rnp->lock);
> rt_mutex_lock(&mtx); /* Side effect: boosts task t's priority. */
> rt_mutex_unlock(&mtx); /* Keep lockdep happy. */
> local_irq_restore(flags);
> --
> 1.7.4.1
>
next prev parent reply other threads:[~2011-09-20 15:08 UTC|newest]
Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-06 18:00 [PATCH tip/core/rcu 0/55] Preview of RCU changes for 3.2 Paul E. McKenney
2011-09-06 17:59 ` [PATCH tip/core/rcu 01/55] rcu: Use kthread_create_on_node() Paul E. McKenney
2011-09-06 17:59 ` [PATCH tip/core/rcu 02/55] rcu: Avoid unnecessary self-wakeup of per-CPU kthreads Paul E. McKenney
2011-09-06 17:59 ` [PATCH tip/core/rcu 03/55] rcu: Update documentation to flag RCU_BOOST trace information Paul E. McKenney
2011-09-06 17:59 ` [PATCH tip/core/rcu 04/55] rcu: Restore checks for blocking in RCU read-side critical sections Paul E. McKenney
2011-09-06 17:59 ` [PATCH tip/core/rcu 05/55] rcu: Move rcu_head definition to types.h Paul E. McKenney
2011-09-07 18:31 ` Paul Gortmaker
2011-09-07 22:11 ` Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 06/55] rcu: Update rcutorture documentation Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 07/55] rcu: Fix mismatched variable in rcutree_trace.c Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 08/55] rcu: Abstract common code for RCU grace-period-wait primitives Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 09/55] rcu: Catch rcutorture up to new RCU API additions Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 10/55] rcu: Fix RCU's NMI documentation Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 11/55] rcu: Drive configuration directly from SMP and PREEMPT Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 12/55] rcu: Fix pathnames in documentation Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 13/55] rcu: Don't destroy rcu_torture_boost() callback until it is done Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 14/55] rcu: Add event-tracing for RCU callback invocation Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 15/55] rcu: Event-trace markers for computing RCU CPU utilization Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 16/55] rcu: Put names into TINY_RCU structures under RCU_TRACE Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 17/55] rcu: Add RCU type to callback-invocation tracing Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 18/55] rcu: Update comments to reflect softirqs vs. kthreads Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 19/55] rcu: Move RCU_BOOST declarations to allow compiler checking Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 20/55] rcu: Add event-trace markers to TREE_RCU kthreads Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 21/55] rcu: Make TINY_RCU also use softirq for RCU_BOOST=n Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 22/55] rcu: Add grace-period, quiescent-state, and call_rcu trace events Paul E. McKenney
2011-10-17 1:33 ` Josh Triplett
2011-10-24 12:02 ` Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 23/55] rcu: Simplify quiescent-state accounting Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 24/55] rcu: Not necessary to pass rcu_read_lock_held() to rcu_dereference_protected() Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 25/55] rcu: Update documentation for additional RCU lockdep functions Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 26/55] rcu: Remove unused and redundant interfaces Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 27/55] rcu: Allow rcutorture's stat_interval parameter to be changed at runtime Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 28/55] rcu: Document interpretation of RCU-lockdep splats Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 29/55] nohz: Remove nohz_cpu_mask Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 30/55] rcu: Eliminate in_irq() checks in rcu_enter_nohz() Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 31/55] rcu: Make rcu_implicit_dynticks_qs() locals be correct size Paul E. McKenney
2011-10-17 1:43 ` Josh Triplett
2011-10-24 12:00 ` Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 32/55] rcu: Make rcu_assign_pointer() unconditionally insert a memory barrier Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 33/55] rcu: Improve rcu_assign_pointer() and RCU_INIT_POINTER() documentation Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 34/55] rcu: Move __rcu_read_unlock()'s barrier() within if-statement Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 35/55] rcu: Dump local stack if cannot dump all CPUs' stacks Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 36/55] rcu: Prevent early boot set_need_resched() from __rcu_pending() Paul E. McKenney
2011-10-17 1:49 ` Josh Triplett
2011-10-24 12:07 ` Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 37/55] rcu: Simplify unboosting checks Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 38/55] rcu: Prohibit grace periods during early boot Paul E. McKenney
2011-10-17 1:51 ` Josh Triplett
2011-09-06 18:00 ` [PATCH tip/core/rcu 39/55] rcu: Suppress NMI backtraces when stall ends before dump Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 40/55] rcu: Avoid having just-onlined CPU resched itself when RCU is idle Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 41/55] rcu: Permit rt_mutex_unlock() with irqs disabled Paul E. McKenney
2011-09-18 4:09 ` Yong Zhang
2011-09-19 4:14 ` Paul E. McKenney
2011-09-19 5:49 ` Yong Zhang
2011-09-20 14:57 ` Paul E. McKenney [this message]
2011-09-06 18:00 ` [PATCH tip/core/rcu 42/55] rcu: Make rcu_torture_fqs() exit loops at end of test Paul E. McKenney
2011-10-17 1:53 ` Josh Triplett
2011-10-24 12:10 ` Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 43/55] rcu: Make rcu_torture_boost() " Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 44/55] rcu: wire up RCU_BOOST_PRIO for rcutree Paul E. McKenney
2011-09-13 12:02 ` Mike Galbraith
2011-09-13 15:34 ` Paul E. McKenney
2011-09-13 16:04 ` Mike Galbraith
2011-09-13 20:50 ` Paul E. McKenney
2011-10-17 1:55 ` Josh Triplett
2011-09-06 18:00 ` [PATCH tip/core/rcu 45/55] rcu: check for entering dyntick-idle mode while in read-side critical section Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 46/55] rcu: Remove rcu_needs_cpu_flush() to avoid false quiescent states Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 47/55] rcu: Move propagation of ->completed from rcu_start_gp() to rcu_report_qs_rsp() Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 48/55] powerpc: strengthen value-returning-atomics memory barriers Paul E. McKenney
2011-09-09 17:23 ` Olof Johansson
2011-09-09 17:34 ` Paul E. McKenney
2011-09-09 18:43 ` Olof Johansson
2011-09-06 18:00 ` [PATCH tip/core/rcu 49/55] rcu: Detect illegal rcu dereference in extended quiescent state Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 50/55] rcu: Inform the user about dynticks-idle mode on PROVE_RCU warning Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 51/55] rcu: Warn when rcu_read_lock() is used in extended quiescent state Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 52/55] rcu: Remove one layer of abstraction from PROVE_RCU checking Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 53/55] rcu: Warn when srcu_read_lock() is used in an extended quiescent state Paul E. McKenney
2011-10-04 21:03 ` Frederic Weisbecker
2011-10-04 23:40 ` Paul E. McKenney
2011-10-04 23:42 ` Frederic Weisbecker
2011-09-06 18:00 ` [PATCH tip/core/rcu 54/55] rcu: Make srcu_read_lock_held() call common lockdep-enabled function Paul E. McKenney
2011-10-17 2:03 ` Josh Triplett
2011-10-24 12:34 ` Paul E. McKenney
2011-09-06 18:00 ` [PATCH tip/core/rcu 55/55] powerpc: Work around tracing from dyntick-idle mode Paul E. McKenney
2011-09-07 10:00 ` Benjamin Herrenschmidt
2011-09-07 13:44 ` Paul E. McKenney
2011-09-13 19:13 ` Frederic Weisbecker
2011-09-13 19:50 ` Paul E. McKenney
2011-09-13 20:49 ` Benjamin Herrenschmidt
2011-09-15 14:53 ` Frederic Weisbecker
2011-09-16 12:24 ` Frederic Weisbecker
2011-09-07 14:39 ` [PATCH tip/core/rcu 0/55] Preview of RCU changes for 3.2 Lin Ming
2011-09-08 17:41 ` Paul E. McKenney
2011-09-08 19:23 ` Thomas Gleixner
2011-09-08 20:48 ` Paul E. McKenney
2011-09-12 16:24 ` Paul E. McKenney
2011-10-17 2:06 ` Josh Triplett
2011-10-24 12:35 ` Paul E. McKenney
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=20110920145754.GB2380@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=Valdis.Kletnieks@vt.edu \
--cc=akpm@linux-foundation.org \
--cc=darren@dvhart.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=eric.dumazet@gmail.com \
--cc=josh@joshtriplett.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=niv@us.ibm.com \
--cc=patches@linaro.org \
--cc=paul.mckenney@linaro.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=yong.zhang0@gmail.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).