From: wen.yang@linux.dev
To: Steven Rostedt <rostedt@goodmis.org>,
Gabriele Monaco <gmonaco@redhat.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
Wen Yang <wen.yang@linux.dev>
Subject: [RFC PATCH 0/4] rv/tlob: Add task latency over budget RV monitor
Date: Mon, 13 Apr 2026 03:27:17 +0800 [thread overview]
Message-ID: <cover.1776020428.git.wen.yang@linux.dev> (raw)
From: Wen Yang <wen.yang@linux.dev>
This series introduces tlob (task latency over budget), a new per-task
Runtime Verification monitor.
Background
----------
The RV framework formalises kernel behavioural properties as
deterministic automata. Existing monitors (wwnr, sssw, opid, etc.) cover
scheduling and locking invariants; none tracks wall-clock latency of
a per-task code path, including off-CPU time. This property is needed
in ADAS perception/planning pipelines, industrial real-time
controllers, and similar mixed-criticality deployments.
tlob adds this capability. A caller demarcates a code path via a
start/stop pair; the kernel arms a per-task hrtimer for the requested
budget. If the task has not called TRACE_STOP before the timer fires,
a violation is recorded, the stop call returns -EOVERFLOW, and an
event is pushed to the caller's mmap ring.
The tracefs interface requires only tracefs write permissions, avoiding
the CAP_BPF privilege needed for equivalent eBPF-based approaches. The
DA model (patch 1) can be independently verified with standard model-
checking tools.
Design
------
The monitor is a three-state deterministic automaton (DA):
unmonitored --trace_start--> on_cpu
on_cpu --switch_out--> off_cpu
off_cpu --switch_in---> on_cpu
{on_cpu, off_cpu} --{trace_stop, budget_expired}--> unmonitored
Per-task state lives in a fixed-size hash table (TLOB_MAX_MONITORED
slots) with RCU-deferred free. Timing is based on CLOCK_MONOTONIC
(ktime_get()), so budgets account for off-CPU time.
Two userspace interfaces are provided:
tracefs: uprobe pair registration via the monitor/enable files; no
new UAPI required.
/dev/rv ioctls (CONFIG_RV_CHARDEV):
TLOB_IOCTL_TRACE_START — arm the budget for a target task
TLOB_IOCTL_TRACE_STOP — disarm; returns -EOVERFLOW on violation
Each /dev/rv file descriptor has a per-fd mmap ring (a physically
contiguous control page struct tlob_mmap_page followed by an array of
struct tlob_event records). Head/tail/dropped are userspace-readable
without locking; overflow uses a drop-new policy.
New UAPI (include/uapi/linux/rv.h): tlob_start_args, tlob_event,
tlob_mmap_page, ioctl numbers (RV_IOC_MAGIC=0xB9, registered in
Documentation/userspace-api/ioctl/ioctl-number.rst).
Testing
-------
KUnit (patch 3): six suites (38 cases) gated on CONFIG_TLOB_KUNIT_TEST.
./tools/testing/kunit/kunit.py run \
--kunitconfig kernel/trace/rv/monitors/tlob/.kunitconfig
Coverage: automaton state transitions, start/stop API error paths,
scheduler context-switch accounting, tracepoint payload fields,
ring-buffer push/overflow/wakeup, and the uprobe line parser.
kselftest (patch 4): 19 TAP test points under
tools/testing/selftests/rv/. Requires CONFIG_RV_MON_TLOB=y,
CONFIG_RV_CHARDEV=y, and root.
make -C tools/testing/selftests/rv
sudo ./test_tlob.sh
Patch overview
--------------
Patch 1 — DOT model: formal automaton specification for verification.
Patch 2 — monitor implementation, UAPI, and documentation.
Patch 3 — KUnit in-kernel unit tests.
Patch 4 — kselftest user-space integration tests.
Wen Yang (4):
rv/tlob: Add tlob model DOT file
rv/tlob: Add tlob deterministic automaton monitor
rv/tlob: Add KUnit tests for the tlob monitor
selftests/rv: Add selftest for the tlob monitor
Documentation/trace/rv/index.rst | 1 +
Documentation/trace/rv/monitor_tlob.rst | 381 ++++++
.../userspace-api/ioctl/ioctl-number.rst | 1 +
MAINTAINERS | 3 +
include/uapi/linux/rv.h | 181 +++
kernel/trace/rv/Kconfig | 17 +
kernel/trace/rv/Makefile | 3 +
kernel/trace/rv/monitors/tlob/.kunitconfig | 5 +
kernel/trace/rv/monitors/tlob/Kconfig | 63 +
kernel/trace/rv/monitors/tlob/tlob.c | 987 ++++++++++++++
kernel/trace/rv/monitors/tlob/tlob.h | 145 ++
kernel/trace/rv/monitors/tlob/tlob_kunit.c | 1194 +++++++++++++++++
kernel/trace/rv/monitors/tlob/tlob_trace.h | 42 +
kernel/trace/rv/rv.c | 4 +
kernel/trace/rv/rv_dev.c | 602 +++++++++
kernel/trace/rv/rv_trace.h | 50 +
tools/include/uapi/linux/rv.h | 54 +
tools/testing/selftests/rv/Makefile | 18 +
tools/testing/selftests/rv/test_tlob.sh | 563 ++++++++
tools/testing/selftests/rv/tlob_helper.c | 994 ++++++++++++++
.../testing/selftests/rv/tlob_uprobe_target.c | 108 ++
tools/verification/models/tlob.dot | 25 +
22 files changed, 5441 insertions(+)
create mode 100644 Documentation/trace/rv/monitor_tlob.rst
create mode 100644 include/uapi/linux/rv.h
create mode 100644 kernel/trace/rv/monitors/tlob/.kunitconfig
create mode 100644 kernel/trace/rv/monitors/tlob/Kconfig
create mode 100644 kernel/trace/rv/monitors/tlob/tlob.c
create mode 100644 kernel/trace/rv/monitors/tlob/tlob.h
create mode 100644 kernel/trace/rv/monitors/tlob/tlob_kunit.c
create mode 100644 kernel/trace/rv/monitors/tlob/tlob_trace.h
create mode 100644 kernel/trace/rv/rv_dev.c
create mode 100644 tools/include/uapi/linux/rv.h
create mode 100644 tools/testing/selftests/rv/Makefile
create mode 100755 tools/testing/selftests/rv/test_tlob.sh
create mode 100644 tools/testing/selftests/rv/tlob_helper.c
create mode 100644 tools/testing/selftests/rv/tlob_uprobe_target.c
create mode 100644 tools/verification/models/tlob.dot
--
2.43.0
next reply other threads:[~2026-04-12 19:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-12 19:27 wen.yang [this message]
2026-04-12 19:27 ` [RFC PATCH 1/4] rv/tlob: Add tlob model DOT file wen.yang
2026-04-13 8:19 ` Gabriele Monaco
2026-04-12 19:27 ` [RFC PATCH 2/4] rv/tlob: Add tlob deterministic automaton monitor wen.yang
2026-04-13 8:19 ` Gabriele Monaco
2026-04-12 19:27 ` [RFC PATCH 3/4] rv/tlob: Add KUnit tests for the tlob monitor wen.yang
2026-04-12 19:27 ` [RFC PATCH 4/4] selftests/rv: Add selftest " wen.yang
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.1776020428.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=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox