summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorWen Yang <wen.yang@linux.dev>2026-09-15 03:13:34 +0800
committerGabriele Monaco <gmonaco@redhat.com>2026-10-01 13:59:36 +0200
commit39ccedfd9e55c95e440c26611a1db750b92b83bf (patch)
treefb7e18f1feb00cf29ea08f6644526361583aa187 /kernel
parentfd73f4a6659897191fa0d40695fe370925dd3780 (diff)
rv: Use LD_WAIT_SPIN as the reactor lockdep wait type
rv_react() overrides the lockdep wait type to LD_WAIT_FREE to enforce that reactor callbacks take no locks. But callbacks run in the context of the triggering tracepoint, which can be preemptible task context on any kernel. A timer interrupt firing during the callback makes the interrupt-exit path schedule and take rq->__lock (LD_WAIT_SPIN) while the LD_WAIT_FREE override is still held, producing a spurious "Invalid wait context" warning: [ BUG: Invalid wait context ] context-{5:5} 1 lock held by kunit_try_catch/209: #0: (rv_react_map-wait-type-override){+.+.}-{1:1} kunit_try_catch/209 is trying to lock: ffff8a743ed3e8a0 (&rq->__lock){-...}-{2:2} Use LD_WAIT_SPIN instead of LD_WAIT_FREE, which causes false-positive warnings in preemptible contexts due to scheduler preemption taking rq->__lock. Fixes: 69d8895cb9a9 ("rv: Add explicit lockdep context for reactors") Reviewed-by: Gabriele Monaco <gmonaco@redhat.com> Signed-off-by: Wen Yang <wen.yang@linux.dev> Cc: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Link: https://lore.kernel.org/r/5586dd00789a0f904cc299cd8889744b8c6f8dc9.1789412799.git.wen.yang@linux.dev Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/rv/rv_reactors.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/kernel/trace/rv/rv_reactors.c b/kernel/trace/rv/rv_reactors.c
index 2f5fc8d18dea..ff7d478227c3 100644
--- a/kernel/trace/rv/rv_reactors.c
+++ b/kernel/trace/rv/rv_reactors.c
@@ -465,7 +465,15 @@ int init_rv_reactors(struct dentry *root_dir)
void rv_react(struct rv_monitor *monitor, const char *msg, ...)
{
- static DEFINE_WAIT_OVERRIDE_MAP(rv_react_map, LD_WAIT_FREE);
+ /*
+ * Reactors must not explicitly take locks, so they should be
+ * LD_WAIT_FREE. However, reactor callbacks can run with preemption
+ * enabled, meaning the preempting code (e.g. the scheduler taking
+ * rq->__lock at LD_WAIT_SPIN) may violate that constraint. Use
+ * LD_WAIT_SPIN to avoid false-positive lockdep reports.
+ * But you should still NOT be using locks in reactors.
+ */
+ static DEFINE_WAIT_OVERRIDE_MAP(rv_react_map, LD_WAIT_SPIN);
va_list args;
if (!rv_reacting_on() || !monitor->react)