linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Juri Lelli <jlelli@redhat.com>,
	Clark Williams <williams@redhat.com>,
	Nam Cao <namcao@linutronix.de>,
	Gabriele Monaco <gmonaco@redhat.com>
Subject: [for-next][PATCH 19/25] verification/rvgen: Organise Kconfig entries for nested monitors
Date: Fri, 25 Jul 2025 16:34:16 -0400	[thread overview]
Message-ID: <20250725203427.130326086@kernel.org> (raw)
In-Reply-To: 20250725203357.087558746@kernel.org

From: Gabriele Monaco <gmonaco@redhat.com>

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>
---
 kernel/trace/rv/Kconfig                     |  5 +++++
 tools/verification/rvgen/rvgen/container.py | 10 ++++++++++
 tools/verification/rvgen/rvgen/generator.py | 16 +++++++++++-----
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig
index c11bf7e61ebf..26017378f79b 100644
--- a/kernel/trace/rv/Kconfig
+++ b/kernel/trace/rv/Kconfig
@@ -43,6 +43,7 @@ config RV_PER_TASK_MONITORS
 
 source "kernel/trace/rv/monitors/wip/Kconfig"
 source "kernel/trace/rv/monitors/wwnr/Kconfig"
+
 source "kernel/trace/rv/monitors/sched/Kconfig"
 source "kernel/trace/rv/monitors/tss/Kconfig"
 source "kernel/trace/rv/monitors/sco/Kconfig"
@@ -50,9 +51,13 @@ source "kernel/trace/rv/monitors/snroc/Kconfig"
 source "kernel/trace/rv/monitors/scpd/Kconfig"
 source "kernel/trace/rv/monitors/snep/Kconfig"
 source "kernel/trace/rv/monitors/sncid/Kconfig"
+# Add new sched monitors here
+
 source "kernel/trace/rv/monitors/rtapp/Kconfig"
 source "kernel/trace/rv/monitors/pagefault/Kconfig"
 source "kernel/trace/rv/monitors/sleep/Kconfig"
+# Add new rtapp monitors here
+
 # Add new monitors here
 
 config RV_REACTORS
diff --git a/tools/verification/rvgen/rvgen/container.py b/tools/verification/rvgen/rvgen/container.py
index 47d8ab2ad3ec..51f188530b4d 100644
--- a/tools/verification/rvgen/rvgen/container.py
+++ b/tools/verification/rvgen/rvgen/container.py
@@ -20,3 +20,13 @@ class Container(generator.RVGenerator):
         main_h = self.main_h
         main_h = main_h.replace("%%MODEL_NAME%%", self.name)
         return main_h
+
+    def fill_kconfig_tooltip(self):
+        """Override to produce a marker for this container in the Kconfig"""
+        container_marker = self._kconfig_marker(self.name) + "\n"
+        result = super().fill_kconfig_tooltip()
+        if self.auto_patch:
+            self._patch_file("Kconfig",
+                             self._kconfig_marker(), container_marker)
+            return result
+        return result + container_marker
diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verification/rvgen/rvgen/generator.py
index 19d0078a3803..3441385c1177 100644
--- a/tools/verification/rvgen/rvgen/generator.py
+++ b/tools/verification/rvgen/rvgen/generator.py
@@ -137,7 +137,8 @@ class RVGenerator:
         kconfig = kconfig.replace("%%MONITOR_DEPS%%", monitor_deps)
         return kconfig
 
-    def __patch_file(self, file, marker, line):
+    def _patch_file(self, file, marker, line):
+        assert self.auto_patch
         file_to_patch = os.path.join(self.rv_dir, file)
         content = self._read_file(file_to_patch)
         content = content.replace(marker, line + "\n" + marker)
@@ -146,7 +147,7 @@ class RVGenerator:
     def fill_tracepoint_tooltip(self):
         monitor_class_type = self.fill_monitor_class_type()
         if self.auto_patch:
