Skip to content

Commit

Permalink
rtla/timerlat: Add the automatic trace option
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Bristot de Oliveira authored and Steven Rostedt (Google) committed Mar 15, 2022
1 parent 2b622ed commit 173a3b0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Documentation/tools/rtla/common_timerlat_options.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
**-a**, **--auto** *us*

Set the automatic trace mode. This mode sets some commonly used options
while debugging the system. It is equivalent to use **-T** *us* **-s** *us*
**-t**. By default, *timerlat* tracer uses FIFO:95 for *timerlat* threads,
thus equilavent to **-P** *f:95*.

**-p**, **--period** *us*

Set the *timerlat* tracer period in microseconds.
Expand Down
24 changes: 20 additions & 4 deletions tools/tracing/rtla/src/timerlat_hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,12 @@ static void timerlat_hist_usage(char *usage)

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

Expand All @@ -491,6 +493,7 @@ static struct timerlat_hist_params

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

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

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

switch (c) {
case 'a':
auto_thresh = get_llong_from_str(optarg);

/* set thread stop to auto_thresh */
params->stop_total_us = auto_thresh;

/* get stack trace */
params->print_stack = auto_thresh;

/* set trace */
params->trace_output = "timerlat_trace.txt";

break;
case 'c':
retval = parse_cpu_list(optarg, &params->monitored_cpus);
if (retval)
Expand Down
22 changes: 19 additions & 3 deletions tools/tracing/rtla/src/timerlat_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,11 @@ static void timerlat_top_usage(char *usage)

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

Expand All @@ -319,6 +321,7 @@ static struct timerlat_top_params

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

c = getopt_long(argc, argv, "c:d:Dhi:np:P:qs:t::T:",
c = getopt_long(argc, argv, "a:c:d:Dhi:np:P:qs:t::T:",
long_options, &option_index);

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

switch (c) {
case 'a':
auto_thresh = get_llong_from_str(optarg);

/* set thread stop to auto_thresh */
params->stop_total_us = auto_thresh;

/* get stack trace */
params->print_stack = auto_thresh;

/* set trace */
params->trace_output = "timerlat_trace.txt";

break;
case 'c':
retval = parse_cpu_list(optarg, &params->monitored_cpus);
if (retval)
Expand Down

0 comments on commit 173a3b0

Please sign in to comment.