Skip to content

Commit 173a3b0

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
rtla/timerlat: Add the automatic trace option
Add the -a/--auto <arg in us> option. This option sets some commonly used options while debugging the system. It aims to help users produce reports in the field, reducing the number of arguments passed to the tool in the first approach to a problem. It is equivalent to setting osnoise/stop_tracing_total_us and print_stack with the argument, and saving the trace to timerlat_trace.txt file if the trace is stopped automatically. Link: https://lkml.kernel.org/r/92438f7ef132c731f538cebdf77850300afe04a5.1646247211.git.bristot@kernel.org Cc: Daniel Bristot de Oliveira <bristot@kernel.org> Cc: Clark Williams <williams@redhat.com> Cc: Juri Lelli <juri.lelli@redhat.com> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 2b622ed commit 173a3b0

3 files changed

Lines changed: 46 additions & 7 deletions

File tree

Documentation/tools/rtla/common_timerlat_options.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
**-a**, **--auto** *us*
2+
3+
Set the automatic trace mode. This mode sets some commonly used options
4+
while debugging the system. It is equivalent to use **-T** *us* **-s** *us*
5+
**-t**. By default, *timerlat* tracer uses FIFO:95 for *timerlat* threads,
6+
thus equilavent to **-P** *f:95*.
7+
18
**-p**, **--period** *us*
29

310
Set the *timerlat* tracer period in microseconds.

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,12 @@ static void timerlat_hist_usage(char *usage)
428428

429429
char *msg[] = {
430430
"",
431-
" usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-p us] [-i us] [-T us] [-s us] [-t[=file]] \\",
432-
" [-c cpu-list] [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\",
433-
" [--no-index] [--with-zeros]",
431+
" usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-a us] [-p us] [-i us] [-T us] [-s us] \\",
432+
" [-t[=file]] [-c cpu-list] [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] \\",
433+
" [--no-summary] [--no-index] [--with-zeros]",
434434
"",
435435
" -h/--help: print this menu",
436+
" -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit",
436437
" -p/--period us: timerlat period in us",
437438
" -i/--irq us: stop trace if the irq latency is higher than the argument in us",
438439
" -T/--thread us: stop trace if the thread latency is higher than the argument in us",
@@ -477,6 +478,7 @@ static struct timerlat_hist_params
477478
*timerlat_hist_parse_args(int argc, char *argv[])
478479
{
479480
struct timerlat_hist_params *params;
481+
int auto_thresh;
480482
int retval;
481483
int c;
482484

@@ -491,6 +493,7 @@ static struct timerlat_hist_params
491493

492494
while (1) {
493495
static struct option long_options[] = {
496+
{"auto", required_argument, 0, 'a'},
494497
{"cpus", required_argument, 0, 'c'},
495498
{"bucket-size", required_argument, 0, 'b'},
496499
{"debug", no_argument, 0, 'D'},
@@ -516,14 +519,27 @@ static struct timerlat_hist_params
516519
/* getopt_long stores the option index here. */
517520
int option_index = 0;
518521

519-
c = getopt_long(argc, argv, "c:b:d:E:Dhi:np:P:s:t::T:012345",
522+
c = getopt_long(argc, argv, "a:c:b:d:E:Dhi:np:P:s:t::T:012345",
520523
long_options, &option_index);
521524

522525
/* detect the end of the options. */
523526
if (c == -1)
524527
break;
525528

526529
switch (c) {
530+
case 'a':
531+
auto_thresh = get_llong_from_str(optarg);
532+
533+
/* set thread stop to auto_thresh */
534+
params->stop_total_us = auto_thresh;
535+
536+
/* get stack trace */
537+
params->print_stack = auto_thresh;
538+
539+
/* set trace */
540+
params->trace_output = "timerlat_trace.txt";
541+
542+
break;
527543
case 'c':
528544
retval = parse_cpu_list(optarg, &params->monitored_cpus);
529545
if (retval)

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,11 @@ static void timerlat_top_usage(char *usage)
266266

267267
static const char *const msg[] = {
268268
"",
269-
" usage: rtla timerlat [top] [-h] [-q] [-d s] [-D] [-n] [-p us] [-i us] [-T us] [-s us] [-t[=file]] \\",
270-
" [-c cpu-list] [-P priority]",
269+
" usage: rtla timerlat [top] [-h] [-q] [-a us] [-d s] [-D] [-n] [-p us] [-i us] [-T us] [-s us] \\",
270+
" [[-t[=file]] -c cpu-list] [-P priority]",
271271
"",
272272
" -h/--help: print this menu",
273+
" -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit",
273274
" -p/--period us: timerlat period in us",
274275
" -i/--irq us: stop trace if the irq latency is higher than the argument in us",
275276
" -T/--thread us: stop trace if the thread latency is higher than the argument in us",
@@ -307,6 +308,7 @@ static struct timerlat_top_params
307308
*timerlat_top_parse_args(int argc, char **argv)
308309
{
309310
struct timerlat_top_params *params;
311+
long long auto_thresh;
310312
int retval;
311313
int c;
312314

@@ -319,6 +321,7 @@ static struct timerlat_top_params
319321

320322
while (1) {
321323
static struct option long_options[] = {
324+
{"auto", required_argument, 0, 'a'},
322325
{"cpus", required_argument, 0, 'c'},
323326
{"debug", no_argument, 0, 'D'},
324327
{"duration", required_argument, 0, 'd'},
@@ -337,14 +340,27 @@ static struct timerlat_top_params
337340
/* getopt_long stores the option index here. */
338341
int option_index = 0;
339342

340-
c = getopt_long(argc, argv, "c:d:Dhi:np:P:qs:t::T:",
343+
c = getopt_long(argc, argv, "a:c:d:Dhi:np:P:qs:t::T:",
341344
long_options, &option_index);
342345

343346
/* detect the end of the options. */
344347
if (c == -1)
345348
break;
346349

347350
switch (c) {
351+
case 'a':
352+
auto_thresh = get_llong_from_str(optarg);
353+
354+
/* set thread stop to auto_thresh */
355+
params->stop_total_us = auto_thresh;
356+
357+
/* get stack trace */
358+
params->print_stack = auto_thresh;
359+
360+
/* set trace */
361+
params->trace_output = "timerlat_trace.txt";
362+
363+
break;
348364
case 'c':
349365
retval = parse_cpu_list(optarg, &params->monitored_cpus);
350366
if (retval)

0 commit comments

Comments
 (0)