Skip to content

Commit 560473f

Browse files
glemcorostedt
authored andcommitted
verification/rvgen: Organise Kconfig entries for nested monitors
The current behaviour of rvgen when running with the -a option is to append the necessary lines at the end of the configuration for Kconfig, Makefile and tracepoints. This is not always the desired behaviour in case of nested monitors: while tracepoints are not affected by nesting and the Makefile's only requirement is that the parent monitor is built before its children, in the Kconfig it is better to have children defined right after their parent, otherwise the result has wrong indentation: [*] foo_parent monitor [*] foo_child1 monitor [*] foo_child2 monitor [*] bar_parent monitor [*] bar_child1 monitor [*] bar_child2 monitor [*] foo_child3 monitor [*] foo_child4 monitor Adapt rvgen to look for a different marker for nested monitors in the Kconfig file and append the line right after the last sibling, instead of the last monitor. Also add the marker when creating a new parent monitor. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Tomas Glozar <tglozar@redhat.com> Cc: Juri Lelli <jlelli@redhat.com> Cc: Clark Williams <williams@redhat.com> Cc: John Kacur <jkacur@redhat.com> Link: https://lore.kernel.org/20250723161240.194860-5-gmonaco@redhat.com Reviewed-by: Nam Cao <namcao@linutronix.de> Signed-off-by: Gabriele Monaco <gmonaco@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 9efcf59 commit 560473f

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

kernel/trace/rv/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,21 @@ config RV_PER_TASK_MONITORS
4343

4444
source "kernel/trace/rv/monitors/wip/Kconfig"
4545
source "kernel/trace/rv/monitors/wwnr/Kconfig"
46+
4647
source "kernel/trace/rv/monitors/sched/Kconfig"
4748
source "kernel/trace/rv/monitors/tss/Kconfig"
4849
source "kernel/trace/rv/monitors/sco/Kconfig"
4950
source "kernel/trace/rv/monitors/snroc/Kconfig"
5051
source "kernel/trace/rv/monitors/scpd/Kconfig"
5152
source "kernel/trace/rv/monitors/snep/Kconfig"
5253
source "kernel/trace/rv/monitors/sncid/Kconfig"
54+
# Add new sched monitors here
55+
5356
source "kernel/trace/rv/monitors/rtapp/Kconfig"
5457
source "kernel/trace/rv/monitors/pagefault/Kconfig"
5558
source "kernel/trace/rv/monitors/sleep/Kconfig"
59+
# Add new rtapp monitors here
60+
5661
# Add new monitors here
5762

5863
config RV_REACTORS

tools/verification/rvgen/rvgen/container.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,13 @@ def fill_model_h(self):
2020
main_h = self.main_h
2121
main_h = main_h.replace("%%MODEL_NAME%%", self.name)
2222
return main_h
23+
24+
def fill_kconfig_tooltip(self):
25+
"""Override to produce a marker for this container in the Kconfig"""
26+
container_marker = self._kconfig_marker(self.name) + "\n"
27+
result = super().fill_kconfig_tooltip()
28+
if self.auto_patch:
29+
self._patch_file("Kconfig",
30+
self._kconfig_marker(), container_marker)
31+
return result
32+
return result + container_marker

tools/verification/rvgen/rvgen/generator.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ def fill_kconfig(self):
137137
kconfig = kconfig.replace("%%MONITOR_DEPS%%", monitor_deps)
138138
return kconfig
139139

140-
def __patch_file(self, file, marker, line):
140+
def _patch_file(self, file, marker, line):
141+
assert self.auto_patch
141142
file_to_patch = os.path.join(self.rv_dir, file)
142143
content = self._read_file(file_to_patch)
143144
content = content.replace(marker, line + "\n" + marker)
@@ -146,7 +147,7 @@ def __patch_file(self, file, marker, line):
146147
def fill_tracepoint_tooltip(self):
147148
monitor_class_type = self.fill_monitor_class_type()
148149
if self.auto_patch:
149-
self.__patch_file("rv_trace.h",
150+
self._patch_file("rv_trace.h",
150151
"// Add new monitors based on CONFIG_%s here" % monitor_class_type,
151152
"#include <monitors/%s/%s_trace.h>" % (self.name, self.name))
152153
return " - Patching %s/rv_trace.h, double check the result" % self.rv_dir
@@ -156,10 +157,15 @@ def fill_tracepoint_tooltip(self):
156157
#include <monitors/%s/%s_trace.h>
157158
""" % (self.rv_dir, monitor_class_type, self.name, self.name)
158159

160+
def _kconfig_marker(self, container=None) -> str:
161+
return "# Add new %smonitors here" % (container + " "
162+
if container else "")
163+
159164
def fill_kconfig_tooltip(self):
160165
if self.auto_patch:
161-
self.__patch_file("Kconfig",
162-
"# Add new monitors here",
166+
# monitors with a container should stay together in the Kconfig
167+
self._patch_file("Kconfig",
168+
self._kconfig_marker(self.parent),
163169
"source \"kernel/trace/rv/monitors/%s/Kconfig\"" % (self.name))
164170
return " - Patching %s/Kconfig, double check the result" % self.rv_dir
165171

@@ -172,7 +178,7 @@ def fill_makefile_tooltip(self):
172178
name = self.name
173179
name_up = name.upper()
174180
if self.auto_patch:
175-
self.__patch_file("Makefile",
181+
self._patch_file("Makefile",
176182
"# Add new monitors here",
177183
"obj-$(CONFIG_RV_MON_%s) += monitors/%s/%s.o" % (name_up, name, name))
178184
return " - Patching %s/Makefile, double check the result" % self.rv_dir

0 commit comments

Comments
 (0)