Skip to content

Commit bc3d482

Browse files
glemcorostedt
authored andcommitted
rv: Simplify manual steps in monitor creation
While creating a new monitor in RV, besides generating code from dot2k, there are a few manual steps which can be tedious and error prone, like adding the tracepoints, makefile lines and kconfig. This patch restructures the existing monitors to keep some files in the monitor's folder itself, which can be automatically generated by future versions of dot2k. Monitors have now their own Kconfig and tracepoint snippets. For simplicity, the main tracepoint definition, is moved to the RV directory, it defines only the tracepoint classes and includes the monitor-specific tracepoints, which reside in the monitor directory. Tracepoints and Kconfig no longer need to be copied and adapted from existing ones but only need to be included in the main files. The Makefile remains untouched since there's little advantage in having a separated Makefile for each monitor with a single line and including it in the main RV Makefile. Cc: Juri Lelli <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: John Kacur <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Gabriele Monaco <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 64b3e5f commit bc3d482

File tree

10 files changed

+66
-45
lines changed

10 files changed

+66
-45
lines changed

kernel/trace/rv/Kconfig

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,9 @@ menuconfig RV
2525
For further information, see:
2626
Documentation/trace/rv/runtime-verification.rst
2727

28-
config RV_MON_WIP
29-
depends on RV
30-
depends on PREEMPT_TRACER
31-
select DA_MON_EVENTS_IMPLICIT
32-
bool "wip monitor"
33-
help
34-
Enable wip (wakeup in preemptive) sample monitor that illustrates
35-
the usage of per-cpu monitors, and one limitation of the
36-
preempt_disable/enable events.
37-
38-
For further information, see:
39-
Documentation/trace/rv/monitor_wip.rst
28+
source "kernel/trace/rv/monitors/wip/Kconfig"
4029

41-
config RV_MON_WWNR
42-
depends on RV
43-
select DA_MON_EVENTS_ID
44-
bool "wwnr monitor"
45-
help
46-
Enable wwnr (wakeup while not running) sample monitor, this is a
47-
sample monitor that illustrates the usage of per-task monitor.
48-
The model is borken on purpose: it serves to test reactors.
49-
50-
For further information, see:
51-
Documentation/trace/rv/monitor_wwnr.rst
30+
source "kernel/trace/rv/monitors/wwnr/Kconfig"
5231

5332
config RV_REACTORS
5433
bool "Runtime verification reactors"

kernel/trace/rv/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22

3+
ccflags-y += -I $(src) # needed for trace events
4+
35
obj-$(CONFIG_RV) += rv.o
46
obj-$(CONFIG_RV_MON_WIP) += monitors/wip/wip.o
57
obj-$(CONFIG_RV_MON_WWNR) += monitors/wwnr/wwnr.o

kernel/trace/rv/monitors/wip/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
config RV_MON_WIP
2+
depends on RV
3+
depends on PREEMPT_TRACER
4+
select DA_MON_EVENTS_IMPLICIT
5+
bool "wip monitor"
6+
help
7+
Enable wip (wakeup in preemptive) sample monitor that illustrates
8+
the usage of per-cpu monitors, and one limitation of the
9+
preempt_disable/enable events.
10+
11+
For further information, see:
12+
Documentation/trace/rv/monitor_wip.rst

kernel/trace/rv/monitors/wip/wip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#define MODULE_NAME "wip"
1212

13-
#include <trace/events/rv.h>
13+
#include <rv_trace.h>
1414
#include <trace/events/sched.h>
1515
#include <trace/events/preemptirq.h>
1616

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
/*
4+
* Snippet to be included in rv_trace.h
5+
*/
6+
7+
#ifdef CONFIG_RV_MON_WIP
8+
DEFINE_EVENT(event_da_monitor, event_wip,
9+
TP_PROTO(char *state, char *event, char *next_state, bool final_state),
10+
TP_ARGS(state, event, next_state, final_state));
11+
12+
DEFINE_EVENT(error_da_monitor, error_wip,
13+
TP_PROTO(char *state, char *event),
14+
TP_ARGS(state, event));
15+
#endif /* CONFIG_RV_MON_WIP */

