Skip to content

Commit

Permalink
rtla/osnoise: 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_us with the argument,
setting tracing_thresh to 1 us, and saving the trace to osnoise_trace.txt
file if the trace is stopped automatically.

Link: https://lkml.kernel.org/r/ef04c961b227eb93a83cd0b54bfca45e1a381b77.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 d635316 commit 2b622ed
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Documentation/tools/rtla/common_osnoise_options.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
**-a**, **--auto** *us*

Set the automatic trace mode. This mode sets some commonly used options
while debugging the system. It is equivalent to use **-s** *us* **-T 1 -t**.

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

Set the *osnoise* tracer period in microseconds.
Expand Down
19 changes: 16 additions & 3 deletions tools/tracing/rtla/src/osnoise_hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,12 @@ static void osnoise_hist_usage(char *usage)

static const char * const msg[] = {
"",
" usage: rtla osnoise hist [-h] [-D] [-d s] [-p us] [-r us] [-s us] [-S us] [-T us] \\",
" [-t[=file]] [-c cpu-list] [-P priority] [-b N] [-E N] [--no-header] \\",
" usage: rtla osnoise hist [-h] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
" [-T us] [-t[=file]] [-c cpu-list] [-P priority] [-b N] [-E N] [--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 sample is hit",
" -p/--period us: osnoise period in us",
" -r/--runtime us: osnoise runtime in us",
" -s/--stop us: stop trace if a single sample is higher than the argument in us",
Expand Down Expand Up @@ -487,6 +488,7 @@ static struct osnoise_hist_params

while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
{"bucket-size", required_argument, 0, 'b'},
{"entries", required_argument, 0, 'E'},
{"cpus", required_argument, 0, 'c'},
Expand All @@ -510,14 +512,25 @@ static struct osnoise_hist_params
/* getopt_long stores the option index here. */
int option_index = 0;

c = getopt_long(argc, argv, "c:b:d:E:Dhp:P:r:s:S:t::T:0123",
c = getopt_long(argc, argv, "a:c:b:d:E:Dhp:P:r:s:S:t::T:0123",
long_options, &option_index);

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

switch (c) {
case 'a':
/* set sample stop to auto_thresh */
params->stop_us = get_llong_from_str(optarg);

/* set sample threshold to 1 */
params->threshold = 1;

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

break;
case 'b':
params->bucket_size = get_llong_from_str(optarg);
if ((params->bucket_size == 0) || (params->bucket_size >= 1000000))
Expand Down
19 changes: 16 additions & 3 deletions tools/tracing/rtla/src/osnoise_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,11 @@ void osnoise_top_usage(char *usage)
int i;

static const char * const msg[] = {
" usage: rtla osnoise [top] [-h] [-q] [-D] [-d s] [-p us] [-r us] [-s us] [-S us] [-T us] \\",
" [-t[=file]] [-c cpu-list] [-P priority]",
" usage: rtla osnoise [top] [-h] [-q] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
" [-T 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 sample is hit",
" -p/--period us: osnoise period in us",
" -r/--runtime us: osnoise runtime in us",
" -s/--stop us: stop trace if a single sample is higher than the argument in us",
Expand Down Expand Up @@ -294,6 +295,7 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)

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 @@ -312,14 +314,25 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
/* getopt_long stores the option index here. */
int option_index = 0;

c = getopt_long(argc, argv, "c:d:Dhp:P:qr:s:S:t::T:",
c = getopt_long(argc, argv, "a:c:d:Dhp:P:qr:s:S:t::T:",
long_options, &option_index);

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

switch (c) {
case 'a':
/* set sample stop to auto_thresh */
params->stop_us = get_llong_from_str(optarg);

/* set sample threshold to 1 */
params->threshold = 1;

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

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

0 comments on commit 2b622ed

Please sign in to comment.