Skip to content

Commit 4ff261e

Browse files
committed
Merge tag 'trace-rv-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull runtime verification updates from Steven Rostedt: - Added Linear temporal logic monitors for RT application Real-time applications may have design flaws causing them to have unexpected latency. For example, the applications may raise page faults, or may be blocked trying to take a mutex without priority inheritance. However, while attempting to implement DA monitors for these real-time rules, deterministic automaton is found to be inappropriate as the specification language. The automaton is complicated, hard to understand, and error-prone. For these cases, linear temporal logic is found to be more suitable. The LTL is more concise and intuitive. - Make printk_deferred() public The new monitors needed access to printk_deferred(). Make them visible for the entire kernel. - Add a vpanic() to allow for va_list to be passed to panic. - Add rtapp container monitor. A collection of monitors that check for common problems with real-time applications that cause unexpected latency. - Add page fault tracepoints to risc-v These tracepoints are necessary to for the RV monitor to run on risc-v. - Fix the behaviour of the rv tool with -s and idle tasks. - Allow the rv tool to gracefully terminate with SIGTERM - Adjusts dot2c not to create lines over 100 columns - Properly order nested monitors in the RV Kconfig file - Return the registration error in all DA monitor instead of 0 - Update and add new sched collection monitors Replace tss and sncid monitors with more complete sts: Not only prove that switches occur in scheduling context and scheduling needs interrupt disabled but also that each call to the scheduler disables interrupts to (optionally) switch. New monitor: nrp Preemption requires need resched which is cleared by any switch (includes a non optimal workaround for /nested/ preemptions) New monitor: sssw suspension requires setting the task to sleepable and, after the switch occurs, the task requires a wakeup to come back to runnable New monitor: opid waking and need-resched operations occur with interrupts and preemption disabled or in IRQ without explicitly disabling preemption" * tag 'trace-rv-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: (48 commits) rv: Add opid per-cpu monitor rv: Add nrp and sssw per-task monitors rv: Replace tss and sncid monitors with more complete sts sched: Adapt sched tracepoints for RV task model rv: Retry when da monitor detects race conditions rv: Adjust monitor dependencies rv: Use strings in da monitors tracepoints rv: Remove trailing whitespace from tracepoint string rv: Add da_handle_start_run_event_ to per-task monitors rv: Fix wrong type cast in reactors_show() and monitor_reactor_show() rv: Fix wrong type cast in monitors_show() rv: Remove struct rv_monitor::reacting rv: Remove rv_reactor's reference counter rv: Merge struct rv_reactor_def into struct rv_reactor rv: Merge struct rv_monitor_def into struct rv_monitor rv: Remove unused field in struct rv_monitor_def rv: Return init error when registering monitors verification/rvgen: Organise Kconfig entries for nested monitors tools/dot2c: Fix generated files going over 100 column limit tools/rv: Stop gracefully also on SIGTERM ...
2 parents d50b07d + 6143845 commit 4ff261e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+4860
-1265
lines changed

Documentation/trace/rv/da_monitor_synthesis.rst

Lines changed: 0 additions & 147 deletions
This file was deleted.

Documentation/trace/rv/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ Runtime Verification
88

