From: wen.yang@linux.dev
To: Gabriele Monaco <gmonaco@redhat.com>
Cc: Nam Cao <namcao@linutronix.de>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
Wen Yang <wen.yang@linux.dev>
Subject: [PATCH v5 0/5] rv/reactors: fix lockdep warning and add tests
Date: Mon, 7 Sep 2026 01:10:36 +0800 [thread overview]
Message-ID: <cover.1788705281.git.wen.yang@linux.dev> (raw)
From: Wen Yang <wen.yang@linux.dev>
We occasionally hit a lockdep "Invalid wait context" warning in
production when a reactor callback is preempted by a timer interrupt.
On interrupt exit the scheduler takes rq->__lock (LD_WAIT_SPIN) while
rv_react() still holds its wait-type-override map, which declared
LD_WAIT_FREE. On any kernel where the task context has preemption
enabled (not just CONFIG_PREEMPT_RT) this triggers a spurious lockdep
report:
[ BUG: Invalid wait context ]
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}
This series fixes the wait type (patch 1), makes reactor registration
failures propagate (patch 2), adds support for module-based
reactors (patch 3), and adds KUnit/kselftest coverage (patch 4-5).
Changes in v5:
- Patch 1: the locking rules no longer go to
Documentation/trace/rv/monitor_synthesis.rst, which is not about
reactors (Gabriele); they are documented in code comments.
Functional code unchanged.
- Patch 2: unchanged
- Patch 3: redesigned. v4 only exported the registration helpers,
which is harmless while all in-tree reactors are built-in, but
would let a loudable reactor module be unloaded while a monitor
still refereances its react() callback. Per the suggestion in
commit 3d3800b4f7 ("rv: Remove rv_reactor's reference counter").
A new selftest (patch 5) exercises it.
- Patch 4: The test callback is kept busy for two timer ticks so
the test also passes with HZ < 200.
- Patch 5: a selftest module that registers a reactor exercises
the module pinni g end to end: rmmod must fail while a monitor
is attached.
v4: https://lore.kernel.org/lkml/cover.1787854397.git.wen.yang@linux.dev/
v3: https://lore.kernel.org/lkml/cover.1786294920.git.wen.yang@linux.dev/
v2: https://lore.kernel.org/lkml/cover.1785695669.git.wen.yang@linux.dev/
v1: https://lore.kernel.org/lkml/cover.1781541556.git.wen.yang@linux.dev/
Wen Yang (5):
rv/reactors: use LD_WAIT_SPIN as the reactor lockdep wait type
rv/reactors: propagate rv_register_reactor() error from reactor init
rv/reactors: export rv_register_reactor() and rv_unregister_reactor()
rv/reactors: add KUnit tests for reactor registration and dispatch
selftests/verification: Test loadable module-based reactor
include/linux/rv.h | 3 +
kernel/trace/rv/Kconfig | 12 ++
kernel/trace/rv/Makefile | 1 +
kernel/trace/rv/reactor_panic.c | 3 +-
kernel/trace/rv/reactor_printk.c | 3 +-
kernel/trace/rv/rv.c | 5 +
kernel/trace/rv/rv_reactors.c | 48 ++++++--
kernel/trace/rv/rv_reactors_kunit.c | 110 ++++++++++++++++++
tools/testing/selftests/verification/Makefile | 1 +
tools/testing/selftests/verification/config | 2 +
.../test.d/rv_reactor_loadable.tc | 46 ++++++++
.../verification/test_modules/Makefile | 16 +++
.../test_modules/rv_test_reactor.c | 37 ++++++
13 files changed, 276 insertions(+), 11 deletions(-)
create mode 100644 kernel/trace/rv/rv_reactors_kunit.c
create mode 100644 tools/testing/selftests/verification/test.d/rv_reactor_loadable.tc
create mode 100644 tools/testing/selftests/verification/test_modules/Makefile
create mode 100644 tools/testing/selftests/verification/test_modules/rv_test_reactor.c
base-commit: 785095112f4198de49760552374f364043c8dbdf
--
2.25.1
next reply other threads:[~2026-09-06 17:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 17:10 wen.yang [this message]
2026-09-06 17:10 ` [PATCH v5 1/5] rv/reactors: use LD_WAIT_SPIN as the reactor lockdep wait type wen.yang
2026-09-06 17:18 ` sashiko-bot
2026-09-06 17:10 ` [PATCH v5 2/5] rv/reactors: propagate rv_register_reactor() error from reactor init wen.yang
2026-09-06 17:10 ` [PATCH v5 3/5] rv/reactors: export rv_register_reactor() and rv_unregister_reactor() wen.yang
2026-09-11 6:53 ` Gabriele Monaco
2026-09-13 16:33 ` Wen Yang
2026-09-06 17:10 ` [PATCH v5 4/5] rv/reactors: add KUnit tests for reactor registration and dispatch wen.yang
2026-09-06 17:23 ` sashiko-bot
2026-09-06 17:10 ` [PATCH v5 5/5] selftests/verification: Test loadable module-based reactor wen.yang
2026-09-06 17:19 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1788705281.git.wen.yang@linux.dev \
--to=wen.yang@linux.dev \
--cc=gmonaco@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=namcao@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.