Re: Can rcu_tasks_trace be used for *all* tracepoints?
From: Paul E. McKenney
Date: Tue Dec 01 2026 - 15:18:23 EST
On Tue, Dec 01, 2026 at 03:07:30PM -0500, Steven Rostedt wrote:
> On Tue, 1 Dec 2026 11:54:08 -0800
> "Paul E. McKenney" <paulmck@xxxxxxxxxx> wrote:
>
> > In recent kernels, rcu_read_lock_trace() is a thin wrapper around SRCU,
> > specifically, __srcu_read_lock_fast(), so it is clearly possible. ;-)
>
> That's what I noticed. What's the difference from using
> rcu_read_lock_trace() and the current tracepoint:
>
> guard(srcu_fast_notrace)(&tracepoint_srcu);
>
> ?
Aside from kernels built with CONFIG_TASKS_TRACE_RCU_NO_MB=y and some
extra lockdep state maintenance, nothing that I know of. Also, your
statement above is a bit more typing.
> > One potential drawback is delays from other rcu_read_lock_trace() callers,
> > but they are supposed to limit themselves to page-fault-duration sleeps,
>
> Which is basically what traecpoints do now. As to free a tracepoint, you
> need to wait for:
>
> extern struct srcu_struct tracepoint_srcu;
> static inline void tracepoint_synchronize_unregister(void)
> {
> synchronize_rcu_tasks_trace();
> synchronize_srcu(&tracepoint_srcu);
> }
>
> Thus tracepoints *already* have to wait for rcu_tasks_trace(). As we didn't
> want to complicate the code and differentiate generic code that uses both
> syscall tracepoints and regular tracepoints, it assumes that it could be
> either, and it waits for both. It does so serially too, so this change
> could actually speed up the wait times.
You could use synchronize_rcu_mult() to overlap the waits, but eliminating
one of the waits entirely will usually be even better.
> > so perhaps that is not a problem. The drawback in the opposite direction
> > (tracepoints using rcu_read_lock_trace() and friends) is reader delays
> > in tracepoints affecting other callers, but your readers should be quite
> > fast, correct?
>
> The current users of rcu_read_lock_trace() are the slow system call
> tracepoints. The other ones are even safe for preempt_disable(), so it will
> not slow things down at all.
Sounds like it is worth a try. ;-)
Thanx, Paul