From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: rostedt <rostedt@goodmis.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
"Joel Fernandes, Google" <joel@joelfernandes.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Thomas Gleixner <tglx@linutronix.de>,
paulmck <paulmck@kernel.org>,
Josh Triplett <josh@joshtriplett.org>,
Lai Jiangshan <jiangshanlai@gmail.com>
Subject: Re: [PATCH v2] tracing/perf: Move rcu_irq_enter/exit_irqson() to perf trace point hook
Date: Tue, 11 Feb 2020 11:02:08 -0500 (EST) [thread overview]
Message-ID: <201671415.617691.1581436928433.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20200211154645.GX14914@hirez.programming.kicks-ass.net>
----- On Feb 11, 2020, at 10:46 AM, Peter Zijlstra peterz@infradead.org wrote:
> On Tue, Feb 11, 2020 at 10:34:38AM -0500, Mathieu Desnoyers wrote:
>>
>> I'm puzzled by this function. It does:
>>
>> perf_tp_event(...)
>> {
>> hlist_for_each_entry_rcu(event, head, hlist_entry) {
>> ...
>> }
>> if (task && task != current) {
>> rcu_read_lock();
>> ... = rcu_dereference();
>> list_for_each_entry_rcu(...) {
>> ....
>> }
>> rcu_read_unlock();
>> }
>> }
>>
>> What is the purpose of the rcu_read_lock/unlock within the if (),
>> considering that there is already an hlist rcu iteration just before ?
>> It seems to assume that a RCU read-side of some kind of already
>> ongoing.
>
> IIRC the hlist_for_each_entry_rcu() uses the RCU stuff from the
> tracepoint API, while the stuff inside the if() uses regular RCU.
>
> Them were note the same one -- tracepoints used rcu-sched, perf used
> rcu.
Indeed, there is a call to tracepoint_synchronize_unregister() within
perf_trace_event_unreg(), which provides the required grace period
before freeing the perf event.
That tracepoint_synchronize_unregister() was initially doing a synchronize_sched()
as you point out. It then moved to synchronize_rcu() with the RCU flavors
consolidation, and we've added the synchronize_srcu(&tracepoint_srcu) as well,
which handles the rcuidle cases.
Adding a comment in perf_tp_event() detailing how each RCU use is synchronized
might help readability, e.g.:
At top of function:
/*
* Synchronization of the perf event RCU hlist is performed by the tracepoint API.
* Synchronization of the perf event context and perf event context event list
* is performed through explicit use of RCU.
*/
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2020-02-11 16:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-11 14:50 [PATCH v2] tracing/perf: Move rcu_irq_enter/exit_irqson() to perf trace point hook Steven Rostedt
2020-02-11 15:34 ` Mathieu Desnoyers
2020-02-11 15:46 ` Peter Zijlstra
2020-02-11 16:02 ` Mathieu Desnoyers [this message]
2020-02-11 15:34 ` Peter Zijlstra
2020-02-11 16:18 ` Steven Rostedt
2020-02-11 16:27 ` Mathieu Desnoyers
2020-02-11 16:35 ` Steven Rostedt
2020-02-11 17:29 ` Peter Zijlstra
2020-02-11 17:32 ` Peter Zijlstra
2020-02-11 18:54 ` Paul E. McKenney
2020-02-12 8:05 ` Peter Zijlstra
2020-02-12 9:05 ` Paul E. McKenney
2020-02-11 17:35 ` Mathieu Desnoyers
2020-02-12 8:02 ` Peter Zijlstra
2020-02-12 15:14 ` 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=201671415.617691.1581436928433.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavo@embeddedor.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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).