From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -tip] rcu: local_irq_disable() also delimits RCU_SCHED read-site critical sections
Date: Tue, 16 Mar 2010 19:26:49 -0700 [thread overview]
Message-ID: <20100317022648.GA7049@linux.vnet.ibm.com> (raw)
In-Reply-To: <20100316132156.GC6709@linux.vnet.ibm.com>
On Tue, Mar 16, 2010 at 06:21:56AM -0700, Paul E. McKenney wrote:
> On Tue, Mar 16, 2010 at 07:09:21PM +0800, Lai Jiangshan wrote:
> > It is documented that local_irq_disable() also delimits
> > RCU_SCHED read-site critical sections.
> > See the document of synchronize_sched() or
> > Documentation/RCU/whatisRCU.txt.
> >
> > So we have to test irqs_disabled() in rcu_read_lock_sched_held().
> > Otherwise rcu-lockdep brings incorrect complaint.
>
> Interesting -- I was under the impression that preempt_count() covered
> this as well, due to the following in include/linux/hardirq.h:
>
> #define PREEMPT_MASK (__IRQ_MASK(PREEMPT_BITS) << PREEMPT_SHIFT)
> #define SOFTIRQ_MASK (__IRQ_MASK(SOFTIRQ_BITS) << SOFTIRQ_SHIFT)
> #define HARDIRQ_MASK (__IRQ_MASK(HARDIRQ_BITS) << HARDIRQ_SHIFT)
> #define NMI_MASK (__IRQ_MASK(NMI_BITS) << NMI_SHIFT)
>
> But irqs_disabled() does look to sample the actual interrupt hardware.
>
> So, if there are cases where RCU is used where the interrupt hardware
> is disabled, but preempt_count() has not been updated, this patch is
> the right thing to do.
In light of later emails in this thread, first a big "thank you!!!"
to Lai, and I will pull this one in. Good stuff!!!
Thanx, Paul
> > Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> > ---
> > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> > index 3024050..2ce5674 100644
> > --- a/include/linux/rcupdate.h
> > +++ b/include/linux/rcupdate.h
> > @@ -160,7 +160,7 @@ static inline int rcu_read_lock_sched_held(void)
> > return 1;
> > if (debug_locks)
> > lockdep_opinion = lock_is_held(&rcu_sched_lock_map);
> > - return lockdep_opinion || preempt_count() != 0;
> > + return lockdep_opinion || preempt_count() != 0 || irqs_disabled();
> > }
> > #else /* #ifdef CONFIG_PREEMPT */
> > static inline int rcu_read_lock_sched_held(void)
> > @@ -191,7 +191,7 @@ static inline int rcu_read_lock_bh_held(void)
> > #ifdef CONFIG_PREEMPT
> > static inline int rcu_read_lock_sched_held(void)
> > {
> > - return !rcu_scheduler_active || preempt_count() != 0;
> > + return !rcu_scheduler_active || preempt_count() != 0 || irqs_disabled();
> > }
> > #else /* #ifdef CONFIG_PREEMPT */
> > static inline int rcu_read_lock_sched_held(void)
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
prev parent reply other threads:[~2010-03-17 3:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-16 11:09 [PATCH -tip] rcu: local_irq_disable() also delimits RCU_SCHED read-site critical sections Lai Jiangshan
2010-03-16 11:28 ` Ingo Molnar
2010-03-16 13:21 ` Paul E. McKenney
2010-03-17 1:41 ` Lai Jiangshan
2010-03-17 2:26 ` Paul E. McKenney [this message]
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=20100317022648.GA7049@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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.