From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6159421EE4 for ; Tue, 7 Jul 2026 13:46:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783431986; cv=none; b=G1R2uf7+Wi0OTjl2LXci1380aj0RIwXvr0nsvOE7KtykivSQqvArcXGl/f0nCuSAv6B4ojWTIJ+dGRvUK+VqwDLV4gRgsD3ebkf7I1voMzyeYZCa0NmITtqcTDQBfojn8Cksvs+LX+iibzabfX11SrRd15GgObFBvtS/wy4Xt3g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783431986; c=relaxed/simple; bh=y8F8NDa2nca95Z3aP7WXDltydbzurVIjc40t/OG2O04=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=eXiqFjRfvOOiEBAKzOKvTkJ+47TJCgoIFcKz6Baa0QRoVWU+sjaB7SrNqMGoqppDtnxDMz8YPiplZPv0a/nr2T/WqIDQDu94huBYuM9VViLA/0rwpCBaUJtqpwHpeZ9Y3ai5HProTw6Q/6r6Mg0IQV4ps08QToUtQoswYWX710c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kg9FuGQO; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kg9FuGQO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 458511F000E9; Tue, 7 Jul 2026 13:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783431982; bh=RS2PnXKAxberMIJ5BRGYeeyHnmD5XBGsA6cZ21Ksm0Y=; h=Date:From:To:Cc:Subject:References; b=kg9FuGQOPYGQBgqLXFCY9EMZ5I4mIgoO74iqlOZWm2vIKcxAymqKfRJ8HnhcHDOVX nM18O33gRj2Op4MjvXt9gufNKWq6Am4ZvVKyWPJIRQMapqW3NWSWGVq1UHp+QJzdJy SYMdkuTZE1Dv1Le8GkTU4GGaBd9GVBSu2H+gcAdqtcqSnM3GltO3iB9v6HYlRuG0hh DBQfwSWcha43qRaO0frq8Mpq4lwfbQgB6glTT6g8R81+38pV2a8TpGjThfRzH/iwTx fTq+w1H2QYU5kMk25oTB4wueK5D84hOzfora4ToEwTBtqEjXTOmhLIN2kOPnssowXl szaA8plRiFP8g== Received: from rostedt by gandalf with local (Exim 4.99.4) (envelope-from ) id 1wh681-00000000h75-2CVT; Tue, 07 Jul 2026 09:46:25 -0400 Message-ID: <20260707134625.377624002@kernel.org> User-Agent: quilt/0.69 Date: Tue, 07 Jul 2026 09:46:17 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Geert Uytterhoeven , Geert Uytterhoeven Subject: [for-linus][PATCH 13/13] tracing: Add a no-rcu-check version of trace_##event##_enabled() References: <20260707134604.275787924@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Steven Rostedt Tracepoints require that RCU is watching. To prevent them from being used in places that RCU is not watching, the trace_##event() macro always calls rcu_is_watching() even when the event is not enabled and warns if RCU is not watching. This is to make sure a warning is triggered even if the tracepoint is never enabled (as it is only a bug when it is). It was noticed that tracepoints could be hidden within trace_#event#_enabled() calls, which are used to do extra work for the tracepoint only if the tracepoint is enabled. But this also can hide the fact that a tracepoint is placed in a location that can be called when RCU is not watching. Commit 9764e731ef6ab ("tracepoint: Add lockdep rcu_is_watching() check to trace_##name##_enabled()") added a check to the trace_##event##_enabled() macro to make sure RCU is watching when it is called to make sure not to hide the bug of a tracepoint being called when RCU is not watching. There is one case in the irq_disable tracepoint where it is within a trace_irq_disable_enabled() block, but it checks if RCU is watching, and if it isn't, it makes a call to ct_irq_enter() that makes RCU watch again. But because trace_irq_disable_enabled() now checks if RCU is watching and will trigger if it isn't. This is a false warning as the code within the block handles this case. Add a new internal macro __trace_##event##_enabled() that doesn't check if RCU is watching, and convert the irq_enable/disable tracepoints over to it. Link: https://patch.msgid.link/20260701132744.6a7fc68b@robin Reported-by: Geert Uytterhoeven Closes: https://lore.kernel.org/all/CAMuHMdXud_RpWag_hFqa2ByBGRxg6KnxGL1ObCWZrpTsk3TfAw@mail.gmail.com/ Fixes: 9764e731ef6ab ("tracepoint: Add lockdep rcu_is_watching() check to trace_##name##_enabled()") Tested-by: Geert Uytterhoeven Signed-off-by: Steven Rostedt --- include/linux/tracepoint.h | 12 +++++++++++- kernel/trace/trace_preemptirq.c | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 4a0c36f40fe2..e0d838c9ce93 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -292,13 +292,18 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) { \ } \ static inline bool \ + __trace_##name##_enabled(void) \ + { \ + return static_branch_unlikely(&__tracepoint_##name.key);\ + } \ + static inline bool \ trace_##name##_enabled(void) \ { \ if (IS_ENABLED(CONFIG_LOCKDEP)) { \ WARN_ONCE(!rcu_is_watching(), \ "RCU not watching for tracepoint"); \ } \ - return static_branch_unlikely(&__tracepoint_##name.key);\ + return __trace_##name##_enabled(); \ } #define __DECLARE_TRACE(name, proto, args, cond, data_proto) \ @@ -457,6 +462,11 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) { \ } \ static inline bool \ + __trace_##name##_enabled(void) \ + { \ + return false; \ + } \ + static inline bool \ trace_##name##_enabled(void) \ { \ return false; \ diff --git a/kernel/trace/trace_preemptirq.c b/kernel/trace/trace_preemptirq.c index 0c42b15c3800..b63e3558948f 100644 --- a/kernel/trace/trace_preemptirq.c +++ b/kernel/trace/trace_preemptirq.c @@ -30,7 +30,7 @@ #else #define trace(point, args) \ do { \ - if (trace_##point##_enabled()) { \ + if (__trace_##point##_enabled()) { \ bool exit_rcu = false; \ if (in_nmi()) \ break; \ -- 2.53.0