Skip to content

Commit 2091336

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
rtla/timerlat_hist: Add auto-analysis support
Add auto-analysis to timerlat hist, including the --no-aa option to reduce overhead and --dump-task. --aa-only was not added as it is already on timerlat top. Link: https://lkml.kernel.org/r/c2693f47ee83e659a7723fed8035f5d2534f528e.1686066600.git.bristot@kernel.org Cc: William White <[email protected]> Cc: Jonathan Corbet <[email protected]> Tested-by: Juri Lelli <[email protected]> Signed-off-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent c66552b commit 2091336

File tree

4 files changed

+61
-11
lines changed

4 files changed

+61
-11
lines changed

Documentation/tools/rtla/common_timerlat_aa.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,3 @@
55
**--no-aa**
66

77
disable auto-analysis, reducing rtla timerlat cpu usage
8-
9-
**--aa-only** *us*
10-
11-
Set stop tracing conditions and run without collecting and displaying statistics.
12-
Print the auto-analysis if the system hits the stop tracing condition. This option
13-
is useful to reduce rtla timerlat CPU, enabling the debug without the overhead of
14-
collecting the statistics.

Documentation/tools/rtla/rtla-timerlat-hist.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@ OPTIONS
2929

3030
.. include:: common_options.rst
3131

32+
.. include:: common_timerlat_aa.rst
33+
3234
EXAMPLE
3335
=======
3436
In the example below, **rtla timerlat hist** is set to run for *10* minutes,
3537
in the cpus *0-4*, *skipping zero* only lines. Moreover, **rtla timerlat
3638
hist** will change the priority of the *timerlat* threads to run under
3739
*SCHED_DEADLINE* priority, with a *10us* runtime every *1ms* period. The
38-
*1ms* period is also passed to the *timerlat* tracer::
40+
*1ms* period is also passed to the *timerlat* tracer. Auto-analysis is disabled
41+
to reduce overhead ::
3942

40-
[root@alien ~]# timerlat hist -d 10m -c 0-4 -P d:100us:1ms -p 1ms
43+
[root@alien ~]# timerlat hist -d 10m -c 0-4 -P d:100us:1ms -p 1ms --no-aa
4144
# RTLA timerlat histogram
4245
# Time unit is microseconds (us)
4346
# Duration: 0 00:10:00

Documentation/tools/rtla/rtla-timerlat-top.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ OPTIONS
3232

3333
.. include:: common_timerlat_aa.rst
3434

35+
**--aa-only** *us*
36+
37+
Set stop tracing conditions and run without collecting and displaying statistics.
38+
Print the auto-analysis if the system hits the stop tracing condition. This option
39+
is useful to reduce rtla timerlat CPU, enabling the debug without the overhead of
40+
collecting the statistics.
41+
3542
EXAMPLE
3643
=======
3744

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "utils.h"
1717
#include "osnoise.h"
1818
#include "timerlat.h"
19+
#include "timerlat_aa.h"
1920

2021
struct timerlat_hist_params {
2122
char *cpus;
@@ -34,6 +35,8 @@ struct timerlat_hist_params {
3435
int dma_latency;
3536
int cgroup;
3637
int hk_cpus;
38+
int no_aa;
39+
int dump_tasks;
3740
cpu_set_t hk_cpu_set;
3841
struct sched_attr sched_param;
3942
struct trace_events *events;
@@ -438,7 +441,7 @@ static void timerlat_hist_usage(char *usage)
438441
" usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-a us] [-p us] [-i us] [-T us] [-s us] \\",
439442
" [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] [-H cpu-list]\\",
440443
" [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\",
441-
" [--no-index] [--with-zeros] [--dma-latency us] [-C[=cgroup_name]]",
444+
" [--no-index] [--with-zeros] [--dma-latency us] [-C[=cgroup_name]] [--no-aa] [--dump-task]",
442445
"",
443446
" -h/--help: print this menu",
444447
" -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit",
@@ -450,12 +453,14 @@ static void timerlat_hist_usage(char *usage)
450453
" -H/--house-keeping cpus: run rtla control threads only on the given cpus",
451454
" -C/--cgroup[=cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
452455
" -d/--duration time[m|h|d]: duration of the session in seconds",
456+
" --dump-tasks: prints the task running on all CPUs if stop conditions are met (depends on !--no-aa)",
453457
" -D/--debug: print debug info",
454458
" -t/--trace[=file]: save the stopped trace to [file|timerlat_trace.txt]",
455459
" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
456460
" --filter <filter>: enable a trace event filter to the previous -e event",
457461
" --trigger <trigger>: enable a trace event trigger to the previous -e event",
458462
" -n/--nano: display data in nanoseconds",
463+
" --no-aa: disable auto-analysis, reducing rtla timerlat cpu usage",
459464
" -b/--bucket-size N: set the histogram bucket size (default 1)",
460465
" -E/--entries N: set the number of entries of the histogram (default 256)",
461466
" --no-irq: ignore IRQ latencies",
@@ -537,13 +542,15 @@ static struct timerlat_hist_params
537542
{"trigger", required_argument, 0, '6'},
538543
{"filter", required_argument, 0, '7'},
539544
{"dma-latency", required_argument, 0, '8'},
545+
{"no-aa", no_argument, 0, '9'},
546+
{"dump-task", no_argument, 0, '\1'},
540547
{0, 0, 0, 0}
541548
};
542549

543550
/* getopt_long stores the option index here. */
544551
int option_index = 0;
545552

546-
c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:np:P:s:t::T:0123456:7:8:",
553+
c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:np:P:s:t::T:0123456:7:8:9\1",
547554
long_options, &option_index);
548555

