From: Joel Fernandes <joel@joelfernandes.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "Paul E. McKenney" <paulmck@linux.ibm.com>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Amol Grover <frextrite@gmail.com>
Subject: Re: [for-next][PATCH 4/4] ftrace: Add comment to why rcu_dereference_sched() is open coded
Date: Wed, 5 Feb 2020 11:08:24 -0500 [thread overview]
Message-ID: <20200205160824.GH142103@google.com> (raw)
In-Reply-To: <20200205104945.4a6f85de@oasis.local.home>
On Wed, Feb 05, 2020 at 10:49:45AM -0500, Steven Rostedt wrote:
> On Wed, 5 Feb 2020 10:42:12 -0500
> Joel Fernandes <joel@joelfernandes.org> wrote:
>
> > On Wed, Feb 05, 2020 at 09:28:47AM -0500, Steven Rostedt wrote:
> > > On Wed, 5 Feb 2020 09:19:15 -0500
> > > Joel Fernandes <joel@joelfernandes.org> wrote:
> > >
> > > > Could you paste the stack here when RCU is not watching? In trace event code
> > > > IIRC we call rcu_enter_irqs_on() to have RCU temporarily watch, since that
> > > > code can be called from idle loop. Should we doing the same here as well?
> > >
> > > Unfortunately I lost the stack trace. And the last time we tried to use
> > > rcu_enter_irqs_on() for ftrace, we couldn't find a way to do this
> > > properly. Ftrace is much more invasive then going into idle. The
> > > problem is that ftrace traces RCU itself, and calling
> > > "rcu_enter_irqs_on()" in pretty much any place in the RCU code caused
> > > lots of bugs ;-)
> > >
> > > This is why we have the schedule_on_each_cpu(ftrace_sync) hack.
> >
> > The "schedule a task on each CPU" trick works on !PREEMPT though right?
>
> It works on both, as I care more about the PREEMPT=y case then
> the !PREEMPT, and the PREEMPT_RT which is even more preemptive than
> PREEMPT!
>
> >
> > Because it is possible in PREEMPT=y to get preempted in the middle of a
> > read-side critical section, switch to the worker thread executing the
> > ftrace_sync() and then switch back. But RCU still has to watch that CPU since
> > the read-side critical section was not completed.
> >
> > Or is there a subtlety here with ftrace that I missed?
> >
>
> Hence Amol's patch:
>
> > + notrace_hash = rcu_dereference_protected(ftrace_graph_notrace_hash,
> > + !preemptible());
>
> It checks to make sure preemption is off. There is no chance of being
> preempted in the read side critical section.
Yes, this makes sense. Sorry for the noise. For "sched" RCU cases,
scheduling on each CPU would work regardless of PREEMPT configuration.
( I guess I was confusing this case with the non-sched RCU usages (such as using
rcu_read_lock()) where scheduling a task on each CPU obviously would not work
with PREEMPT=y. )
By the way would SRCU not work instead of the ftrace_sync() technique? Or is
the concern that SRCU cannot be used from NMI?
thanks,
- Joel
next prev parent reply other threads:[~2020-02-05 16:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-05 10:49 [for-next][PATCH 0/4] tracing: Hopefully last update for 5.6 Steven Rostedt
2020-02-05 10:49 ` [for-next][PATCH 1/4] bootconfig: Only load bootconfig if "bootconfig" is on the kernel cmdline Steven Rostedt
2020-02-05 10:49 ` [for-next][PATCH 2/4] tracing: Annotate ftrace_graph_hash pointer with __rcu Steven Rostedt
2020-02-05 10:49 ` [for-next][PATCH 3/4] tracing: Annotate ftrace_graph_notrace_hash " Steven Rostedt
2020-02-05 10:49 ` [for-next][PATCH 4/4] ftrace: Add comment to why rcu_dereference_sched() is open coded Steven Rostedt
2020-02-05 11:33 ` Steven Rostedt
2020-02-05 14:19 ` Joel Fernandes
2020-02-05 14:28 ` Steven Rostedt
2020-02-05 15:42 ` Joel Fernandes
2020-02-05 15:49 ` Steven Rostedt
2020-02-05 16:08 ` Joel Fernandes [this message]
2020-02-05 21:54 ` Joel Fernandes
2020-02-05 21:59 ` Joel Fernandes
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=20200205160824.GH142103@google.com \
--to=joel@joelfernandes.org \
--cc=akpm@linux-foundation.org \
--cc=frextrite@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@linux.ibm.com \
--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