Commit cb7ca871 authored by Daniel Bristot de Oliveira's avatar Daniel Bristot de Oliveira Committed by Steven Rostedt (Google)

tracing/osnoise: Skip running osnoise if all instances are off

In the case of all tracing instances being off, sleep for the entire
period.

 Q: Why not kill all threads so?
 A: It is valid and useful to start the threads with tracing off.
For example, rtla disables tracing, starts the tracer, applies the
scheduling setup to the threads, e.g., sched priority and cgroup,
and then begin tracing with all set.

Skipping the period helps to speed up rtla setup and save the
trace after a stop tracing.

Link: https://lkml.kernel.org/r/aa4dd9b7e76fcb63901fe5407e15ec002b318599.1686063934.git.bristot@kernel.org

Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: William White <chwhite@redhat.com>
Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 4998e7fd
...@@ -1285,6 +1285,22 @@ static __always_inline void osnoise_stop_tracing(void) ...@@ -1285,6 +1285,22 @@ static __always_inline void osnoise_stop_tracing(void)
rcu_read_unlock(); rcu_read_unlock();
} }
/*
* osnoise_has_tracing_on - Check if there is at least one instance on
*/
static __always_inline int osnoise_has_tracing_on(void)
{
struct osnoise_instance *inst;
int trace_is_on = 0;
rcu_read_lock();
list_for_each_entry_rcu(inst, &osnoise_instances, list)
trace_is_on += tracer_tracing_is_on(inst->tr);
rcu_read_unlock();
return trace_is_on;
}
/* /*
* notify_new_max_latency - Notify a new max latency via fsnotify interface. * notify_new_max_latency - Notify a new max latency via fsnotify interface.
*/ */
...@@ -1517,13 +1533,16 @@ static struct cpumask save_cpumask; ...@@ -1517,13 +1533,16 @@ static struct cpumask save_cpumask;
/* /*
* osnoise_sleep - sleep until the next period * osnoise_sleep - sleep until the next period
*/ */
static void osnoise_sleep(void) static void osnoise_sleep(bool skip_period)
{ {
u64 interval; u64 interval;
ktime_t wake_time; ktime_t wake_time;
mutex_lock(&interface_lock); mutex_lock(&interface_lock);
interval = osnoise_data.sample_period - osnoise_data.sample_runtime; if (skip_period)
interval = osnoise_data.sample_period;
else
interval = osnoise_data.sample_period - osnoise_data.sample_runtime;
mutex_unlock(&interface_lock); mutex_unlock(&interface_lock);
/* /*
...@@ -1604,8 +1623,14 @@ static int osnoise_main(void *data) ...@@ -1604,8 +1623,14 @@ static int osnoise_main(void *data)
if (osnoise_migration_pending()) if (osnoise_migration_pending())
break; break;
/* skip a period if tracing is off on all instances */
if (!osnoise_has_tracing_on()) {
osnoise_sleep(true);
continue;
}
run_osnoise(); run_osnoise();
osnoise_sleep(); osnoise_sleep(false);
} }
migrate_enable(); migrate_enable();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment