From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
rostedt <rostedt@goodmis.org>
Subject: Re: Possible use of RCU while in extended QS: idle vs RCU read-side in interrupt vs rcu_eqs_exit
Date: Thu, 10 Jan 2019 06:19:38 -0800 [thread overview]
Message-ID: <20190110141938.GI1215@linux.ibm.com> (raw)
In-Reply-To: <219114011.864.1547101805680.JavaMail.zimbra@efficios.com>
On Thu, Jan 10, 2019 at 01:30:05AM -0500, Mathieu Desnoyers wrote:
> ----- On Jan 9, 2019, at 8:13 PM, paulmck paulmck@linux.ibm.com wrote:
>
> > On Wed, Jan 09, 2019 at 08:38:51PM -0500, Mathieu Desnoyers wrote:
> >> Hi Paul,
> >>
> >> I've had a user report that trace_sched_waking() appears to be
> >> invoked while !rcu_is_watching() in some situation, so I started
> >> digging into the scheduler idle code.
> >>
> >> It appears that interrupts are re-enabled before rcu_eqs_exit() is
> >> invoked when exiting idle code from the scheduler.
> >>
> >> I wonder what happens if an interrupt handler (including scheduler code)
> >> happens to issue a RCU read-side critical section before rcu_eqs_exit()
> >> is called ? Is there some code on interrupt entry that ensures rcu eqs
> >> state is exited in such scenario ?
> >
> > Interrupt handlers are supposed to invoke irq_enter(), which will in
> > turn invoke rcu_irq_enter(), which should take care of things.
> >
> > However, there are cases where a given architecture knows that a given
> > interrupt handler does not contain RCU readers, and in this case, the
> > architecture might omit the rcu_irq_enter() or maybe even the whole
> > irq_enter(). And then it is all fun and games until someone adds an
> > RCU read-side critical section. ;-)
>
> Even if an irq handler does not contain any RCU read-side critical
> section, won't it end by possibly invoking the scheduler before
> returning ? Considering that the scheduler has tracepoints which
> use RCU, this might be related to the issue that has been brought
> to my attention.
Most interrupt handlers just return, but yes, scheduler state is often
checked during return from interrupt. But in that case, the interrupt
handler needs to have invoked irq_enter().
> Do you have examples of such interrupt handlers which do not invoke
> rcu_irq_enter() ?
Mostly examples of lightweight interrupts handlers that used to not invoke
irq_enter() and thus not rcu_irq_enter(), but which later started using
RCU readers. Which means that they are no longer examples that do not
invoke rcu_irq_enter(). ;-)
Some of them just invoked rcu_irq_enter(), others had to do the full
irq_enter() call (which in turn invokes rcu_irq_enter()).
These interrupt handlers were very light-weight. Page-table walkers,
hardware events, and the like. Take an interrupt, look at a hardware
register, update a data structure, maybe write to a hardware register,
return from interrupt.
If there is only one such tracepoint, one approach is to use _rcuidle,
that is, instead of trace_blarvitz(), trace_blarvitz_rcuidle(). This can
add overhead, so this might not be appropriate for any of the scheduler's
fastpaths. Which brings me back to the interrupt handler invoking
either irq_enter() or rcu_irq_enter(). Or moving the tracepoints to
a nearby region of code that RCU is already watching.
So, is it reasonably to add the rcu_irq_enter()? If you do change this,
please test with CONFIG_RCU_EQS_DEBUG=y.
Thanx, Paul
next prev parent reply other threads:[~2019-01-10 14:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 1:38 Possible use of RCU while in extended QS: idle vs RCU read-side in interrupt vs rcu_eqs_exit Mathieu Desnoyers
2019-01-10 4:13 ` Paul E. McKenney
2019-01-10 6:30 ` Mathieu Desnoyers
2019-01-10 14:19 ` Paul E. McKenney [this message]
2019-01-10 16:08 ` Steven Rostedt
2019-01-10 16:44 ` Mathieu Desnoyers
2019-01-10 17:11 ` Mathieu Desnoyers
2019-01-10 17:23 ` Steven Rostedt
2019-01-10 17:25 ` Mathieu Desnoyers
2019-01-10 17:45 ` Perf: event wakeup discards sched_waking events Mathieu Desnoyers
2019-01-14 13:09 ` Peter Zijlstra
2019-01-14 21:36 ` Mathieu Desnoyers
2019-01-14 22:04 ` Steven Rostedt
2019-01-14 22:31 ` Mathieu Desnoyers
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=20190110141938.GI1215@linux.ibm.com \
--to=paulmck@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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