Re: [PATCH v2] tracing/perf: Move rcu_irq_enter/exit_irqson() to perf trace point hook
From: Peter Zijlstra
Date: Tue Feb 11 2020 - 10:47:08 EST
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.