From: Wen Yang <[email protected]>

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 switches to a single LD_WAIT_SPIN override, hardens reactor
registration error handling, exports the registration helpers for
modules, and adds KUnit coverage.

Changes in v4:
  - Patch 1: replace the context-sensitive two-map wait type with a
    single LD_WAIT_SPIN override, and document the constraint.
  - Patch 4: use a plain int instead of atomic_t for the test counter,
    trim redundant comments.

v3: https://lore.kernel.org/lkml/[email protected]/
v2: https://lore.kernel.org/lkml/[email protected]/
v1: https://lore.kernel.org/lkml/[email protected]/

Wen Yang (4):
  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

 Documentation/trace/rv/monitor_synthesis.rst |  20 ++++
 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_reactors.c                |   8 +-
 kernel/trace/rv/rv_reactors_kunit.c          | 105 +++++++++++++++++++
 7 files changed, 147 insertions(+), 5 deletions(-)
 create mode 100644 kernel/trace/rv/rv_reactors_kunit.c

base-commit: 785095112f4198de49760552374f364043c8dbdf
-- 
2.25.1


Reply via email to