Re: [RFC 0/3] Revert SRCU from tracepoint infrastructure
From: Mathieu Desnoyers
Date: Mon Feb 10 2020 - 12:33:08 EST
----- On Feb 10, 2020, at 12:05 PM, rostedt rostedt@xxxxxxxxxxx wrote:
> On Mon, 10 Feb 2020 10:46:16 +0100
> Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
>> Furthermore, using srcu would be detrimental, because of how it has
>> smp_mb() in the read side primitives.
>
> I didn't realize that there was a full memory barrier in the srcu read
> side. Seems to me that itself is rational for reverting it. And also a
> big NAK for any suggestion to have any of the function tracing to use
> it as well (which comes up here and there).
The rcu_irq_enter/exit_irqson() does atomic_add_return(), which is even worse
than a memory barrier.
Let me summarize my understanding of a few use-cases we have with tracepoints
and other instrumentation mechanisms and the guarantees they provide (or not):
* Tracepoints
- Uses sched-rcu (typically)
- Uses SRCU for _cpuidle callsites
- Planned use of SRCU to allow syscall entry/exit instrumentation to
take page faults. (currently all tracers paper over that issue by filling
with zeroes rather than handle the fault)
- Grace period waits for both sched-rcu and SRCU.
* kprobes/kretprobes
- interrupts off around probe invocation
* Hardware performance counters
- Probe invoked from NMI context
- Software performance counters
- preempt off around probe invocation
Moving _rcuidle instrumentation to SRCU aimed at removing a significant
overhead incurred by having all _rcuidle tracepoints perform the atomic_add_return
on the shared variable (which is frequent enough to impact performance).
There are a couple of approaches that perf could take in order to tackle this
without hurting performance for all other tracers:
- If perf wishes to keep using explicit rcu_read_lock/unlock in its probes:
Use is_rcu_watching() within the perf probe, and only invoke rcu_irq_enter/exit_irqson()
when needed.
As an alternative, perf could implement a "trampoline" which would only be used
when registering a perf probe to a _rcuidle tracepoint. That trampoline would
perform rcu_irq_entrer/exit_irqson() around the call to the real perf probe.
- If perf can remove the redundant RCU read-side lock/unlock and replace this
by waiting for the relevant RCU/SRCU grace periods instead:
Basically, looking at all the instrumentation sources perf uses, all of them
already provide some kind of RCU guarantee, which makes the explicit rcu read-side
locks within the perf probes redundant. Removing the redundant rcu read-side lock/unlock
from the perf probes should bring a slight performance improvement as well.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com