]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rv: Allow to configure the number of per-task monitor
authorNam Cao <namcao@linutronix.de>
Wed, 9 Jul 2025 19:21:23 +0000 (21:21 +0200)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 9 Jul 2025 19:27:02 +0000 (15:27 -0400)
Now that there are 2 monitors for real-time applications, users may want to
enable both of them simultaneously. Make the number of per-task monitor
configurable. Default it to 2 for now.

Cc: John Ogness <john.ogness@linutronix.de>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/93e83313fc4ba7f6e66f4abe80ca5f5494d658d0.1752088709.git.namcao@linutronix.de
Reviewed-by: Gabriele Monaco <gmonaco@redhat.com>
Signed-off-by: Nam Cao <namcao@linutronix.de>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
include/linux/rv.h
include/linux/sched.h
kernel/trace/rv/Kconfig
kernel/trace/rv/monitors/rtapp/Kconfig
kernel/trace/rv/rv.c

index 1d5579f9b75afefd9cec6c8bc201ce3769768376..97baf58d88b282ca18be2ab7cc7fb6a809dee55f 100644 (file)
@@ -75,14 +75,7 @@ struct ltl_monitor {};
 
 #endif /* CONFIG_RV_LTL_MONITOR */
 
-/*
- * Per-task RV monitors count. Nowadays fixed in RV_PER_TASK_MONITORS.
- * If we find justification for more monitors, we can think about
- * adding more or developing a dynamic method. So far, none of
- * these are justified.
- */
-#define RV_PER_TASK_MONITORS           1
-#define RV_PER_TASK_MONITOR_INIT       (RV_PER_TASK_MONITORS)
+#define RV_PER_TASK_MONITOR_INIT       (CONFIG_RV_PER_TASK_MONITORS)
 
 union rv_task_monitor {
        struct da_monitor       da_mon;
index 4f78a64beb52c425e46c66427b2f608ba30b3d99..fabd7fe1a07a506b0c5fb2d62914e829628e73de 100644 (file)
@@ -1642,12 +1642,10 @@ struct task_struct {
 
 #ifdef CONFIG_RV
        /*
-        * Per-task RV monitor. Nowadays fixed in RV_PER_TASK_MONITORS.
-        * If we find justification for more monitors, we can think
-        * about adding more or developing a dynamic method. So far,
-        * none of these are justified.
+        * Per-task RV monitor, fixed in CONFIG_RV_PER_TASK_MONITORS.
+        * If memory becomes a concern, we can think about a dynamic method.
         */
-       union rv_task_monitor           rv[RV_PER_TASK_MONITORS];
+       union rv_task_monitor           rv[CONFIG_RV_PER_TASK_MONITORS];
 #endif
 
 #ifdef CONFIG_USER_EVENTS
index 942d57575e67b32ae830f04d0f10019974e86510..c11bf7e61ebf00fba12618e1a2a2f2a6de9e4327 100644 (file)
@@ -32,6 +32,15 @@ menuconfig RV
          For further information, see:
            Documentation/trace/rv/runtime-verification.rst
 
+config RV_PER_TASK_MONITORS
+       int "Maximum number of per-task monitor"
+       depends on RV
+       range 1 8
+       default 2
+       help
+         This option configures the maximum number of per-task RV monitors that can run
+         simultaneously.
+
 source "kernel/trace/rv/monitors/wip/Kconfig"
 source "kernel/trace/rv/monitors/wwnr/Kconfig"
 source "kernel/trace/rv/monitors/sched/Kconfig"
index b7415c3570bb99696739bd8acaacd67cde3c7540..1ce9370a9ba81b3734df46580e6e7808c5080a7f 100644 (file)
@@ -1,5 +1,6 @@
 config RV_MON_RTAPP
        depends on RV
+       depends on RV_PER_TASK_MONITORS >= 2
        bool "rtapp monitor"
        help
          Collection of monitors to check for common problems with real-time
index e25d65fe432a6bd4ce21bf9c0a5f609cc23b153c..108429d16ec122485300be094f517ac6cd94310b 100644 (file)
@@ -165,7 +165,7 @@ struct dentry *get_monitors_root(void)
 LIST_HEAD(rv_monitors_list);
 
 static int task_monitor_count;
-static bool task_monitor_slots[RV_PER_TASK_MONITORS];
+static bool task_monitor_slots[CONFIG_RV_PER_TASK_MONITORS];
 
 int rv_get_task_monitor_slot(void)
 {
@@ -173,12 +173,12 @@ int rv_get_task_monitor_slot(void)
 
        lockdep_assert_held(&rv_interface_lock);
 
-       if (task_monitor_count == RV_PER_TASK_MONITORS)
+       if (task_monitor_count == CONFIG_RV_PER_TASK_MONITORS)
                return -EBUSY;
 
        task_monitor_count++;
 
-       for (i = 0; i < RV_PER_TASK_MONITORS; i++) {
+       for (i = 0; i < CONFIG_RV_PER_TASK_MONITORS; i++) {
                if (task_monitor_slots[i] == false) {
                        task_monitor_slots[i] = true;
                        return i;
@@ -194,7 +194,7 @@ void rv_put_task_monitor_slot(int slot)
 {
        lockdep_assert_held(&rv_interface_lock);
 
-       if (slot < 0 || slot >= RV_PER_TASK_MONITORS) {
+       if (slot < 0 || slot >= CONFIG_RV_PER_TASK_MONITORS) {
                WARN_ONCE(1, "RV releasing an invalid slot!: %d\n", slot);
                return;
        }