From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 71D911067041 for ; Thu, 12 Mar 2026 15:13:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C59C110EA3E; Thu, 12 Mar 2026 15:13:14 +0000 (UTC) Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC68D10EA3E; Thu, 12 Mar 2026 15:13:13 +0000 (UTC) Received: from omf11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id ADC251602E0; Thu, 12 Mar 2026 15:13:07 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf11.hostedemail.com (Postfix) with ESMTPA id 78D742002C; Thu, 12 Mar 2026 15:12:41 +0000 (UTC) Date: Thu, 12 Mar 2026 11:12:55 -0400 From: Steven Rostedt To: "Vineeth Pillai (Google)" Cc: Peter Zijlstra , Dmitry Ilvokhin , Masami Hiramatsu , Mathieu Desnoyers , Ingo Molnar , Jens Axboe , io-uring@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Marcelo Ricardo Leitner , Xin Long , Jon Maloy , Aaron Conole , Eelco Chaudron , Ilya Maximets , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-sctp@vger.kernel.org, tipc-discussion@lists.sourceforge.net, dev@openvswitch.org, Oded Gabbay , Koby Elbaz , dri-devel@lists.freedesktop.org, "Rafael J. Wysocki" , Viresh Kumar , "Gautham R. Shenoy" , Huang Rui , Mario Limonciello , Len Brown , Srinivas Pandruvada , linux-pm@vger.kernel.org, MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Christian =?UTF-8?B?S8O2bmln?= , Sumit Semwal , linaro-mm-sig@lists.linaro.org, Eddie James , Andrew Jeffery , Joel Stanley , linux-fsi@lists.ozlabs.org, David Airlie , Simona Vetter , Alex Deucher , Danilo Krummrich , Matthew Brost , Philipp Stanner , Harry Wentland , Leo Li , amd-gfx@lists.freedesktop.org, Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, Wolfram Sang , linux-i2c@vger.kernel.org, Mark Brown , Michael Hennerich , Nuno =?UTF-8?B?U8Oh?= , linux-spi@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, Chris Mason , David Sterba , linux-btrfs@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/15] tracepoint: Add trace_invoke_##name() API Message-ID: <20260312111255.7925b4e2@gandalf.local.home> In-Reply-To: <20260312150523.2054552-2-vineeth@bitbyteword.org> References: <20260312150523.2054552-1-vineeth@bitbyteword.org> <20260312150523.2054552-2-vineeth@bitbyteword.org> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: ywcbaqn9zwge3gfga96u97w7nijzfb5x X-Rspamd-Server: rspamout08 X-Rspamd-Queue-Id: 78D742002C X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX18ieAMVXlCsjfIHQB5VYSMKQawnv3xLXWM= X-HE-Tag: 1773328361-302890 X-HE-Meta: U2FsdGVkX19212n5hf5VfWxxI3698ig+MYJ7h5PCrgzm7w3SBjXRVmntUgy1KAiA1j7ASoLiubrJUkhEQG+sVPUaqYvKVHrwHJfLEWqAblPMb1GCyB1vNtgXBTh0V0ySDjWK4c33hpSt6/UqWv2L0DWGvadPudlZSBYs0RHFEdqFbOLNYrAcOZsPRKT15ByTEqCfDyAmN0Qx4BlSkuaDuqx2DqlJVWxM1GIGcenYfKc4Oug4F+oj89fFXccHcftI8mvLFhHknaGUAcf5v6epx6ogBFZcEEfmCJxjXwE/1rjNLuPMol8FZX9cbSBPAiHoHDFNAmrC3azhj+xd+IQ9/nDUnOF7z/s7bbkZPpL2MZx7bw+9cK59bCAAmgXFQUGvGdwUDjf+aJ99jx8W6XuzQvGWj1cuLtlykLy1hAkh57CyBpLZSVzGcIlLV0+qfGz9ZsIFZ0fPg4pdG4v8JMXapSh4ZRe71DXAUeEQ5q5ubssZsWB5mqjTVA== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Thu, 12 Mar 2026 11:04:56 -0400 "Vineeth Pillai (Google)" 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 > Suggested-by: Peter Zijlstra > Signed-off-by: Vineeth Pillai (Google) > Assisted-by: Claude:claude-sonnet-4-6 I'm guessing Claude helped with the other patches. Did it really help with this one? -- Steve > --- > include/linux/tracepoint.h | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h > index 22ca1c8b54f32..07219316a8e14 100644 > --- a/include/linux/tracepoint.h > +++ b/include/linux/tracepoint.h > @@ -294,6 +294,10 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) > WARN_ONCE(!rcu_is_watching(), \ > "RCU not watching for tracepoint"); \ > } \ > + } \ > + static inline void trace_invoke_##name(proto) \ > + { \ > + __do_trace_##name(args); \ > } > > #define __DECLARE_TRACE_SYSCALL(name, proto, args, data_proto) \ > @@ -313,6 +317,11 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) > WARN_ONCE(!rcu_is_watching(), \ > "RCU not watching for tracepoint"); \ > } \ > + } \ > + static inline void trace_invoke_##name(proto) \ > + { \ > + might_fault(); \ > + __do_trace_##name(args); \ > } > > /* > @@ -398,6 +407,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) > #define __DECLARE_TRACE_COMMON(name, proto, args, data_proto) \ > static inline void trace_##name(proto) \ > { } \ > + static inline void trace_invoke_##name(proto) \ > + { } \ > static inline int \ > register_trace_##name(void (*probe)(data_proto), \ > void *data) \