IRQ action tracepoints describe handlers, but not the lifetime of the enclosing IRQ context. One context may run several actions, and an action may be dispatched outside hardirq context. PREEMPT_RT may also enter serving-softirq state without invoking an action. This leaves no generic event stream from which an RV monitor can check IRQ-context transitions.
This RFC adds events at the generic hardirq and serving-softirq boundaries. The irqstate RV monitor checks their order and agreement with live kernel state. irqexit follows the owner of a preempt_schedule_irq() invocation across task switches and CPU migration. The hardirq events cover paths through irq_enter() or irq_enter_rcu() and their matching exits. They do not cover direct __irq_enter() and __irq_exit() users, raw paths, or architecture-specific entry and return intervals. irqexit covers preempt_schedule_irq(), not the complete interrupt-return path. Boundary callbacks can raise softirq work after the pending-work check. The series wakes ksoftirqd or ktimerd for remaining work. KUnit covers nesting, monitor synchronization, PREEMPT_RT worker intervals, provenance and late-work handoff. Cross-architecture RV KUnit testing also exposed an Arm-specific opid bug: https://lore.kernel.org/r/[email protected] I would especially appreciate feedback on: 1. Should the context boundaries be trace events or private RV instrumentation? 2. Are dedicated scheduler events the right way to follow preempt_schedule_irq() across task switches and migration? 3. Should irqstate and irqexit remain separate monitors? 4. Is the KUnit-only hook for an empty ksoftirqd invocation acceptable? Outside a KUnit run, its worker checks take a disabled static-key path. Patches 1-5 add the events, monitors, and documentation. Patches 6-9 add KUnit coverage. This series is based on v7.3 (c03c1a14507d) and depends on the following accepted change, which is not included: softirq: Preserve interrupt context on return from interrupt https://lore.kernel.org/r/[email protected] A pre-existing issue can make rv_test_dummy intermittently report a false-positive invalid-wait-context warning under lockdep. Wen Yang has posted a fix: https://lore.kernel.org/lkml/5586dd00789a0f904cc299cd8889744b8c6f8dc9.1789412799.git.wen.y...@linux.dev/ This series does not include that fix. Karl Mehltretter (9): tracing/irq: Add generic IRQ context boundary events tracing/sched: Add IRQ preemption lifecycle events rv: Add a monitor for generic IRQ context transitions rv: Add a monitor for IRQ-exit scheduling ownership docs/rv: Document the IRQ-entry monitors rv: Add KUnit coverage for IRQ context transitions rv: Add KUnit coverage for IRQ-exit scheduling rv: Test empty PREEMPT_RT softirq worker intervals rv: Test IRQ-exit softirq provenance and handoff Documentation/trace/rv/index.rst | 1 + Documentation/trace/rv/monitor_irqentry.rst | 398 ++++ include/linux/interrupt.h | 7 + include/rv/kunit.h | 34 +- include/trace/events/irq.h | 70 + include/trace/events/sched.h | 51 + kernel/sched/core.c | 6 + kernel/softirq.c | 308 ++- kernel/trace/rv/Kconfig | 5 + kernel/trace/rv/Makefile | 3 + kernel/trace/rv/monitors/irqentry/Kconfig | 13 + kernel/trace/rv/monitors/irqentry/irqentry.c | 35 + kernel/trace/rv/monitors/irqentry/irqentry.h | 3 + kernel/trace/rv/monitors/irqexit/Kconfig | 14 + kernel/trace/rv/monitors/irqexit/irqexit.c | 172 ++ kernel/trace/rv/monitors/irqexit/irqexit.h | 85 + .../trace/rv/monitors/irqexit/irqexit_kunit.c | 537 +++++ .../trace/rv/monitors/irqexit/irqexit_kunit.h | 21 + .../trace/rv/monitors/irqexit/irqexit_trace.h | 19 + kernel/trace/rv/monitors/irqstate/Kconfig | 14 + kernel/trace/rv/monitors/irqstate/irqstate.c | 289 +++ kernel/trace/rv/monitors/irqstate/irqstate.h | 139 ++ .../rv/monitors/irqstate/irqstate_kunit.c | 2062 +++++++++++++++++ .../rv/monitors/irqstate/irqstate_kunit.h | 25 + .../rv/monitors/irqstate/irqstate_trace.h | 15 + kernel/trace/rv/rv_monitors_test.c | 29 + kernel/trace/rv/rv_trace.h | 2 + .../verification/models/irqentry/irqexit.dot | 21 + .../verification/models/irqentry/irqstate.dot | 32 + 29 files changed, 4397 insertions(+), 13 deletions(-) create mode 100644 Documentation/trace/rv/monitor_irqentry.rst create mode 100644 kernel/trace/rv/monitors/irqentry/Kconfig create mode 100644 kernel/trace/rv/monitors/irqentry/irqentry.c create mode 100644 kernel/trace/rv/monitors/irqentry/irqentry.h create mode 100644 kernel/trace/rv/monitors/irqexit/Kconfig create mode 100644 kernel/trace/rv/monitors/irqexit/irqexit.c create mode 100644 kernel/trace/rv/monitors/irqexit/irqexit.h create mode 100644 kernel/trace/rv/monitors/irqexit/irqexit_kunit.c create mode 100644 kernel/trace/rv/monitors/irqexit/irqexit_kunit.h create mode 100644 kernel/trace/rv/monitors/irqexit/irqexit_trace.h create mode 100644 kernel/trace/rv/monitors/irqstate/Kconfig create mode 100644 kernel/trace/rv/monitors/irqstate/irqstate.c create mode 100644 kernel/trace/rv/monitors/irqstate/irqstate.h create mode 100644 kernel/trace/rv/monitors/irqstate/irqstate_kunit.c create mode 100644 kernel/trace/rv/monitors/irqstate/irqstate_kunit.h create mode 100644 kernel/trace/rv/monitors/irqstate/irqstate_trace.h create mode 100644 tools/verification/models/irqentry/irqexit.dot create mode 100644 tools/verification/models/irqentry/irqstate.dot base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222 prerequisite-patch-id: 6ac7167f0aa7c5319dac78bf5b06a989fd7dfac5 -- 2.39.5 (Apple Git-154)
