* [PATCH] tracepoints: Use WARN() and not WARN_ON() for warnings
@ 2024-02-28 18:31 Steven Rostedt
2024-02-28 18:32 ` Borislav Petkov
2024-02-28 18:48 ` Paul E. McKenney
0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2024-02-28 18:31 UTC (permalink / raw)
To: LKML, Linux Trace Kernel
Cc: Masami Hiramatsu, Mathieu Desnoyers, Paul E. McKenney,
Borislav Petkov, Thomas Gleixner
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
There are two WARN_ON*() warnings in tracepoint.h that deal with RCU
usage. But when they trigger, especially from using a TRACE_EVENT()
macro, the information is not very helpful and is confusing:
------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at include/trace/events/lock.h:24 lock_acquire+0x2b2/0x2d0
Where the above warning takes you to:
TRACE_EVENT(lock_acquire, <<<--- line 24 in lock.h
TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
int trylock, int read, int check,
struct lockdep_map *next_lock, unsigned long ip),
[..]
Change the WARN_ON_ONCE() to WARN_ONCE() and add a string that allows
someone to search for exactly where the bug happened.
Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
include/linux/tracepoint.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 88c0ba623ee6..689b6d71590e 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -199,7 +199,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
if (!(cond)) \
return; \
\
- if (WARN_ON_ONCE(RCUIDLE_COND(rcuidle))) \
+ if (WARN_ONCE(RCUIDLE_COND(rcuidle), \
+ "Bad RCU usage for tracepoint")) \
return; \
\
/* keep srcu and sched-rcu usage consistent */ \
@@ -259,7 +260,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
TP_ARGS(args), \
TP_CONDITION(cond), 0); \
if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \
- WARN_ON_ONCE(!rcu_is_watching()); \
+ WARN_ONCE(!rcu_is_watching(), \
+ "RCU not watching for tracepoint"); \
} \
} \
__DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args), \
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tracepoints: Use WARN() and not WARN_ON() for warnings
2024-02-28 18:31 [PATCH] tracepoints: Use WARN() and not WARN_ON() for warnings Steven Rostedt
@ 2024-02-28 18:32 ` Borislav Petkov
2024-02-28 18:48 ` Paul E. McKenney
1 sibling, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2024-02-28 18:32 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Mathieu Desnoyers,
Paul E. McKenney, Thomas Gleixner
On Wed, Feb 28, 2024 at 01:31:12PM -0500, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> There are two WARN_ON*() warnings in tracepoint.h that deal with RCU
> usage. But when they trigger, especially from using a TRACE_EVENT()
> macro, the information is not very helpful and is confusing:
>
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 0 at include/trace/events/lock.h:24 lock_acquire+0x2b2/0x2d0
>
> Where the above warning takes you to:
>
> TRACE_EVENT(lock_acquire, <<<--- line 24 in lock.h
>
> TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
> int trylock, int read, int check,
> struct lockdep_map *next_lock, unsigned long ip),
> [..]
>
> Change the WARN_ON_ONCE() to WARN_ONCE() and add a string that allows
> someone to search for exactly where the bug happened.
>
> Reported-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> include/linux/tracepoint.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
meaning: tested that it really fires:
[ 1.196008] Running RCU Tasks wait API self tests
[ 1.200227] ------------[ cut here ]------------
[ 1.203899] RCU not watching for tracepoint
[ 1.203899] WARNING: CPU: 0 PID: 0 at include/trace/events/lock.h:24 lock_acquire+0x2d3/0x300
...
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tracepoints: Use WARN() and not WARN_ON() for warnings
2024-02-28 18:31 [PATCH] tracepoints: Use WARN() and not WARN_ON() for warnings Steven Rostedt
2024-02-28 18:32 ` Borislav Petkov
@ 2024-02-28 18:48 ` Paul E. McKenney
1 sibling, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2024-02-28 18:48 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Mathieu Desnoyers,
Borislav Petkov, Thomas Gleixner
On Wed, Feb 28, 2024 at 01:31:12PM -0500, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> There are two WARN_ON*() warnings in tracepoint.h that deal with RCU
> usage. But when they trigger, especially from using a TRACE_EVENT()
> macro, the information is not very helpful and is confusing:
>
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 0 at include/trace/events/lock.h:24 lock_acquire+0x2b2/0x2d0
>
> Where the above warning takes you to:
>
> TRACE_EVENT(lock_acquire, <<<--- line 24 in lock.h
>
> TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
> int trylock, int read, int check,
> struct lockdep_map *next_lock, unsigned long ip),
> [..]
>
> Change the WARN_ON_ONCE() to WARN_ONCE() and add a string that allows
> someone to search for exactly where the bug happened.
>
> Reported-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
> ---
> include/linux/tracepoint.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
> index 88c0ba623ee6..689b6d71590e 100644
> --- a/include/linux/tracepoint.h
> +++ b/include/linux/tracepoint.h
> @@ -199,7 +199,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
> if (!(cond)) \
> return; \
> \
> - if (WARN_ON_ONCE(RCUIDLE_COND(rcuidle))) \
> + if (WARN_ONCE(RCUIDLE_COND(rcuidle), \
> + "Bad RCU usage for tracepoint")) \
> return; \
> \
> /* keep srcu and sched-rcu usage consistent */ \
> @@ -259,7 +260,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
> TP_ARGS(args), \
> TP_CONDITION(cond), 0); \
> if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \
> - WARN_ON_ONCE(!rcu_is_watching()); \
> + WARN_ONCE(!rcu_is_watching(), \
> + "RCU not watching for tracepoint"); \
> } \
> } \
> __DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args), \
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-28 18:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-28 18:31 [PATCH] tracepoints: Use WARN() and not WARN_ON() for warnings Steven Rostedt
2024-02-28 18:32 ` Borislav Petkov
2024-02-28 18:48 ` Paul E. McKenney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®