Skip to content

Commit ca08e07

Browse files
glemcorostedt
authored andcommitted
verification/dot2k: Unify main.c templates
dot2k has 3 templates, one per monitor type, but the only difference among them is the `DECLARE_DA_MON_*` call, keeping 3 almost identical templates requires more work whenever we introduce a change. This patch removes the 3 dot2k templates and replaces them with a generic one, we then adjust the model type from the script. 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 6c432b5 commit ca08e07

File tree

4 files changed

+7
-184
lines changed

4 files changed

+7
-184
lines changed

tools/verification/dot2/dot2k.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, file_path, MonitorType):
2626

2727
self.monitor_type = MonitorType
2828
self.__fill_rv_templates_dir()
29-
self.main_c = self.__open_file(self.monitor_templates_dir + "main_" + MonitorType + ".c")
29+
self.main_c = self.__open_file(self.monitor_templates_dir + "main.c")
3030
self.enum_suffix = "_%s" % self.name
3131

3232
def __fill_rv_templates_dir(self):
@@ -69,6 +69,9 @@ def __buff_to_string(self, buff):
6969
# cut off the last \n
7070
return string[:-1]
7171

72+
def fill_monitor_type(self):
73+
return self.monitor_type.upper()
74+
7275
def fill_tracepoint_handlers_skel(self):
7376
buff = []
7477
for event in self.events:
@@ -97,12 +100,14 @@ def fill_tracepoint_detach_helper(self):
97100

98101
def fill_main_c(self):
99102
main_c = self.main_c
103+
monitor_type = self.fill_monitor_type()
100104
min_type = self.get_minimun_type()
101105
nr_events = len(self.events)
102106
tracepoint_handlers = self.fill_tracepoint_handlers_skel()
103107
tracepoint_attach = self.fill_tracepoint_attach_probe()
104108
tracepoint_detach = self.fill_tracepoint_detach_helper()
105109

110+
main_c = main_c.replace("MONITOR_TYPE", monitor_type)
106111
main_c = main_c.replace("MIN_TYPE", min_type)
107112
main_c = main_c.replace("MODEL_NAME", self.name)
108113
main_c = main_c.replace("NR_EVENTS", str(nr_events))

tools/verification/dot2/dot2k_templates/main_global.c renamed to tools/verification/dot2/dot2k_templates/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* The rv monitor reference is needed for the monitor declaration.
2929
*/
3030
static struct rv_monitor rv_MODEL_NAME;
31-
DECLARE_DA_MON_GLOBAL(MODEL_NAME, MIN_TYPE);
31+
DECLARE_DA_MON_MONITOR_TYPE(MODEL_NAME, MIN_TYPE);
3232

3333
/*
3434
* This is the instrumentation part of the monitor.

tools/verification/dot2/dot2k_templates/main_per_cpu.c

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

tools/verification/dot2/dot2k_templates/main_per_task.c

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

0 commit comments

Comments
 (0)