Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracepoints: Use WARN() and not WARN_ON() for warnings

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.

Link: https://lore.kernel.org/linux-trace-kernel/20240228133112.0d64fb1b@gandalf.local.home

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Reported-by: Borislav Petkov <bp@alien8.de>
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+4 -2
+4 -2
include/linux/tracepoint.h
··· 199 199 if (!(cond)) \ 200 200 return; \ 201 201 \ 202 - if (WARN_ON_ONCE(RCUIDLE_COND(rcuidle))) \ 202 + if (WARN_ONCE(RCUIDLE_COND(rcuidle), \ 203 + "Bad RCU usage for tracepoint")) \ 203 204 return; \ 204 205 \ 205 206 /* keep srcu and sched-rcu usage consistent */ \ ··· 260 259 TP_ARGS(args), \ 261 260 TP_CONDITION(cond), 0); \ 262 261 if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \ 263 - WARN_ON_ONCE(!rcu_is_watching()); \ 262 + WARN_ONCE(!rcu_is_watching(), \ 263 + "RCU not watching for tracepoint"); \ 264 264 } \ 265 265 } \ 266 266 __DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args), \