Skip to content

Commit 8812d21

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
rv/monitor: Add the wip monitor skeleton created by dot2k
THIS CODE IS NOT LINKED TO THE MAKEFILE. This model does not compile because it lacks the instrumentation part, which will be added next. In the typical case, there will be only one patch, but it was split into two patches for educational purposes. This is the direct output this command line: $ dot2k -d tools/verification/models/wip.dot -t per_cpu Link: https://lkml.kernel.org/r/5eb7a9118917e8a814c5e49853a72fc62be0a101.1659052063.git.bristot@kernel.org Cc: Wim Van Sebroeck <[email protected]> Cc: Guenter Roeck <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Will Deacon <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Marco Elver <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Gabriele Paoloni <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Clark Williams <[email protected]> Cc: Tao Zhou <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent b6172b5 commit 8812d21

File tree

2 files changed

+155
-0
lines changed

2 files changed

+155
-0
lines changed

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

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include <linux/ftrace.h>
3+
#include <linux/tracepoint.h>
4+
#include <linux/kernel.h>
5+
#include <linux/module.h>
6+
#include <linux/init.h>
7+
#include <linux/rv.h>
8+
#include <rv/instrumentation.h>
9+
#include <rv/da_monitor.h>
10+
11+
#define MODULE_NAME "wip"
12+
13+
/*
14+
* XXX: include required tracepoint headers, e.g.,
15+
* #include <linux/trace/events/sched.h>
16+
*/
17+
#include <trace/events/rv.h>
18+
19+
/*
20+
* This is the self-generated part of the monitor. Generally, there is no need
21+
* to touch this section.
22+
*/
23+
#include "wip.h"
24+
25+
/*
26+
* Declare the deterministic automata monitor.
27+
*
28+
* The rv monitor reference is needed for the monitor declaration.
29+
*/
30+
struct rv_monitor rv_wip;
31+
DECLARE_DA_MON_PER_CPU(wip, unsigned char);
32+
33+
/*
34+
* This is the instrumentation part of the monitor.
35+
*
36+
* This is the section where manual work is required. Here the kernel events
37+
* are translated into model's event.
38+
*
39+
*/
40+
static void handle_preempt_disable(void *data, /* XXX: fill header */)
41+
{
42+
da_handle_event_wip(preempt_disable_wip);
43+
}
44+
45+
static void handle_preempt_enable(void *data, /* XXX: fill header */)
46+
{
47+
da_handle_event_wip(preempt_enable_wip);
48+
}
49+
50+
static void handle_sched_waking(void *data, /* XXX: fill header */)
51+
{
52+
da_handle_event_wip(sched_waking_wip);
53+
}
54+
55+
static int enable_wip(void)
56+
{
57+
int retval;
58+
59+
retval = da_monitor_init_wip();
60+
if (retval)
61+
return retval;
62+
63+
rv_attach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_disable);
64+
rv_attach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_enable);
65+
rv_attach_trace_probe("wip", /* XXX: tracepoint */, handle_sched_waking);
66+
67+
return 0;
68+
}
69+
70+
static void disable_wip(void)
71+
{
72+
rv_wip.enabled = 0;
73+
74+
rv_detach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_disable);
75+
rv_detach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_enable);
76+
rv_detach_trace_probe("wip", /* XXX: tracepoint */, handle_sched_waking);
77+
78+
da_monitor_destroy_wip();
79+
}
80+
81+
/*
82+
* This is the monitor register section.
83+
*/
84+
struct rv_monitor rv_wip = {
85+
.name = "wip",
86+
.description = "auto-generated wip",
87+
.enable = enable_wip,
88+
.disable = disable_wip,
89+
.reset = da_monitor_reset_all_wip,
90+
.enabled = 0,
91+
};
92+
93+
static int register_wip(void)
94+
{
95+
rv_register_monitor(&rv_wip);
96+
return 0;
97+
}
98+
99+
static void unregister_wip(void)
100+
{
101+
rv_unregister_monitor(&rv_wip);
102+
}
103+
104+
module_init(register_wip);
105+
module_exit(unregister_wip);
106+
107+
MODULE_LICENSE("GPL");
108+
MODULE_AUTHOR("dot2k: auto-generated");
109+
MODULE_DESCRIPTION("wip");

kernel/trace/rv/monitors/wip/wip.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Automatically generated C representation of wip automaton
3+
* For further information about this format, see kernel documentation:
4+
* Documentation/trace/rv/deterministic_automata.rst
5+
*/
6+
7+
enum states_wip {
8+
preemptive_wip = 0,
9+
non_preemptive_wip,
10+
state_max_wip
11+
};
12+
13+
#define INVALID_STATE state_max_wip
14+
15+
enum events_wip {
16+
preempt_disable_wip = 0,
17+
preempt_enable_wip,
18+
sched_waking_wip,
19+
event_max_wip
20+
};
21+
22+
struct automaton_wip {
23+
char *state_names[state_max_wip];
24+
char *event_names[event_max_wip];
25+
unsigned char function[state_max_wip][event_max_wip];
26+
unsigned char initial_state;
27+
bool final_states[state_max_wip];
28+
};
29+
30+
struct automaton_wip automaton_wip = {
31+
.state_names = {
32+
"preemptive",
33+
"non_preemptive"
34+
},
35+
.event_names = {
36+
"preempt_disable",
37+
"preempt_enable",
38+
"sched_waking"
39+
},
40+
.function = {
41+
{ non_preemptive_wip, INVALID_STATE, INVALID_STATE },
42+
{ INVALID_STATE, preemptive_wip, non_preemptive_wip },
43+
},
44+
.initial_state = preemptive_wip,
45+
.final_states = { 1, 0 },
46+
};

0 commit comments

Comments
 (0)