99
runtime-verification.rst
1010
deterministic_automata.rst
11-
da_monitor_synthesis.rst
11+
linear_temporal_logic.rst
12+
monitor_synthesis.rst
1213
da_monitor_instrumentation.rst
1314
monitor_wip.rst
1415
monitor_wwnr.rst
1516
monitor_sched.rst
17+
monitor_rtapp.rst
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
Linear temporal logic
2+
=====================
3+
4+
Introduction
5+
------------
6+
7+
Runtime verification monitor is a verification technique which checks that the
8+
kernel follows a specification. It does so by using tracepoints to monitor the
9+
kernel's execution trace, and verifying that the execution trace sastifies the
10+
specification.
11+
12+
Initially, the specification can only be written in the form of deterministic
13+
automaton (DA). However, while attempting to implement DA monitors for some
14+
complex specifications, deterministic automaton is found to be inappropriate as
15+
the specification language. The automaton is complicated, hard to understand,
16+
and error-prone.
17+
18+
Thus, RV monitors based on linear temporal logic (LTL) are introduced. This type
19+
of monitor uses LTL as specification instead of DA. For some cases, writing the
20+
specification as LTL is more concise and intuitive.
21+
22+
Many materials explain LTL in details. One book is::
23+
24+
Christel Baier and Joost-Pieter Katoen: Principles of Model Checking, The MIT
25+
Press, 2008.
26+
27+
Grammar
28+
-------
29+
30+
Unlike some existing syntax, kernel's implementation of LTL is more verbose.
31+
This is motivated by considering that the people who read the LTL specifications
32+
may not be well-versed in LTL.
33+
34+
Grammar:
35+
ltl ::= opd | ( ltl ) | ltl binop ltl | unop ltl
36+
37+
Operands (opd):
38+
true, false, user-defined names consisting of upper-case characters, digits,
39+
and underscore.
40+
41+
Unary Operators (unop):
42+
always
43+
eventually
44+
next
45+
not
46+
47+
Binary Operators (binop):
48+
until
49+
and
50+
or
51+
imply
52+
equivalent
53+
54+
This grammar is ambiguous: operator precedence is not defined. Parentheses must
55+
be used.
56+
57+
Example linear temporal logic
58+
-----------------------------
59+
.. code-block::
60+
61+
RAIN imply (GO_OUTSIDE imply HAVE_UMBRELLA)
62+
63+
means: if it is raining, going outside means having an umbrella.
64+
65+
.. code-block::
66+
67+
RAIN imply (WET until not RAIN)
68+
69+
means: if it is raining, it is going to be wet until the rain stops.
70+
71+
.. code-block::
72+
73+
RAIN imply eventually not RAIN
74+
75+
means: if it is raining, rain will eventually stop.
76+
77+
The above examples are referring to the current time instance only. For kernel
78+
verification, the `always` operator is usually desirable, to specify that
79+
something is always true at the present and for all future. For example::
80+
81+
always (RAIN imply eventually not RAIN)
82+
83+
means: *all* rain eventually stops.
84+
85+
In the above examples, `RAIN`, `GO_OUTSIDE`, `HAVE_UMBRELLA` and `WET` are the
86+
"atomic propositions".
87+
88+
Monitor synthesis
89+
-----------------
90+
91+
To synthesize an LTL into a kernel monitor, the `rvgen` tool can be used:
92+
`tools/verification/rvgen`. The specification needs to be provided as a file,
93+
and it must have a "RULE = LTL" assignment. For example::
94+
95+
RULE = always (ACQUIRE imply ((not KILLED and not CRASHED) until RELEASE))
96+
97+
which says: if `ACQUIRE`, then `RELEASE` must happen before `KILLED` or
98+
`CRASHED`.
99+
100+
The LTL can be broken down using sub-expressions. The above is equivalent to:
101+
102+
.. code-block::
103+
104+
RULE = always (ACQUIRE imply (ALIVE until RELEASE))
105+
ALIVE = not KILLED and not CRASHED
106+
107+
From this specification, `rvgen` generates the C implementation of a Buchi
108+
automaton - a non-deterministic state machine which checks the satisfiability of
109+
the LTL. See Documentation/trace/rv/monitor_synthesis.rst for details on using
110+
`rvgen`.
111+
112+
References
113+
----------
114+
115+
One book covering model checking and linear temporal logic is::
116+
117+
Christel Baier and Joost-Pieter Katoen: Principles of Model Checking, The MIT
118+
Press, 2008.
119+
120+
For an example of using linear temporal logic in software testing, see::
121+
122+
Ruijie Meng, Zhen Dong, Jialin Li, Ivan Beschastnikh, and Abhik Roychoudhury.
123+
2022. Linear-time temporal logic guided greybox fuzzing. In Proceedings of the
124+
44th International Conference on Software Engineering (ICSE '22). Association
125+
for Computing Machinery, New York, NY, USA, 1343–1355.
126+
https://doi.org/10.1145/3510003.3510082
127+
128+
The kernel's LTL monitor implementation is based on::
129+
130+
Gerth, R., Peled, D., Vardi, M.Y., Wolper, P. (1996). Simple On-the-fly
131+
Automatic Verification of Linear Temporal Logic. In: Dembiński, P., Średniawa,
132+
M. (eds) Protocol Specification, Testing and Verification XV. PSTV 1995. IFIP
133+
Advances in Information and Communication Technology. Springer, Boston, MA.
134+
https://doi.org/10.1007/978-0-387-34892-6_1

0 commit comments

Comments
 (0)