tools/rtla: Updates for v6.18
Subsystems (2)
cover tools/rtla: Updates for v6.18
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.gittools/for-next
Head SHA1: 05b7e10687c69e0c28e62b9a74ce78b3e7463806
Costa Shulyupin (1):
tools/rtla: Consolidate common parameters into shared structure
Crystal Wood (6):
tools/rtla: Move top/hist params into common struct tools/rtla: Create common_apply_config()
tools/rtla: Consolidate code between osnoise/timerlat and hist/top tools/rtla: Fix -A option name in test comment tools/rtla: Add test engine support for unexpected output tools/rtla: Add remaining support for osnoise actions
----
Documentation/tools/rtla/common_options.rst | 61 ++ .../tools/rtla/common_osnoise_options.rst | 8 + .../tools/rtla/common_timerlat_options.rst | 74 +-- Documentation/tools/rtla/rtla-hwnoise.rst | 2 + Documentation/tools/rtla/rtla-osnoise-hist.rst | 2 + Documentation/tools/rtla/rtla-osnoise-top.rst | 2 + Documentation/tools/rtla/rtla-timerlat-hist.rst | 2 + Documentation/tools/rtla/rtla-timerlat-top.rst | 2 + tools/tracing/rtla/src/Build | 1 + tools/tracing/rtla/src/actions.c | 8 +- tools/tracing/rtla/src/actions.h | 2 +- tools/tracing/rtla/src/common.c | 344 +++++++++++ tools/tracing/rtla/src/common.h | 154 +++++ tools/tracing/rtla/src/osnoise.c | 101 ++-- tools/tracing/rtla/src/osnoise.h | 114 +--- tools/tracing/rtla/src/osnoise_hist.c | 369 +++++------- tools/tracing/rtla/src/osnoise_top.c | 303 +++------- tools/tracing/rtla/src/timerlat.c | 210 +++++-- tools/tracing/rtla/src/timerlat.h | 55 +- tools/tracing/rtla/src/timerlat_bpf.c | 22 +- tools/tracing/rtla/src/timerlat_hist.c | 642 ++++++--------------- tools/tracing/rtla/src/timerlat_top.c | 568 ++++-------------- tools/tracing/rtla/src/trace.h | 3 - tools/tracing/rtla/tests/engine.sh | 26 +- tools/tracing/rtla/tests/osnoise.t | 27 +- tools/tracing/rtla/tests/timerlat.t | 4 +- 26 files changed, 1395 insertions(+), 1711 deletions(-) create mode 100644 tools/tracing/rtla/src/common.c create mode 100644 tools/tracing/rtla/src/common.h
PATCH 1/7 tools/rtla: Consolidate common parameters into shared structure
From: Costa Shulyupin <[email protected]>
timerlat_params and osnoise_params structures contain 15 identical fields.
Introduce a new header common.h and define a common_params structure to consolidate shared fields, reduce code duplication, and enhance maintainability.
--- tools/tracing/rtla/src/common.h | 30 +++++++ tools/tracing/rtla/src/osnoise.c | 20 ++--- tools/tracing/rtla/src/osnoise.h | 19 +---- tools/tracing/rtla/src/osnoise_hist.c | 92 ++++++++++---------- tools/tracing/rtla/src/osnoise_top.c | 80 ++++++++--------- tools/tracing/rtla/src/timerlat.c | 24 +++--- tools/tracing/rtla/src/timerlat.h | 18 +--- tools/tracing/rtla/src/timerlat_bpf.c | 4 +- tools/tracing/rtla/src/timerlat_hist.c | 113 +++++++++++++------------ tools/tracing/rtla/src/timerlat_top.c | 105 +++++++++++------------ 10 files changed, 253 insertions(+), 252 deletions(-) create mode 100644 tools/tracing/rtla/src/common.h
tools/tracing/rtla/src/common.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#pragma once + +#include "utils.h" + +/* +* common_params - Parameters shared between timerlat_params and osnoise_params +*/ +struct common_params { +/* trace configuration */ +char *cpus; +cpu_set_t monitored_cpus; +struct trace_events *events; +int buffer_size; + +/* Timing parameters */ +int warmup; +long long stop_us; +long long stop_total_us; +int sleep_time; +int duration; + +/* Scheduling parameters */ +int set_sched; +struct sched_attr sched_param; +int cgroup; +char *cgroup_name; +int hk_cpus; +cpu_set_t hk_cpu_set; +};
tools/tracing/rtla/src/osnoise.c +10 -10
@@ -1127,10 +1127,10 @@ osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params) {int retval; -if (!params->sleep_time) - params->sleep_time =1 ; +if (!params->common.sleep_time) + params->common.sleep_time =1 ; - retval =osnoise_set_cpus (tool->context, params->cpus ? params->cpus :"all" ); + retval =osnoise_set_cpus (tool->context, params->common.cpus ? params->common.cpus :"all" );if (retval) {err_msg ("Failed to apply CPUs config\n" ); goto out_err;
@@ -1151,13 +1151,13 @@ osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params) goto out_err; } - retval =osnoise_set_stop_us (tool->context, params->stop_us); + retval =osnoise_set_stop_us (tool->context, params->common.stop_us);if (retval) {err_msg ("Failed to set stop us\n" ); goto out_err; } - retval =osnoise_set_stop_total_us (tool->context, params->stop_total_us); + retval =osnoise_set_stop_total_us (tool->context, params->common.stop_total_us);if (retval) {err_msg ("Failed to set stop total us\n" ); goto out_err;
@@ -1169,14 +1169,14 @@ osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params) goto out_err; } -if (params->hk_cpus) { - retval =sched_setaffinity (getpid (),sizeof (params->hk_cpu_set), - ¶ms->hk_cpu_set); +if (params->common.hk_cpus) { + retval =sched_setaffinity (getpid (),sizeof (params->common.hk_cpu_set), + ¶ms->common.hk_cpu_set);if (retval ==-1 ) {err_msg ("Failed to set rtla to the house keeping CPUs\n" ); goto out_err; } - }else if (params->cpus) { + }else if (params->common.cpus) {/* * Even if the user do not set a house-keeping CPU, try to * move rtla to a CPU set different to the one where the user
@@ -1184,7 +1184,7 @@ osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)* * No need to check results as this is an automatic attempt. */ -auto_house_keeping (¶ms->monitored_cpus); +auto_house_keeping (¶ms->common.monitored_cpus); } retval =osnoise_set_workload (tool->context, true);
tools/tracing/rtla/src/osnoise.h +2 -17
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #pragma once -#include "utils.h" +#include "common.h" #include "trace.h" enum osnoise_mode {
@@ -10,26 +10,11 @@ enum osnoise_mode { }; struct osnoise_params { - /* Common params */ - char *cpus; - cpu_set_t monitored_cpus; + struct common_params common; char *trace_output; - char *cgroup_name; unsigned long long runtime; unsigned long long period; long long threshold; - long long stop_us; - long long stop_total_us; - int sleep_time; - int duration; - int set_sched; - int cgroup; - int hk_cpus; - cpu_set_t hk_cpu_set; - struct sched_attr sched_param; - struct trace_events *events; - int warmup; - int buffer_size; union { struct { /* top only */
tools/tracing/rtla/src/osnoise_hist.c +46 -46
256 lines not on this page · raw message
tools/tracing/rtla/src/osnoise_top.c +40 -40
207 lines not on this page · raw message
tools/tracing/rtla/src/timerlat.c +12 -12
@@ -26,18 +26,18 @@ timerlat_apply_config(struct osnoise_tool *tool, struct timerlat_params *params) {int retval, i; -if (!params->sleep_time) - params->sleep_time =1 ; +if (!params->common.sleep_time) + params->common.sleep_time =1 ; - retval =osnoise_set_cpus (tool->context, params->cpus ? params->cpus :"all" ); + retval =osnoise_set_cpus (tool->context, params->common.cpus ? params->common.cpus :"all" );if (retval) {err_msg ("Failed to apply CPUs config\n" ); goto out_err; } -if (!params->cpus) { +if (!params->common.cpus) {for (i =0 ; i <sysconf (_SC_NPROCESSORS_CONF); i++) -CPU_SET (i, ¶ms->monitored_cpus); +CPU_SET (i, ¶ms->common.monitored_cpus); }if (params->mode !=TRACING_MODE_BPF ) {
@@ -45,13 +45,13 @@ timerlat_apply_config(struct osnoise_tool *tool, struct timerlat_params *params)* In tracefs and mixed mode, timerlat tracer handles stopping * on threshold */ - retval =osnoise_set_stop_us (tool->context, params->stop_us); + retval =osnoise_set_stop_us (tool->context, params->common.stop_us);if (retval) {err_msg ("Failed to set stop us\n" ); goto out_err; } - retval =osnoise_set_stop_total_us (tool->context, params->stop_total_us); + retval =osnoise_set_stop_total_us (tool->context, params->common.stop_total_us);if (retval) {err_msg ("Failed to set stop total us\n" ); goto out_err;
@@ -75,14 +75,14 @@ timerlat_apply_config(struct osnoise_tool *tool, struct timerlat_params *params) goto out_err; } -if (params->hk_cpus) { - retval =sched_setaffinity (getpid (),sizeof (params->hk_cpu_set), - ¶ms->hk_cpu_set); +if (params->common.hk_cpus) { + retval =sched_setaffinity (getpid (),sizeof (params->common.hk_cpu_set), + ¶ms->common.hk_cpu_set);if (retval ==-1 ) {err_msg ("Failed to set rtla to the house keeping CPUs\n" ); goto out_err; } - }else if (params->cpus) { + }else if (params->common.cpus) {/* * Even if the user do not set a house-keeping CPU, try to * move rtla to a CPU set different to the one where the user
@@ -90,7 +90,7 @@ timerlat_apply_config(struct osnoise_tool *tool, struct timerlat_params *params)* * No need to check results as this is an automatic attempt. */ -auto_house_keeping (¶ms->monitored_cpus); +auto_house_keeping (¶ms->common.monitored_cpus); }/*
tools/tracing/rtla/src/timerlat.h +1 -17
@@ -20,33 +20,17 @@ enum timerlat_tracing_mode { };struct timerlat_params { -/* Common params */ -char *cpus; -cpu_set_t monitored_cpus; -char *cgroup_name; -unsigned long long runtime; -long long stop_us; -long long stop_total_us; +struct common_params common;long long timerlat_period_us;long long print_stack; -int sleep_time;int output_divisor; -int duration; -int set_sched;int dma_latency;int no_aa;int dump_tasks; -int cgroup; -int hk_cpus;int user_workload;int kernel_workload;int user_data; -int warmup; -int buffer_size;int deepest_idle_state; -cpu_set_t hk_cpu_set; -struct sched_attr sched_param; -struct trace_events *events;enum timerlat_tracing_mode mode;struct actions threshold_actions;
tools/tracing/rtla/src/timerlat_bpf.c +2 -2
@@ -23,8 +23,8 @@ int timerlat_bpf_init(struct timerlat_params *params)/* Pass common options */ bpf->rodata->output_divisor = params->output_divisor; bpf->rodata->entries = params->entries; - bpf->rodata->irq_threshold = params->stop_us; - bpf->rodata->thread_threshold = params->stop_total_us; + bpf->rodata->irq_threshold = params->common.stop_us; + bpf->rodata->thread_threshold = params->common.stop_total_us; bpf->rodata->aa_only = params->aa_only;if (params->entries !=0 ) {
tools/tracing/rtla/src/timerlat_hist.c +57 -56
317 lines not on this page · raw message
tools/tracing/rtla/src/timerlat_top.c +53 -52
279 lines not on this page · raw message
Signature · 1 line
2.50.1
PATCH 2/7 tools/rtla: Move top/hist params into common struct
In reply to Steven RostedtFrom: Crystal Wood <[email protected]>
The hist members were very similar between timerlat and top, so just use one common hist struct.
output_divisor, quiet, and pretty printing are pretty generic concepts that can go in the main struct even if not every specific tool (currently) uses them.
--- tools/tracing/rtla/src/common.h | 17 ++++ tools/tracing/rtla/src/osnoise.h | 19 +--- tools/tracing/rtla/src/osnoise_hist.c | 59 ++++++------ tools/tracing/rtla/src/osnoise_top.c | 19 ++-- tools/tracing/rtla/src/timerlat.h | 22 +---- tools/tracing/rtla/src/timerlat_bpf.c | 14 +-- tools/tracing/rtla/src/timerlat_hist.c | 127 +++++++++++++------------ tools/tracing/rtla/src/timerlat_top.c | 38 ++++---- 8 files changed, 152 insertions(+), 163 deletions(-)
tools/tracing/rtla/src/common.h +17 -0
@@ -3,6 +3,17 @@#include "utils.h" +struct hist_params { +char no_irq; +char no_thread; +char no_header; +char no_summary; +char no_index; +char with_zeros; +int bucket_size; +int entries; +}; +/* * common_params - Parameters shared between timerlat_params and osnoise_params */
@@ -27,4 +38,10 @@ struct common_params {char *cgroup_name;int hk_cpus;cpu_set_t hk_cpu_set; + +/* Other parameters */ +struct hist_params hist; +int output_divisor; +int pretty_output; +int quiet; };
tools/tracing/rtla/src/osnoise.h +1 -18
@@ -15,24 +15,7 @@ struct osnoise_params {unsigned long long runtime;unsigned long long period;long long threshold; -union { -struct { -/* top only */ -int quiet; -int pretty_output; -enum osnoise_mode mode; - }; -struct { -/* hist only */ -int output_divisor; -char no_header; -char no_summary; -char no_index; -char with_zeros; -int bucket_size; -int entries; - }; - }; +enum osnoise_mode mode; };/*
tools/tracing/rtla/src/osnoise_hist.c +31 -28
171 lines not on this page · raw message
tools/tracing/rtla/src/osnoise_top.c +10 -9
@@ -125,11 +125,12 @@ static void osnoise_top_header(struct osnoise_tool *top) {struct osnoise_params *params = top->params;struct trace_seq *s = top->trace.seq; +bool pretty = params->common.pretty_output;char duration[26 ];get_duration (top->start_time, duration,sizeof (duration)); -if (params->pretty_output) +if (pretty)trace_seq_printf (s,"\033[2;37;40m" );trace_seq_printf (s," " );
@@ -143,13 +144,13 @@ static void osnoise_top_header(struct osnoise_tool *top)trace_seq_printf (s," " ); -if (params->pretty_output) +if (pretty)trace_seq_printf (s,"\033[0;0;0m" );trace_seq_printf (s,"\n" );trace_seq_printf (s,"duration: %9s | time is in us\n" , duration); -if (params->pretty_output) +if (pretty)trace_seq_printf (s,"\033[2;30;47m" );trace_seq_printf (s,"CPU Period Runtime " );
@@ -164,7 +165,7 @@ static void osnoise_top_header(struct osnoise_tool *top)trace_seq_printf (s," IRQ Softirq Thread" ); eol: -if (params->pretty_output) +if (pretty)trace_seq_printf (s,"\033[0;0;0m" );trace_seq_printf (s,"\n" ); }
@@ -232,7 +233,7 @@ osnoise_print_stats(struct osnoise_params *params, struct osnoise_tool *top)if (nr_cpus ==-1 ) nr_cpus =sysconf (_SC_NPROCESSORS_CONF); -if (!params->quiet) +if (!params->common.quiet)clear_terminal (trace->seq);osnoise_top_header (top);
@@ -446,7 +447,7 @@ struct osnoise_params *osnoise_top_parse_args(int argc, char **argv) params->common.set_sched =1 ;break ;case 'q' : - params->quiet =1 ; + params->common.quiet =1 ;break ;case 'r' : params->runtime =get_llong_from_str (optarg);
@@ -534,8 +535,8 @@ osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_params *param } } -if (isatty (STDOUT_FILENO ) && !params->quiet) - params->pretty_output =1 ; +if (isatty (STDOUT_FILENO ) && !params->common.quiet) + params->common.pretty_output =1 ;return 0 ;
@@ -705,7 +706,7 @@ int osnoise_top_main(int argc, char **argv) goto out_top; } -if (!params->quiet) +if (!params->common.quiet)osnoise_print_stats (params, tool);if (osnoise_trace_is_off (tool, record))
tools/tracing/rtla/src/timerlat.h +1 -21
@@ -23,7 +23,6 @@ struct timerlat_params {struct common_params common;long long timerlat_period_us;long long print_stack; -int output_divisor;int dma_latency;int no_aa;int dump_tasks;
@@ -31,30 +30,11 @@ struct timerlat_params {int kernel_workload;int user_data;int deepest_idle_state; +int aa_only;enum timerlat_tracing_mode mode;struct actions threshold_actions;struct actions end_actions; - -union { -struct { -/* top only */ -int quiet; -int aa_only; -int pretty_output; - }; -struct { -/* hist only */ -char no_irq; -char no_thread; -char no_header; -char no_summary; -char no_index; -char with_zeros; -int bucket_size; -int entries; - }; - }; };int timerlat_apply_config (struct osnoise_tool *tool,struct timerlat_params *params);
tools/tracing/rtla/src/timerlat_bpf.c +7 -7
@@ -21,20 +21,20 @@ int timerlat_bpf_init(struct timerlat_params *params)return 1 ;/* Pass common options */ - bpf->rodata->output_divisor = params->output_divisor; - bpf->rodata->entries = params->entries; + bpf->rodata->output_divisor = params->common.output_divisor; + bpf->rodata->entries = params->common.hist.entries; bpf->rodata->irq_threshold = params->common.stop_us; bpf->rodata->thread_threshold = params->common.stop_total_us; bpf->rodata->aa_only = params->aa_only; -if (params->entries !=0 ) { +if (params->common.hist.entries !=0 ) {/* Pass histogram options */ - bpf->rodata->bucket_size = params->bucket_size; + bpf->rodata->bucket_size = params->common.hist.bucket_size;/* Set histogram array sizes */ -bpf_map__set_max_entries (bpf->maps.hist_irq, params->entries); -bpf_map__set_max_entries (bpf->maps.hist_thread, params->entries); -bpf_map__set_max_entries (bpf->maps.hist_user, params->entries); +bpf_map__set_max_entries (bpf->maps.hist_irq, params->common.hist.entries); +bpf_map__set_max_entries (bpf->maps.hist_thread, params->common.hist.entries); +bpf_map__set_max_entries (bpf->maps.hist_user, params->common.hist.entries); }else {/* No entries, disable histogram */ bpf_map__set_autocreate (bpf->maps.hist_irq, false);
tools/tracing/rtla/src/timerlat_hist.c +65 -62
381 lines not on this page · raw message
tools/tracing/rtla/src/timerlat_top.c +20 -18
@@ -132,8 +132,8 @@ timerlat_top_update(struct osnoise_tool *tool, int cpu,struct timerlat_top_data *data = tool->data;struct timerlat_top_cpu *cpu_data = &data->cpu_data[cpu]; -if (params->output_divisor) - latency = latency / params->output_divisor; +if (params->common.output_divisor) + latency = latency / params->common.output_divisor;if (!thread) { cpu_data->irq_count++;
@@ -258,39 +258,40 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)static void timerlat_top_header (struct timerlat_params *params,struct osnoise_tool *top) {struct trace_seq *s = top->trace.seq; +bool pretty = params->common.pretty_output;char duration[26 ];get_duration (top->start_time, duration,sizeof (duration)); -if (params->pretty_output) +if (pretty)trace_seq_printf (s,"\033[2;37;40m" );trace_seq_printf (s," Timer Latency " );if (params->user_data)trace_seq_printf (s," " ); -if (params->pretty_output) +if (pretty)trace_seq_printf (s,"\033[0;0;0m" );trace_seq_printf (s,"\n" );trace_seq_printf (s,"%-6s | IRQ Timer Latency (%s) | Thread Timer Latency (%s)" , duration, - params->output_divisor ==1 ?"ns" :"us" , - params->output_divisor ==1 ?"ns" :"us" ); + params->common.output_divisor ==1 ?"ns" :"us" , + params->common.output_divisor ==1 ?"ns" :"us" );if (params->user_data) {trace_seq_printf (s," | Ret user Timer Latency (%s)" , - params->output_divisor ==1 ?"ns" :"us" ); + params->common.output_divisor ==1 ?"ns" :"us" ); }trace_seq_printf (s,"\n" ); -if (params->pretty_output) +if (pretty)trace_seq_printf (s,"\033[2;30;47m" );trace_seq_printf (s,"CPU COUNT | cur min avg max | cur min avg max" );if (params->user_data)trace_seq_printf (s," | cur min avg max" ); -if (params->pretty_output) +if (pretty)trace_seq_printf (s,"\033[0;0;0m" );trace_seq_printf (s,"\n" ); }
@@ -449,7 +450,7 @@ timerlat_print_stats(struct timerlat_params *params, struct osnoise_tool *top)if (nr_cpus ==-1 ) nr_cpus =sysconf (_SC_NPROCESSORS_CONF); -if (!params->quiet) +if (!params->common.quiet)clear_terminal (trace->seq);timerlat_top_reset_sum (&summary);
@@ -563,7 +564,7 @@ static struct timerlat_params params->deepest_idle_state =-2 ;/* display data in microseconds */ - params->output_divisor =1000 ; + params->common.output_divisor =1000 ;/* default to BPF mode */ params->mode =TRACING_MODE_BPF ;
@@ -696,7 +697,7 @@ static struct timerlat_params params->kernel_workload = true;break ;case 'n' : - params->output_divisor =1 ; + params->common.output_divisor =1 ;break ;case 'p' : params->timerlat_period_us =get_llong_from_str (optarg);
@@ -710,7 +711,7 @@ static struct timerlat_params params->common.set_sched =1 ;break ;case 'q' : - params->quiet =1 ; + params->common.quiet =1 ;break ;case 's' : params->print_stack =get_llong_from_str (optarg);
@@ -842,8 +843,8 @@ timerlat_top_apply_config(struct osnoise_tool *top, struct timerlat_params *paraif (retval) goto out_err; -if (isatty (STDOUT_FILENO ) && !params->quiet) - params->pretty_output =1 ; +if (isatty (STDOUT_FILENO ) && !params->common.quiet) + params->common.pretty_output =1 ;return 0 ;
@@ -942,7 +943,7 @@ timerlat_top_main_loop(struct osnoise_tool *top,return retval; } -if (!params->quiet) +if (!params->common.quiet)timerlat_print_stats (params, top);if (osnoise_trace_is_off (top, record)) {
@@ -992,7 +993,8 @@ timerlat_top_bpf_main_loop(struct osnoise_tool *top,/* Pull and display data in a loop */ while (!stop_tracing) { - wait_retval =timerlat_bpf_wait (params->quiet ?-1 : params->common.sleep_time); + wait_retval =timerlat_bpf_wait (params->common.quiet ?-1 : + params->common.sleep_time); retval =timerlat_top_bpf_pull_data (top);if (retval) {
@@ -1000,7 +1002,7 @@ timerlat_top_bpf_main_loop(struct osnoise_tool *top,return retval; } -if (!params->quiet) +if (!params->common.quiet)timerlat_print_stats (params, top);if (wait_retval ==1 ) {
Signature · 1 line
2.50.1
PATCH 3/7 tools/rtla: Create common_apply_config()
In reply to Steven RostedtFrom: Crystal Wood <[email protected]>
Merge the common bits of osnoise_apply_config() and timerlat_apply_config(). Put the result in a new common.c, and move enough things to common.h so that common.c does not need to include osnoise.h.
--- tools/tracing/rtla/src/Build | 1 + tools/tracing/rtla/src/common.c | 63 ++++++++++++++++++++++++ tools/tracing/rtla/src/common.h | 67 ++++++++++++++++++++++++++ tools/tracing/rtla/src/osnoise.c | 37 ++------------ tools/tracing/rtla/src/osnoise.h | 64 ------------------------ tools/tracing/rtla/src/timerlat.c | 51 ++------------------ tools/tracing/rtla/src/timerlat.h | 1 - tools/tracing/rtla/src/timerlat_hist.c | 4 +- tools/tracing/rtla/src/timerlat_top.c | 4 +- 9 files changed, 142 insertions(+), 150 deletions(-) create mode 100644 tools/tracing/rtla/src/common.c
tools/tracing/rtla/src/Build +1 -0
@@ -1,6 +1,7 @@ rtla-y += trace.o rtla-y += utils.o rtla-y += actions.o +rtla-y += common.o rtla-y += osnoise.o rtla-y += osnoise_top.o rtla-y += osnoise_hist.o
tools/tracing/rtla/src/common.c new file +63 -0
63 lines not on this page · raw message
tools/tracing/rtla/src/common.h +67 -0
79 lines not on this page · raw message
tools/tracing/rtla/src/osnoise.c +3 -34
@@ -1120,21 +1120,14 @@ osnoise_report_missed_events(struct osnoise_tool *tool) }/* -* osnoise_apply_config - apply common configs to the initialized tool +* osnoise_apply_config - apply osnoise configs to the initialized tool */ int osnoise_apply_config (struct osnoise_tool *tool,struct osnoise_params *params) {int retval; -if (!params->common.sleep_time) - params->common.sleep_time =1 ; - - retval =osnoise_set_cpus (tool->context, params->common.cpus ? params->common.cpus :"all" ); -if (retval) { -err_msg ("Failed to apply CPUs config\n" ); - goto out_err; - } + params->common.kernel_workload = true;if (params->runtime || params->period) { retval = osnoise_set_runtime_period(tool->context,
@@ -1169,31 +1162,7 @@ osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params) goto out_err; } -if (params->common.hk_cpus) { - retval =sched_setaffinity (getpid (),sizeof (params->common.hk_cpu_set), - ¶ms->common.hk_cpu_set); -if (retval ==-1 ) { -err_msg ("Failed to set rtla to the house keeping CPUs\n" ); - goto out_err; - } - }else if (params->common.cpus) { -/* -* Even if the user do not set a house-keeping CPU, try to -* move rtla to a CPU set different to the one where the user -* set the workload to run. -* -* No need to check results as this is an automatic attempt. -*/ -auto_house_keeping (¶ms->common.monitored_cpus); - } - - retval =osnoise_set_workload (tool->context, true); -if (retval <-1 ) { -err_msg ("Failed to set OSNOISE_WORKLOAD option\n" ); - goto out_err; - } - -return 0 ; +return common_apply_config (tool, ¶ms->common); out_err:return -1 ;
tools/tracing/rtla/src/osnoise.h +0 -64
88 lines not on this page · raw message
tools/tracing/rtla/src/timerlat.c +4 -47
76 lines not on this page · raw message
tools/tracing/rtla/src/timerlat.h +0 -1
@@ -27,7 +27,6 @@ struct timerlat_params {int no_aa;int dump_tasks;int user_workload; -int kernel_workload;int user_data;int deepest_idle_state;int aa_only;
tools/tracing/rtla/src/timerlat_hist.c +2 -2
@@ -941,7 +941,7 @@ static struct timerlat_params params->common.stop_us =get_llong_from_str (optarg);break ;case 'k' : - params->kernel_workload =1 ; + params->common.kernel_workload =1 ;break ;case 'n' : params->common.output_divisor =1 ;
@@ -1081,7 +1081,7 @@ static struct timerlat_paramsif (!params->common.stop_us && !params->common.stop_total_us) params->no_aa =1 ; -if (params->kernel_workload && params->user_workload) +if (params->common.kernel_workload && params->user_workload)timerlat_hist_usage ("--kernel-threads and --user-threads are mutually exclusive!" );/*
tools/tracing/rtla/src/timerlat_top.c +2 -2
@@ -694,7 +694,7 @@ static struct timerlat_params params->common.stop_us =get_llong_from_str (optarg);break ;case 'k' : - params->kernel_workload = true; + params->common.kernel_workload = true;break ;case 'n' : params->common.output_divisor =1 ;
@@ -816,7 +816,7 @@ static struct timerlat_paramsif (params->no_aa && params->aa_only)timerlat_top_usage ("--no-aa and --aa-only are mutually exclusive!" ); -if (params->kernel_workload && params->user_workload) +if (params->common.kernel_workload && params->user_workload)timerlat_top_usage ("--kernel-threads and --user-threads are mutually exclusive!" );/*
Signature · 1 line
2.50.1
PATCH 4/7 tools/rtla: Consolidate code between osnoise/timerlat and hist/top
In reply to Steven RostedtFrom: Crystal Wood <[email protected]>
Currently a lot of code is duplicated between the different rtla tools, making maintenance more difficult, and encouraging divergence such as features that are only implemented for certain tools even though they could be more broadly applicable.
Merge the various main() functions into a common run_tool() with an ops struct for tool-specific details.
Implement enough support for actions on osnoise to not need to keep the old params->trace_output path.
--- tools/tracing/rtla/src/common.c | 281 +++++++++++++++ tools/tracing/rtla/src/common.h | 60 +++- tools/tracing/rtla/src/osnoise.c | 66 ++-- tools/tracing/rtla/src/osnoise.h | 14 +- tools/tracing/rtla/src/osnoise_hist.c | 234 +++--------- tools/tracing/rtla/src/osnoise_top.c | 218 ++---------- tools/tracing/rtla/src/timerlat.c | 167 ++++++++- tools/tracing/rtla/src/timerlat.h | 16 +- tools/tracing/rtla/src/timerlat_bpf.c | 4 +- tools/tracing/rtla/src/timerlat_hist.c | 450 +++++------------------ tools/tracing/rtla/src/timerlat_top.c | 473 ++++--------------------- tools/tracing/rtla/src/trace.h | 3 - 12 files changed, 792 insertions(+), 1194 deletions(-)
tools/tracing/rtla/src/common.c +281 -0
@@ -1,9 +1,42 @@// SPDX-License-Identifier: GPL-2.0 #define _GNU_SOURCE +#include <pthread.h> +#include <signal.h> +#include <stdlib.h> #include <unistd.h> #include "common.h" +struct trace_instance *trace_inst; +int stop_tracing; + +static void stop_trace (int sig) +{ +if (stop_tracing) { +/* +* Stop requested twice in a row; abort event processing and +* exit immediately +*/ +tracefs_iterate_stop (trace_inst->inst); +return ; + } + stop_tracing =1 ; +if (trace_inst) +trace_instance_stop (trace_inst); +} + +/* +* set_signals - handles the signal to stop the tool +*/ +static void set_signals (struct common_params *params) +{ +signal (SIGINT , stop_trace); +if (params->duration) { +signal (SIGALRM , stop_trace); +alarm (params->duration); + } +} +/* * common_apply_config - apply common configs to the initialized tool */
@@ -61,3 +94,251 @@ common_apply_config(struct osnoise_tool *tool, struct common_params *params)return -1 ; } + +int run_tool (struct tool_ops *ops,int argc,char *argv[]) +{ +struct common_params *params; +enum result return_value =ERROR ; +struct osnoise_tool *tool; +bool stopped; +int retval; + + params = ops->parse_args (argc, argv); +if (!params) +exit (1 ); + + tool = ops->init_tool (params); +if (!tool) { +err_msg ("Could not init osnoise tool\n" ); + goto out_exit; + } + tool->ops = ops; + tool->params = params; + +/* +* Save trace instance into global variable so that SIGINT can stop +* the timerlat tracer. +* Otherwise, rtla could loop indefinitely when overloaded. +*/ + trace_inst = &tool->trace; + + retval = ops->apply_config (tool); +if (retval) { +err_msg ("Could not apply config\n" ); + goto out_free; + } + + retval =enable_tracer_by_name (trace_inst->inst, ops->tracer); +if (retval) { +err_msg ("Failed to enable %s tracer\n" , ops->tracer); + goto out_free; + } + +if (params->set_sched) { + retval =set_comm_sched_attr (ops->comm_prefix, ¶ms->sched_param); +if (retval) { +err_msg ("Failed to set sched parameters\n" ); + goto out_free; + } + } + +if (params->cgroup && !params->user_data) { + retval =set_comm_cgroup (ops->comm_prefix, params->cgroup_name); +if (!retval) { +err_msg ("Failed to move threads to cgroup\n" ); + goto out_free; + } + } + + +if (params->threshold_actions.present[ACTION_TRACE_OUTPUT ] || + params->end_actions.present[ACTION_TRACE_OUTPUT ]) { + tool->record =osnoise_init_trace_tool (ops->tracer); +if (!tool->record) { +err_msg ("Failed to enable the trace instance\n" ); + goto out_free; + } + params->threshold_actions.trace_output_inst = tool->record->trace.inst; + params->end_actions.trace_output_inst = tool->record->trace.inst; + +if (params->events) { + retval =trace_events_enable (&tool->record->trace, params->events); +if (retval) + goto out_trace; + } + +if (params->buffer_size >0 ) { + retval =trace_set_buffer_size (&tool->record->trace, params->buffer_size); +if (retval) + goto out_trace; + } + } + +if (params->user_workload) { +pthread_t user_thread; + +/* rtla asked to stop */ + params->user.should_run =1 ; +/* all threads left */ + params->user.stopped_running =0 ; + + params->user.set = ¶ms->monitored_cpus; +if (params->set_sched) + params->user.sched_param = ¶ms->sched_param; +else + params->user.sched_param =NULL ; + + params->user.cgroup_name = params->cgroup_name; + + retval =pthread_create (&user_thread,NULL , timerlat_u_dispatcher, ¶ms->user); +if (retval) +err_msg ("Error creating timerlat user-space threads\n" ); + } + + retval = ops->enable (tool); +if (retval) + goto out_trace; + + tool->start_time =time (NULL ); +set_signals (params); + + retval = ops->main (tool); +if (retval) + goto out_trace; + +if (params->user_workload && !params->user.stopped_running) { + params->user.should_run =0 ; +sleep (1 ); + } + + ops->print_stats (tool); + +actions_perform (¶ms->end_actions); + + return_value =PASSED ; + + stopped =osnoise_trace_is_off (tool, tool->record) && !stop_tracing; +if (stopped) { +printf ("%s hit stop tracing\n" , ops->tracer); + return_value =FAILED ; + } + +if (ops->analyze) + ops->analyze (tool, stopped); + +out_trace: +trace_events_destroy (&tool->record->trace, params->events); + params->events =NULL ; +out_free: + ops->free (tool); +osnoise_destroy_tool (tool->record); +osnoise_destroy_tool (tool); +actions_destroy (¶ms->threshold_actions); +actions_destroy (¶ms->end_actions); +free (params); +out_exit: +exit (return_value); +} + +int top_main_loop (struct osnoise_tool *tool) +{ +struct common_params *params = tool->params; +struct trace_instance *trace = &tool->trace; +struct osnoise_tool *record = tool->record; +int retval; + +while (!stop_tracing) { +sleep (params->sleep_time); + +if (params->aa_only && !osnoise_trace_is_off (tool, record)) +continue ; + + retval =tracefs_iterate_raw_events (trace->tep, + trace->inst, +NULL , +0 , + collect_registered_events, + trace); +if (retval <0 ) { +err_msg ("Error iterating on events\n" ); +return retval; + } + +if (!params->quiet) + tool->ops->print_stats (tool); + +if (osnoise_trace_is_off (tool, record)) { +actions_perform (¶ms->threshold_actions); + +if (!params->threshold_actions.continue_flag) +/* continue flag not set, break */ +return 0 ; + +/* continue action reached, re-enable tracing */ +if (record) +trace_instance_start (&record->trace); +if (tool->aa) +trace_instance_start (&tool->aa->trace); +trace_instance_start (trace); + } + +/* is there still any user-threads ? */ +if (params->user_workload) { +if (params->user.stopped_running) { +debug_msg ("timerlat user space threads stopped!\n" ); +break ; + } + } + } + +return 0 ; +} + +int hist_main_loop (struct osnoise_tool *tool) +{ +struct common_params *params = tool->params; +struct trace_instance *trace = &tool->trace; +int retval =0 ; + +while (!stop_tracing) { +sleep (params->sleep_time); + + retval =tracefs_iterate_raw_events (trace->tep, + trace->inst, +NULL , +0 , + collect_registered_events, + trace); +if (retval <0 ) { +err_msg ("Error iterating on events\n" ); +break ; + } + +if (osnoise_trace_is_off (tool, tool->record)) { +actions_perform (¶ms->threshold_actions); + +if (!params->threshold_actions.continue_flag) { +/* continue flag not set, break */ +break ; + +/* continue action reached, re-enable tracing */ +if (tool->record) +trace_instance_start (&tool->record->trace); +if (tool->aa) +trace_instance_start (&tool->aa->trace); +trace_instance_start (&tool->trace); + } +break ; + } + +/* is there still any user-threads ? */ +if (params->user_workload) { +if (params->user.stopped_running) { +debug_msg ("user-space threads stopped!\n" ); +break ; + } + } + } + +return retval; +}
tools/tracing/rtla/src/common.h +50 -10
83 lines not on this page · raw message
tools/tracing/rtla/src/osnoise.c +44 -22
105 lines not on this page · raw message
tools/tracing/rtla/src/osnoise.h +9 -5
@@ -10,13 +10,14 @@ enum osnoise_mode {struct osnoise_params {struct common_params common; -char *trace_output;unsigned long long runtime;unsigned long long period;long long threshold;enum osnoise_mode mode; }; +#define to_osnoise_params (ptr) container_of(ptr, struct osnoise_params, common) +/* * *_INIT_VALs are also invalid values, they are used to * communicate errors.
@@ -54,14 +55,17 @@ int osnoise_set_print_stack(struct osnoise_context *context, long long print_stack);int osnoise_set_irq_disable (struct osnoise_context *context,bool onoff); -void osnoise_destroy_tool (struct osnoise_tool *top); -struct osnoise_tool *osnoise_init_tool (char *tool_name); -struct osnoise_tool *osnoise_init_trace_tool (char *tracer);void osnoise_report_missed_events (struct osnoise_tool *tool); -bool osnoise_trace_is_off (struct osnoise_tool *tool,struct osnoise_tool *record);int osnoise_apply_config (struct osnoise_tool *tool,struct osnoise_params *params);int osnoise_hist_main (int argc,char *argv[]);int osnoise_top_main (int argc,char **argv); +int osnoise_enable (struct osnoise_tool *tool);int osnoise_main (int argc,char **argv);int hwnoise_main (int argc,char **argv); + +extern struct tool_ops timerlat_top_ops, timerlat_hist_ops; +extern struct tool_ops osnoise_top_ops, osnoise_hist_ops; + +int run_tool (struct tool_ops *ops,int argc,char *argv[]); +int hist_main_loop (struct osnoise_tool *tool);
tools/tracing/rtla/src/osnoise_hist.c +50 -184
345 lines not on this page · raw message
tools/tracing/rtla/src/osnoise_top.c +38 -180
312 lines not on this page · raw message
tools/tracing/rtla/src/timerlat.c +160 -7
213 lines not on this page · raw message
tools/tracing/rtla/src/timerlat.h +6 -10
@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include "actions.h" #include "osnoise.h" /*
@@ -26,18 +25,15 @@ struct timerlat_params {int dma_latency;int no_aa;int dump_tasks; -int user_workload; -int user_data;int deepest_idle_state; -int aa_only;enum timerlat_tracing_mode mode; - -struct actions threshold_actions; -struct actions end_actions; }; -int timerlat_apply_config (struct osnoise_tool *tool,struct timerlat_params *params); +#define to_timerlat_params (ptr) container_of(ptr, struct timerlat_params, common) -int timerlat_hist_main (int argc,char *argv[]); -int timerlat_top_main (int argc,char *argv[]); +int timerlat_apply_config (struct osnoise_tool *tool,struct timerlat_params *params);int timerlat_main (int argc,char *argv[]); +int timerlat_enable (struct osnoise_tool *tool); +void timerlat_analyze (struct osnoise_tool *tool,bool stopped); +void timerlat_free (struct osnoise_tool *tool); +
tools/tracing/rtla/src/timerlat_bpf.c +2 -2
@@ -25,7 +25,7 @@ int timerlat_bpf_init(struct timerlat_params *params) bpf->rodata->entries = params->common.hist.entries; bpf->rodata->irq_threshold = params->common.stop_us; bpf->rodata->thread_threshold = params->common.stop_total_us; - bpf->rodata->aa_only = params->aa_only; + bpf->rodata->aa_only = params->common.aa_only;if (params->common.hist.entries !=0 ) {/* Pass histogram options */
@@ -42,7 +42,7 @@ int timerlat_bpf_init(struct timerlat_params *params)bpf_map__set_autocreate (bpf->maps.hist_user, false); } -if (params->aa_only) { +if (params->common.aa_only) {/* Auto-analysis only, disable summary */ bpf_map__set_autocreate (bpf->maps.summary_irq, false);bpf_map__set_autocreate (bpf->maps.summary_thread, false);
tools/tracing/rtla/src/timerlat_hist.c +83 -367
645 lines not on this page · raw message
tools/tracing/rtla/src/timerlat_top.c +69 -404
696 lines not on this page · raw message
tools/tracing/rtla/src/trace.h +0 -3
@@ -30,9 +30,6 @@ struct trace_seq *get_trace_seq(void);int enable_tracer_by_name (struct tracefs_instance *inst,const char *tracer_name);void disable_tracer (struct tracefs_instance *inst); -int enable_osnoise (struct trace_instance *trace); -int enable_timerlat (struct trace_instance *trace); -struct tracefs_instance *create_instance (char *instance_name);void destroy_instance (struct tracefs_instance *inst);
Signature · 1 line
2.50.1
PATCH 5/7 tools/rtla: Fix -A option name in test comment
In reply to Steven RostedtFrom: Crystal Wood <[email protected]>
This was changed to --on-threshold when the patches were applied.
--- tools/tracing/rtla/tests/timerlat.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/tracing/rtla/tests/timerlat.t +2 -2
@@ -47,9 +47,9 @@ check "trace output through -t" \ "timerlat hist -T 2 -t" 2 "^ Saving trace to timerlat_trace.txt$" check "trace output through -t with custom filename" \ "timerlat hist -T 2 -t custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" -check "trace output through -A trace" \ +check "trace output through --on-threshold trace" \ "timerlat hist -T 2 --on-threshold trace" 2 "^ Saving trace to timerlat_trace.txt$" -check "trace output through -A trace with custom filename" \ +check "trace output through --on-threshold trace with custom filename" \ "timerlat hist -T 2 --on-threshold trace,file=custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" check "exec command" \ "timerlat hist -T 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$"
Signature · 1 line
2.50.1
PATCH 6/7 tools/rtla: Add test engine support for unexpected output
In reply to Steven RostedtFrom: Crystal Wood <[email protected]>
Add a check() parameter to indicate which text must not appear in the output.
Simplify the code so that we can print failures as they happen rather than trying to figure out what went wrong after printing "not ok". This also means that "not ok" gets printed after the info rather than before, which seems more intuitive anyway.
--- tools/tracing/rtla/tests/engine.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
tools/tracing/rtla/tests/engine.sh +18 -8
@@ -43,6 +43,7 @@ check() { tested_command=$1 expected_exitcode=${3:-0} expected_output=$4 + unexpected_output=$5 # Simple check: run rtla with given arguments and test exit code. # If TEST_COUNT is set, run the test. Otherwise, just count. ctr=$(($ctr + 1))
@@ -53,24 +54,33 @@ check() { # Run rtla; in case of failure, include its output as comment # in the test results. result=$(eval stdbuf -oL $TIMEOUT "$RTLA" $2 2>&1); exitcode=$? + failbuf='' + fail=0 + # Test if the results matches if requested - if [ -n "$expected_output" ] + if [ -n "$expected_output" ] && ! grep -qE "$expected_output" <<< "$result" then - grep -E "$expected_output" <<< "$result" > /dev/null; grep_result=$? - else - grep_result=0 + fail=1 + failbuf+=$(printf "# Output match failed: \"%s\"" "$expected_output") + failbuf+=$'\n' fi - if [ $exitcode -eq $expected_exitcode ] && [ $grep_result -eq 0 ] + if [ -n "$unexpected_output" ] && grep -qE "$unexpected_output" <<< "$result" + then + fail=1 + failbuf+=$(printf "# Output non-match failed: \"%s\"" "$unexpected_output") + failbuf+=$'\n' + fi + + if [ $exitcode -eq $expected_exitcode ] && [ $fail -eq 0 ] then echo "ok $ctr - $1" else - echo "not ok $ctr - $1" # Add rtla output and exit code as comments in case of failure + echo "not ok $ctr - $1" + echo -n "$failbuf" echo "$result" | col -b | while read line; do echo "# $line"; done printf "#\n# exit code %s\n" $exitcode - [ -n "$expected_output" ] && [ $grep_result -ne 0 ] && \ - printf "# Output match failed: \"%s\"\n" "$expected_output" fi fi }
Signature · 1 line
2.50.1
PATCH 7/7 tools/rtla: Add remaining support for osnoise actions
In reply to Steven RostedtFrom: Crystal Wood <[email protected]>
The basic functionality came with the consolidation; now hook up the command line options, and add documentation and tests.
--- Documentation/tools/rtla/common_options.rst | 61 +++++++++++++++ .../tools/rtla/common_osnoise_options.rst | 8 ++ .../tools/rtla/common_timerlat_options.rst | 74 +++---------------- Documentation/tools/rtla/rtla-hwnoise.rst | 2 + .../tools/rtla/rtla-osnoise-hist.rst | 2 + Documentation/tools/rtla/rtla-osnoise-top.rst | 2 + .../tools/rtla/rtla-timerlat-hist.rst | 2 + .../tools/rtla/rtla-timerlat-top.rst | 2 + tools/tracing/rtla/src/actions.c | 8 +- tools/tracing/rtla/src/actions.h | 2 +- tools/tracing/rtla/src/osnoise_hist.c | 20 +++++ tools/tracing/rtla/src/osnoise_top.c | 20 +++++ tools/tracing/rtla/src/timerlat_hist.c | 6 +- tools/tracing/rtla/src/timerlat_top.c | 6 +- tools/tracing/rtla/tests/osnoise.t | 27 ++++++- 15 files changed, 168 insertions(+), 74 deletions(-)
Documentation/tools/rtla/common_options.rst +61 -0
@@ -53,6 +53,67 @@ **--trace-buffer-size** *kB* Set the per-cpu trace buffer size in kB for the tracing output. +**--on-threshold** *action* + + Defines an action to be executed when tracing is stopped on a latency threshold + specified by |threshold|. + + Multiple --on-threshold actions may be specified, and they will be executed in + the order they are provided. If any action fails, subsequent actions in the list + will not be executed. + + Supported actions are: + + - *trace[,file=<filename>]* + + Saves trace output, optionally taking a filename. Alternative to -t/--trace. + Note that nlike -t/--trace, specifying this multiple times will result in + the trace being saved multiple times. + + - *signal,num=<sig>,pid=<pid>* + + Sends signal to process. "parent" might be specified in place of pid to target + the parent process of rtla. + + - *shell,command=<command>* + + Execute shell command. + + - *continue* + + Continue tracing after actions are executed instead of stopping. + + Example: + + $ rtla |tool| |thresharg| 20 --on-threshold trace + --on-threshold shell,command="grep ipi_send |tracer|\_trace.txt" + --on-threshold signal,num=2,pid=parent + + This will save a trace with the default filename "|tracer|\_trace.txt", print its + lines that contain the text "ipi_send" on standard output, and send signal 2 + (SIGINT) to the parent process. + + Performance Considerations: + + |actionsperf| + +**--on-end** *action* + + Defines an action to be executed at the end of tracing. + + Multiple --on-end actions can be specified, and they will be executed in the order + they are provided. If any action fails, subsequent actions in the list will not be + executed. + + See the documentation for **--on-threshold** for the list of supported actions, with + the exception that *continue* has no effect. + + Example: + + $ rtla |tool| -d 5s --on-end trace + + This runs rtla with the default options, and saves trace output at the end. + **-h**, **--help** Print help menu.
Documentation/tools/rtla/common_osnoise_options.rst +8 -0
@@ -1,3 +1,11 @@ +.. |threshold| replace:: **-a/--auto**, **-s/--stop**, or **-S/--stop-total** +.. |thresharg| replace:: -s +.. |tracer| replace:: osnoise + +.. |actionsperf| replace:: + Due to implementational limitations, actions might be delayed + up to one second after tracing is stopped. + **-a**, **--auto** *us* Set the automatic trace mode. This mode sets some commonly used options
Documentation/tools/rtla/common_timerlat_options.rst +10 -64
80 lines not on this page · raw message
Documentation/tools/rtla/rtla-hwnoise.rst +2 -0
@@ -1,5 +1,7 @@ .. SPDX-License-Identifier: GPL-2.0 +.. |tool| replace:: hwnoise + ============ rtla-hwnoise ============
Documentation/tools/rtla/rtla-osnoise-hist.rst +2 -0
@@ -1,3 +1,5 @@ +.. |tool| replace:: osnoise hist + =================== rtla-osnoise-hist ===================
Documentation/tools/rtla/rtla-osnoise-top.rst +2 -0
@@ -1,3 +1,5 @@ +.. |tool| replace:: osnoise top + =================== rtla-osnoise-top ===================
Documentation/tools/rtla/rtla-timerlat-hist.rst +2 -0
@@ -1,3 +1,5 @@ +.. |tool| replace:: timerlat hist + ===================== rtla-timerlat-hist =====================
Documentation/tools/rtla/rtla-timerlat-top.rst +2 -0
@@ -1,3 +1,5 @@ +.. |tool| replace:: timerlat top + ==================== rtla-timerlat-top ====================
tools/tracing/rtla/src/actions.c +4 -4
@@ -127,17 +127,17 @@ actions_add_continue(struct actions *self)* actions_parse - add an action based on text specification */ int -actions_parse (struct actions *self,const char *trigger) +actions_parse (struct actions *self,const char *trigger,const char *tracefn) {enum action_type type =ACTION_NONE ; -char *token; +const char *token;char trigger_c[strlen (trigger)];/* For ACTION_SIGNAL */ int signal =0 , pid =0 ;/* For ACTION_TRACE_OUTPUT */ -char *trace_output; +const char *trace_output;strcpy (trigger_c, trigger); token =strtok (trigger_c,"," );
@@ -160,7 +160,7 @@ actions_parse(struct actions *self, const char *trigger)case ACTION_TRACE_OUTPUT :/* Takes no argument */ if (token ==NULL ) - trace_output ="timerlat_trace.txt" ; + trace_output = tracefn;else {if (strlen (token) >5 &&strncmp (token,"file=" ,5 ) ==0 ) { trace_output = token +5 ;
tools/tracing/rtla/src/actions.h +1 -1
@@ -48,5 +48,5 @@ int actions_add_trace_output(struct actions *self, const char *trace_output);int actions_add_signal (struct actions *self,int signal,int pid);int actions_add_shell (struct actions *self,const char *command);int actions_add_continue (struct actions *self); -int actions_parse (struct actions *self,const char *trigger); +int actions_parse (struct actions *self,const char *trigger,const char *tracefn);int actions_perform (struct actions *self);
tools/tracing/rtla/src/osnoise_hist.c +20 -0
@@ -462,6 +462,8 @@ static void osnoise_hist_usage(char *usage)" in nanoseconds" ," --warm-up: let the workload run for s seconds before collecting data" ," --trace-buffer-size kB: set the per-cpu trace buffer size in kB" , +" --on-threshold <action>: define action to be executed at stop-total threshold, multiple are allowed" , +" --on-end <action>: define action to be executed at measurement end, multiple are allowed" , NULL, };
@@ -531,6 +533,8 @@ static struct common_params {"filter", required_argument, 0, '5'}, {"warm-up", required_argument, 0, '6'}, {"trace-buffer-size", required_argument, 0, '7'}, + {"on-threshold", required_argument, 0, '8'}, + {"on-end", required_argument, 0, '9'}, {0, 0, 0, 0} };
@@ -692,6 +696,22 @@ static struct common_paramscase '7' : params->common.buffer_size =get_llong_from_str (optarg);break ; +case '8' : + retval =actions_parse (¶ms->common.threshold_actions, optarg, +"osnoise_trace.txt" ); +if (retval) { +err_msg ("Invalid action %s\n" , optarg); +exit (EXIT_FAILURE ); + } +break ; +case '9' : + retval =actions_parse (¶ms->common.end_actions, optarg, +"osnoise_trace.txt" ); +if (retval) { +err_msg ("Invalid action %s\n" , optarg); +exit (EXIT_FAILURE ); + } +break ;default :osnoise_hist_usage ("Invalid option" ); }
tools/tracing/rtla/src/osnoise_top.c +20 -0
@@ -291,6 +291,8 @@ static void osnoise_top_usage(struct osnoise_params *params, char *usage)" in nanoseconds" ," --warm-up s: let the workload run for s seconds before collecting data" ," --trace-buffer-size kB: set the per-cpu trace buffer size in kB" , +" --on-threshold <action>: define action to be executed at stop-total threshold, multiple are allowed" , +" --on-end: define action to be executed at measurement end, multiple are allowed" , NULL, };
@@ -371,6 +373,8 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv) {"filter", required_argument, 0, '1'}, {"warm-up", required_argument, 0, '2'}, {"trace-buffer-size", required_argument, 0, '3'}, + {"on-threshold", required_argument, 0, '4'}, + {"on-end", required_argument, 0, '5'}, {0, 0, 0, 0} };
@@ -511,6 +515,22 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)case '3' : params->common.buffer_size =get_llong_from_str (optarg);break ; +case '4' : + retval =actions_parse (¶ms->common.threshold_actions, optarg, +"osnoise_trace.txt" ); +if (retval) { +err_msg ("Invalid action %s\n" , optarg); +exit (EXIT_FAILURE ); + } +break ; +case '5' : + retval =actions_parse (¶ms->common.end_actions, optarg, +"osnoise_trace.txt" ); +if (retval) { +err_msg ("Invalid action %s\n" , optarg); +exit (EXIT_FAILURE ); + } +break ;default :osnoise_top_usage (params,"Invalid option" ); }
tools/tracing/rtla/src/timerlat_hist.c +4 -2
@@ -1047,14 +1047,16 @@ static struct common_params params->deepest_idle_state =get_llong_from_str (optarg);break ;case '\5' : - retval =actions_parse (¶ms->common.threshold_actions, optarg); + retval =actions_parse (¶ms->common.threshold_actions, optarg, +"timerlat_trace.txt" );if (retval) {err_msg ("Invalid action %s\n" , optarg);exit (EXIT_FAILURE ); }break ;case '\6' : - retval =actions_parse (¶ms->common.end_actions, optarg); + retval =actions_parse (¶ms->common.end_actions, optarg, +"timerlat_trace.txt" );if (retval) {err_msg ("Invalid action %s\n" , optarg);exit (EXIT_FAILURE );
tools/tracing/rtla/src/timerlat_top.c +4 -2
@@ -783,14 +783,16 @@ static struct common_params params->deepest_idle_state =get_llong_from_str (optarg);break ;case '9' : - retval =actions_parse (¶ms->common.threshold_actions, optarg); + retval =actions_parse (¶ms->common.threshold_actions, optarg, +"timerlat_trace.txt" );if (retval) {err_msg ("Invalid action %s\n" , optarg);exit (EXIT_FAILURE ); }break ;case '\1' : - retval =actions_parse (¶ms->common.end_actions, optarg); + retval =actions_parse (¶ms->common.end_actions, optarg, +"timerlat_trace.txt" );if (retval) {err_msg ("Invalid action %s\n" , optarg);exit (EXIT_FAILURE );
tools/tracing/rtla/tests/osnoise.t +26 -1
@@ -8,7 +8,8 @@ set_timeout 2m check "verify help page" \ "osnoise --help" 0 "osnoise version" check "verify the --priority/-P param" \ - "osnoise top -P F:1 -c 0 -r 900000 -d 10s -q" + "osnoise top -P F:1 -c 0 -r 900000 -d 10s -q -S 1 --on-threshold shell,command=\"tests/scripts/check-priority.sh osnoise/ SCHED_FIFO 1\"" \ + 2 "Priorities are set correctly" check "verify the --stop/-s param" \ "osnoise top -s 30 -T 1" 2 "osnoise hit stop tracing" check "verify the --trace param" \
@@ -22,4 +23,28 @@ check "verify the --entries/-E param" \ check_with_osnoise_options "apply default period" \ "osnoise hist -s 1" 2 period_us=600000000 +# Actions tests +check "trace output through -t with custom filename" \ + "osnoise hist -S 2 -t custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" +check "trace output through --on-threshold trace" \ + "osnoise hist -S 2 --on-threshold trace" 2 "^ Saving trace to osnoise_trace.txt$" +check "trace output through --on-threshold trace with custom filename" \ + "osnoise hist -S 2 --on-threshold trace,file=custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" +check "exec command" \ + "osnoise hist -S 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$" +check "multiple actions" \ + "osnoise hist -S 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$" +check "hist stop at failed action" \ + "osnoise hist -S 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1# RTLA osnoise histogram$" +check "top stop at failed action" \ + "timerlat top -T 2 --on-threshold shell,command='echo -n abc; false' --on-threshold shell,command='echo -n defgh'" 2 "^abc" "defgh" +check "hist with continue" \ + "osnoise hist -S 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" +check "top with continue" \ + "osnoise top -q -S 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" +check "hist with trace output at end" \ + "osnoise hist -d 1s --on-end trace" 0 "^ Saving trace to osnoise_trace.txt$" +check "top with trace output at end" \ + "osnoise top -d 1s --on-end trace" 0 "^ Saving trace to osnoise_trace.txt$" + test_end
Signature · 1 line
2.50.1