-            self.__patch_file("rv_trace.h",
+            self._patch_file("rv_trace.h",
                             "// Add new monitors based on CONFIG_%s here" % monitor_class_type,
                             "#include <monitors/%s/%s_trace.h>" % (self.name, self.name))
             return "  - Patching %s/rv_trace.h, double check the result" % self.rv_dir
@@ -156,10 +157,15 @@ Add this line where other tracepoints are included and %s is defined:
 #include <monitors/%s/%s_trace.h>
 """ % (self.rv_dir, monitor_class_type, self.name, self.name)
 
+    def _kconfig_marker(self, container=None) -> str:
+        return "# Add new %smonitors here" % (container + " "
+                                              if container else "")
+
     def fill_kconfig_tooltip(self):
         if self.auto_patch:
-            self.__patch_file("Kconfig",
-                            "# Add new monitors here",
+            # monitors with a container should stay together in the Kconfig
+            self._patch_file("Kconfig",
+                             self._kconfig_marker(self.parent),
                             "source \"kernel/trace/rv/monitors/%s/Kconfig\"" % (self.name))
             return "  - Patching %s/Kconfig, double check the result" % self.rv_dir
 
@@ -172,7 +178,7 @@ source \"kernel/trace/rv/monitors/%s/Kconfig\"
         name = self.name
         name_up = name.upper()
         if self.auto_patch:
-            self.__patch_file("Makefile",
+            self._patch_file("Makefile",
                             "# Add new monitors here",
                             "obj-$(CONFIG_RV_MON_%s) += monitors/%s/%s.o" % (name_up, name, name))
             return "  - Patching %s/Makefile, double check the result" % self.rv_dir
-- 
2.47.2



  parent reply	other threads:[~2025-07-25 20:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-25 20:33 [for-next][PATCH 00/25] rv/verfication: Updatse for v6.17 Steven Rostedt
2025-07-25 20:33 ` [for-next][PATCH 01/25] objtool: Add vpanic() to the noreturn list Steven Rostedt
2025-07-25 20:33 ` [for-next][PATCH 02/25] panic: Fix up description of vpanic() Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 03/25] rv/ltl: Do not execute the Buchi automaton twice on start condition Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 04/25] verification/dot2k: Make a separate dot2k_templates/Kconfig_container Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 05/25] verification/dot2k: Remove __buff_to_string() Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 06/25] verification/dot2k: Replace is_container() hack with subparsers Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 07/25] verification/dot2k: Prepare the frontend for LTL inclusion Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 08/25] Documentation/rv: Prepare monitor synthesis document " Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 09/25] verification/rvgen: Restructure the templates files Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 10/25] verification/rvgen: Restructure the classes to prepare for LTL inclusion Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 11/25] verification/rvgen: Add support for linear temporal logic Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 12/25] Documentation/rv: Add documentation for linear temporal logic monitors Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 13/25] verification/rvgen: Support the next operator Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 14/25] verification/rvgen: Generate each variable definition only once Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 15/25] verification/rvgen: Do not generate unused variables Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 16/25] tools/rv: Do not skip idle in trace Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 17/25] tools/rv: Stop gracefully also on SIGTERM Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 18/25] tools/dot2c: Fix generated files going over 100 column limit Steven Rostedt
2025-07-25 20:34 ` Steven Rostedt [this message]
2025-07-25 20:34 ` [for-next][PATCH 20/25] rv: Return init error when registering monitors Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 21/25] rv: Remove unused field in struct rv_monitor_def Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 22/25] rv: Merge struct rv_monitor_def into struct rv_monitor Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 23/25] rv: Merge struct rv_reactor_def into struct rv_reactor Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 24/25] rv: Remove rv_reactors reference counter Steven Rostedt
2025-07-25 20:34 ` [for-next][PATCH 25/25] rv: Remove struct rv_monitor::reacting Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250725203427.130326086@kernel.org \
    --to=rostedt@kernel.org \
    --cc=gmonaco@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=jlelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=namcao@linutronix.de \
    --cc=tglozar@redhat.com \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).