Re: [PATCH 01/15] tracepoint: Add trace_invoke_##name() API

From: Vineeth Remanan Pillai

Date: Thu Mar 12 2026 - 12:07:28 EST


On Thu, Mar 12, 2026 at 11:53 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Thu, Mar 12, 2026 at 11:39:06AM -0400, Vineeth Remanan Pillai wrote:
> > On Thu, Mar 12, 2026 at 11:13 AM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> > >
> > > On Thu, 12 Mar 2026 11:04:56 -0400
> > > "Vineeth Pillai (Google)" <vineeth@xxxxxxxxxxxxxxx> wrote:
> > >
> > > > Add trace_invoke_##name() as a companion to trace_##name(). When a
> > > > caller already guards a tracepoint with an explicit enabled check:
> > > >
> > > > if (trace_foo_enabled() && cond)
> > > > trace_foo(args);
> > > >
> > > > trace_foo() internally repeats the static_branch_unlikely() test, which
> > > > the compiler cannot fold since static branches are patched binary
> > > > instructions. This results in two static-branch evaluations for every
> > > > guarded call site.
> > > >
> > > > trace_invoke_##name() calls __do_trace_##name() directly, skipping the
> > > > redundant static-branch re-check. This avoids leaking the internal
> > > > __do_trace_##name() symbol into call sites while still eliminating the
> > > > double evaluation:
> > > >
> > > > if (trace_foo_enabled() && cond)
> > > > trace_invoke_foo(args); /* calls __do_trace_foo() directly */
> > > >
> > > > Three locations are updated:
> > > > - __DECLARE_TRACE: invoke form omits static_branch_unlikely, retains
> > > > the LOCKDEP RCU-watching assertion.
> > > > - __DECLARE_TRACE_SYSCALL: same, plus retains might_fault().
> > > > - !TRACEPOINTS_ENABLED stub: empty no-op so callers compile cleanly
> > > > when tracepoints are compiled out.
> > > >
> > > > Suggested-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
> > > > Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > > > Signed-off-by: Vineeth Pillai (Google) <vineeth@xxxxxxxxxxxxxxx>
> > > > Assisted-by: Claude:claude-sonnet-4-6
> > >
> > > I'm guessing Claude helped with the other patches. Did it really help with this one?
> > >
> >
> > Claude wrote and build tested the whole series based on my guidance
> > and prompt :-). I verified the series before sending it out, but
> > claude did the initial work.
>
> That seems like an unreasonable waste of energy. You could've had claude
> write a Coccinelle script for you and saved a ton of tokens.

Yeah true, Steve also mentioned this to me offline. Haven't used
Coccinelle before, but now I know :-)

Thanks,
Vineeth