Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gabriele Monaco and committed by
Steven Rostedt (Google)
560473f2 9efcf590

+26 -5
+5
kernel/trace/rv/Kconfig
··· 43 43 44 44 source "kernel/trace/rv/monitors/wip/Kconfig" 45 45 source "kernel/trace/rv/monitors/wwnr/Kconfig" 46 + 46 47 source "kernel/trace/rv/monitors/sched/Kconfig" 47 48 source "kernel/trace/rv/monitors/tss/Kconfig" 48 49 source "kernel/trace/rv/monitors/sco/Kconfig" ··· 51 50 source "kernel/trace/rv/monitors/scpd/Kconfig" 52 51 source "kernel/trace/rv/monitors/snep/Kconfig" 53 52 source "kernel/trace/rv/monitors/sncid/Kconfig" 53 + # Add new sched monitors here 54 + 54 55 source "kernel/trace/rv/monitors/rtapp/Kconfig" 55 56 source "kernel/trace/rv/monitors/pagefault/Kconfig" 56 57 source "kernel/trace/rv/monitors/sleep/Kconfig" 58 + # Add new rtapp monitors here 59 + 57 60 # Add new monitors here 58 61 59 62 config RV_REACTORS
+10
tools/verification/rvgen/rvgen/container.py
··· 20 20 main_h = self.main_h 21 21 main_h = main_h.replace("%%MODEL_NAME%%", self.name) 22 22 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
+11 -5
tools/verification/rvgen/rvgen/generator.py
··· 137 137 kconfig = kconfig.replace("%%MONITOR_DEPS%%", monitor_deps) 138 138 return kconfig 139 139 140 - def __patch_file(self, file, marker, line): 140 + def _patch_file(self, file, marker, line): 141 + assert self.auto_patch 141 142 file_to_patch = os.path.join(self.rv_dir, file) 142 143 content = self._read_file(file_to_patch) 143 144 content = content.replace(marker, line + "\n" + marker) ··· 147 146 def fill_tracepoint_tooltip(self): 148 147 monitor_class_type = self.fill_monitor_class_type() 149 148 if self.auto_patch: 150 - self.__patch_file("rv_trace.h", 149 + self._patch_file("rv_trace.h", 151 150 "// Add new monitors based on CONFIG_%s here" % monitor_class_type, 152 151 "#include <monitors/%s/%s_trace.h>" % (self.name, self.name)) 153 152 return " - Patching %s/rv_trace.h, double check the result" % self.rv_dir ··· 157 156 #include <monitors/%s/%s_trace.h> 158 157 """ % (self.rv_dir, monitor_class_type, self.name, self.name) 159 158 159 + def _kconfig_marker(self, container=None) -> str: 160 + return "# Add new %smonitors here" % (container + " " 161 + if container else "") 162 + 160 163 def fill_kconfig_tooltip(self): 161 164 if self.auto_patch: 162 - self.__patch_file("Kconfig", 163 - "# Add new monitors here", 165 + # monitors with a container should stay together in the Kconfig 166 + self._patch_file("Kconfig", 167 + self._kconfig_marker(self.parent), 164 168 "source \"kernel/trace/rv/monitors/%s/Kconfig\"" % (self.name)) 165 169 return " - Patching %s/Kconfig, double check the result" % self.rv_dir 166 170 ··· 178 172 name = self.name 179 173 name_up = name.upper() 180 174 if self.auto_patch: 181 - self.__patch_file("Makefile", 175 + self._patch_file("Makefile", 182 176 "# Add new monitors here", 183 177 "obj-$(CONFIG_RV_MON_%s) += monitors/%s/%s.o" % (name_up, name, name)) 184 178 return " - Patching %s/Makefile, double check the result" % self.rv_dir