Runtime verifier and osnoise fixes for 6.14:

- Reset idle tasks on reset for runtime verifier
 
   When the runtime verifier is reset, it resets the task's data that is being
   monitored. But it only iterates for_each_process() which does not include
   the idle tasks. As the idle tasks can be monitored, they need to be reset
   as well.
 
 - Fix the enabling and disabling of tracepoints in osnoise
 
   If timerlat is enabled and the WORKLOAD flag is not set, then the osnoise
   tracer will enable the migrate task tracepoint to monitor it for its own
   workload. The test to enable the tracepoint is done against user space
   modifiable parameters. On disabling of the tracer, those same parameters
   are used to determine if the tracepoint should be disabled. The problem is
   if user space were to modify the parameters after it enables the tracer
   then it may not disable the tracepoint.
 
   Instead, a static variable is used to keep track if the tracepoint was
   enabled or not. Then when the tracer shuts down, it will use this variable
   to decide to disable the tracepoint or not, instead of looking at the user
   space parameters.
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYIADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCZ5UJ1BQccm9zdGVkdEBn
 b29kbWlzLm9yZwAKCRAp5XQQmuv6qo46AQDjr1yVTyUmzvxe1bMLDoDOq1xeRMRe
 4f8CdpOJRxbi0QEAwnl5Ey9Rvcuy8GFpt/USESr4VYWAN10fvsPx7pkphAs=
 =RYyn
 -----END PGP SIGNATURE-----

Merge tag 'trace-rv-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull runtime verifier and osnoise fixes from Steven Rostedt:

 - Reset idle tasks on reset for runtime verifier

   When the runtime verifier is reset, it resets the task's data that is
   being monitored. But it only iterates for_each_process() which does
   not include the idle tasks. As the idle tasks can be monitored, they
   need to be reset as well.

 - Fix the enabling and disabling of tracepoints in osnoise

   If timerlat is enabled and the WORKLOAD flag is not set, then the
   osnoise tracer will enable the migrate task tracepoint to monitor it
   for its own workload. The test to enable the tracepoint is done
   against user space modifiable parameters. On disabling of the tracer,
   those same parameters are used to determine if the tracepoint should
   be disabled. The problem is if user space were to modify the
   parameters after it enables the tracer then it may not disable the
   tracepoint.

   Instead, a static variable is used to keep track if the tracepoint
   was enabled or not. Then when the tracer shuts down, it will use this
   variable to decide to disable the tracepoint or not, instead of
   looking at the user space parameters.

* tag 'trace-rv-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  tracing/osnoise: Fix resetting of tracepoints
  rv: Reset per-task monitors also for idle tasks
This commit is contained in:
Linus Torvalds 2025-01-26 14:19:45 -08:00
commit 90ab2117f4
2 changed files with 18 additions and 3 deletions

View File

@ -14,6 +14,7 @@
#include <rv/automata.h>
#include <linux/rv.h>
#include <linux/bug.h>
#include <linux/sched.h>
#ifdef CONFIG_RV_REACTORS
@ -324,10 +325,13 @@ static inline struct da_monitor *da_get_monitor_##name(struct task_struct *tsk)
static void da_monitor_reset_all_##name(void) \
{ \
struct task_struct *g, *p; \
int cpu; \
\
read_lock(&tasklist_lock); \
for_each_process_thread(g, p) \
da_monitor_reset_##name(da_get_monitor_##name(p)); \
for_each_present_cpu(cpu) \
da_monitor_reset_##name(da_get_monitor_##name(idle_task(cpu))); \
read_unlock(&tasklist_lock); \
} \
\

View File

@ -1229,6 +1229,8 @@ static void trace_sched_migrate_callback(void *data, struct task_struct *p, int
}
}
static bool monitor_enabled;
static int register_migration_monitor(void)
{
int ret = 0;
@ -1237,16 +1239,25 @@ static int register_migration_monitor(void)
* Timerlat thread migration check is only required when running timerlat in user-space.
* Thus, enable callback only if timerlat is set with no workload.
*/
if (timerlat_enabled() && !test_bit(OSN_WORKLOAD, &osnoise_options))
if (timerlat_enabled() && !test_bit(OSN_WORKLOAD, &osnoise_options)) {
if (WARN_ON_ONCE(monitor_enabled))
return 0;
ret = register_trace_sched_migrate_task(trace_sched_migrate_callback, NULL);
if (!ret)
monitor_enabled = true;
}
return ret;
}
static void unregister_migration_monitor(void)
{
if (timerlat_enabled() && !test_bit(OSN_WORKLOAD, &osnoise_options))
unregister_trace_sched_migrate_task(trace_sched_migrate_callback, NULL);
if (!monitor_enabled)
return;
unregister_trace_sched_migrate_task(trace_sched_migrate_callback, NULL);
monitor_enabled = false;
}
#else
static int register_migration_monitor(void)