kernel/trace/rv/monitors/wwnr/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
config RV_MON_WWNR
2+
depends on RV
3+
select DA_MON_EVENTS_ID
4+
bool "wwnr monitor"
5+
help
6+
Enable wwnr (wakeup while not running) sample monitor, this is a
7+
sample monitor that illustrates the usage of per-task monitor.
8+
The model is borken on purpose: it serves to test reactors.
9+
10+
For further information, see:
11+
Documentation/trace/rv/monitor_wwnr.rst

kernel/trace/rv/monitors/wwnr/wwnr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#define MODULE_NAME "wwnr"
1212

13-
#include <trace/events/rv.h>
13+
#include <rv_trace.h>
1414
#include <trace/events/sched.h>
1515

1616
#include "wwnr.h"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
/*
4+
* Snippet to be included in rv_trace.h
5+
*/
6+
7+
#ifdef CONFIG_RV_MON_WWNR
8+
/* id is the pid of the task */
9+
DEFINE_EVENT(event_da_monitor_id, event_wwnr,
10+
TP_PROTO(int id, char *state, char *event, char *next_state, bool final_state),
11+
TP_ARGS(id, state, event, next_state, final_state));
12+
13+
DEFINE_EVENT(error_da_monitor_id, error_wwnr,
14+
TP_PROTO(int id, char *state, char *event),
15+
TP_ARGS(id, state, event));
16+
#endif /* CONFIG_RV_MON_WWNR */

kernel/trace/rv/rv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145

146146
#ifdef CONFIG_DA_MON_EVENTS
147147
#define CREATE_TRACE_POINTS
148-
#include <trace/events/rv.h>
148+
#include <rv_trace.h>
149149
#endif
150150

151151
#include "rv.h"

include/trace/events/rv.h renamed to kernel/trace/rv/rv_trace.h

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,8 @@ DECLARE_EVENT_CLASS(error_da_monitor,
5757
__entry->state)
5858
);
5959

60-
#ifdef CONFIG_RV_MON_WIP
61-
DEFINE_EVENT(event_da_monitor, event_wip,
62-
TP_PROTO(char *state, char *event, char *next_state, bool final_state),
63-
TP_ARGS(state, event, next_state, final_state));
64-
65-
DEFINE_EVENT(error_da_monitor, error_wip,
66-
TP_PROTO(char *state, char *event),
67-
TP_ARGS(state, event));
68-
#endif /* CONFIG_RV_MON_WIP */
60+
#include <monitors/wip/wip_trace.h>
61+
6962
#endif /* CONFIG_DA_MON_EVENTS_IMPLICIT */
7063

7164
#ifdef CONFIG_DA_MON_EVENTS_ID
@@ -123,20 +116,13 @@ DECLARE_EVENT_CLASS(error_da_monitor_id,
123116
__entry->state)
124117
);
125118

126-
#ifdef CONFIG_RV_MON_WWNR
127-
/* id is the pid of the task */
128-
DEFINE_EVENT(event_da_monitor_id, event_wwnr,
129-
TP_PROTO(int id, char *state, char *event, char *next_state, bool final_state),
130-
TP_ARGS(id, state, event, next_state, final_state));
131-
132-
DEFINE_EVENT(error_da_monitor_id, error_wwnr,
133-
TP_PROTO(int id, char *state, char *event),
134-
TP_ARGS(id, state, event));
135-
#endif /* CONFIG_RV_MON_WWNR */
119+
#include <monitors/wwnr/wwnr_trace.h>
136120

137121
#endif /* CONFIG_DA_MON_EVENTS_ID */
138122
#endif /* _TRACE_RV_H */
139123

140124
/* This part ust be outside protection */
141125
#undef TRACE_INCLUDE_PATH
126+
#define TRACE_INCLUDE_PATH .
127+
#define TRACE_INCLUDE_FILE rv_trace
142128
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)