]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rv: Add explicit lockdep context for reactors
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Tue, 14 Oct 2025 05:51:58 +0000 (07:51 +0200)
committerGabriele Monaco <gmonaco@redhat.com>
Tue, 11 Nov 2025 12:18:56 +0000 (13:18 +0100)
Reactors can be called from any context through tracepoints.
When developing reactors care needs to be taken to only call APIs which
are safe. As the tracepoints used during testing may not actually be
called from restrictive contexts lockdep may not be helpful.

Add explicit overrides to help lockdep find invalid code patterns.

The usage of LD_WAIT_FREE will trigger lockdep warnings in the panic
reactor. These are indeed valid warnings but they are out of scope for
RV and will instead be fixed by the printk subsystem.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Nam Cao <namcao@linutronix.de>
Link: https://lore.kernel.org/r/20251014-rv-lockdep-v1-3-0b9e51919ea8@linutronix.de
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
kernel/trace/rv/rv_reactors.c

index 8c02426bc3bd944265f809e431283d1a20d56a8c..d9d335ae9badaa320f1d35dd159a033c3a30eb1a 100644 (file)
@@ -61,6 +61,7 @@
  *      printk
  */
 
+#include <linux/lockdep.h>
 #include <linux/slab.h>
 
 #include "rv.h"
@@ -480,6 +481,7 @@ out_err:
 
 void rv_react(struct rv_monitor *monitor, const char *msg, ...)
 {
+       static DEFINE_WAIT_OVERRIDE_MAP(rv_react_map, LD_WAIT_FREE);
        va_list args;
 
        if (!rv_reacting_on() || !monitor->react)
@@ -487,7 +489,9 @@ void rv_react(struct rv_monitor *monitor, const char *msg, ...)
 
        va_start(args, msg);
 
+       lock_map_acquire_try(&rv_react_map);
        monitor->react(msg, args);
+       lock_map_release(&rv_react_map);
 
        va_end(args);
 }