549556
/* detect the end of the options. */
@@ -556,6 +563,7 @@ static struct timerlat_hist_params
556563

557564
/* set thread stop to auto_thresh */
558565
params->stop_total_us = auto_thresh;
566+
params->stop_us = auto_thresh;
559567

560568
/* get stack trace */
561569
params->print_stack = auto_thresh;
@@ -699,6 +707,12 @@ static struct timerlat_hist_params
699707
exit(EXIT_FAILURE);
700708
}
701709
break;
710+
case '9':
711+
params->no_aa = 1;
712+
break;
713+
case '\1':
714+
params->dump_tasks = 1;
715+
break;
702716
default:
703717
timerlat_hist_usage("Invalid option");
704718
}
@@ -715,6 +729,12 @@ static struct timerlat_hist_params
715729
if (params->no_index && !params->with_zeros)
716730
timerlat_hist_usage("no-index set with with-zeros is not set - it does not make sense");
717731

732+
/*
733+
* Auto analysis only happens if stop tracing, thus:
734+
*/
735+
if (!params->stop_us && !params->stop_total_us)
736+
params->no_aa = 1;
737+
718738
return params;
719739
}
720740

@@ -848,6 +868,7 @@ int timerlat_hist_main(int argc, char *argv[])
848868
struct timerlat_hist_params *params;
849869
struct osnoise_tool *record = NULL;
850870
struct osnoise_tool *tool = NULL;
871+
struct osnoise_tool *aa = NULL;
851872
struct trace_instance *trace;
852873
int dma_latency_fd = -1;
853874
int return_value = 1;
@@ -919,6 +940,26 @@ int timerlat_hist_main(int argc, char *argv[])
919940
trace_instance_start(&record->trace);
920941
}
921942

943+
if (!params->no_aa) {
944+
aa = osnoise_init_tool("timerlat_aa");
945+
if (!aa)
946+
goto out_hist;
947+
948+
retval = timerlat_aa_init(aa, params->dump_tasks);
949+
if (retval) {
950+
err_msg("Failed to enable the auto analysis instance\n");
951+
goto out_hist;
952+
}
953+
954+
retval = enable_timerlat(&aa->trace);
955+
if (retval) {
956+
err_msg("Failed to enable timerlat tracer\n");
957+
goto out_hist;
958+
}
959+
960+
trace_instance_start(&aa->trace);
961+
}
962+
922963
tool->start_time = time(NULL);
923964
timerlat_hist_set_signals(params);
924965

@@ -946,19 +987,25 @@ int timerlat_hist_main(int argc, char *argv[])
946987

947988
if (trace_is_off(&tool->trace, &record->trace)) {
948989
printf("rtla timerlat hit stop tracing\n");
990+
991+
if (!params->no_aa)
992+
timerlat_auto_analysis(params->stop_us, params->stop_total_us);
993+
949994
if (params->trace_output) {
950995
printf(" Saving trace to %s\n", params->trace_output);
951996
save_trace_to_file(record->trace.inst, params->trace_output);
952997
}
953998
}
954999

9551000
out_hist:
1001+
timerlat_aa_destroy();
9561002
if (dma_latency_fd >= 0)
9571003
close(dma_latency_fd);
9581004
trace_events_destroy(&record->trace, params->events);
9591005
params->events = NULL;
9601006
out_free:
9611007
timerlat_free_histogram(tool->data);
1008+
osnoise_destroy_tool(aa);
9621009
osnoise_destroy_tool(record);
9631010
osnoise_destroy_tool(tool);
9641011
free(params);

0 commit comments

Comments
 (0)