Skip to content

Commit

Permalink
Merge tag 'trace-tools-v6.10' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/git/trace/linux-trace

Pull tracing tool updates from Steven Rostedt:
 "Specific for timerlat:

   - Improve the output of timerlat top by adding a missing \n, and by
     avoiding printing color-formatting characters where they are
     translated to regular characters.

   - Improve timerlat auto-analysis output by replacing '\t' with spaces
     to avoid copy-and-paste issues when reporting problems.

   - Make the user-space (-u) option the default, as it is the most
     complete test. Add a -k option to use the in-kernel workload.

   - On timerlat top and hist, add a summary with the overall results.
     For instance, the minimum value for all CPUs, the overall average
     and the maximum value from all CPUs.

   - timerlat hist was printing initial values (i.e., 0 as max, and ~0
     as min) if the trace stopped before the first Ret-User event. This
     problem was fixed by printing the " - " no value string to the
     output if that was the case.

  For all RTLA tools:

   - Add a --warm-up <seconds> option, allowing the workload to run for
     <seconds> before starting to collect results.

   - Add a --trace-buffer-size option, allowing the user to set the
     tracing buffer size for -t option. This option is mainly useful for
     reducing the trace file. Now rtla depends on libtracefs >= 1.6.

   - Fix the -t [trace_file] parsing, now it does not require the '='
     before the option parameter, and better handles the multiple ways a
     user can pass the trace_file.txt"

* tag 'trace-tools-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  rtla: Documentation: Fix -t, --trace
  rtla: Fix -t\--trace[=file]
  rtla/timerlat: Fix histogram report when a cpu count is 0
  rtla: Add --trace-buffer-size option
  rtla/timerlat: Make user-space threads the default
  rtla: Add the --warm-up option
  rtla/timerlat: Add a summary for hist mode
  rtla/timerlat: Add a summary for top mode
  rtla/timerlat: Use pretty formatting only on interactive tty
  rtla/auto-analysis: Replace \t with spaces
  rtla/timerlat: Simplify "no value" printing on top
  • Loading branch information
Linus Torvalds committed May 18, 2024
2 parents fa3889d + 59c22f7 commit 26aa834
Show file tree
Hide file tree
Showing 11 changed files with 653 additions and 153 deletions.
11 changes: 7 additions & 4 deletions Documentation/tools/rtla/common_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

Print debug info.

**-t**, **--trace**\[*=file*]

Save the stopped trace to [*file|osnoise_trace.txt*].

**-e**, **--event** *sys:event*

Enable an event in the trace (**-t**) session. The argument can be a specific event, e.g., **-e** *sched:sched_switch*, or all events of a system group, e.g., **-e** *sched*. Multiple **-e** are allowed. It is only active when **-t** or **-a** are set.
Expand Down Expand Up @@ -50,6 +46,13 @@

Set a *cgroup* to the tracer's threads. If the **-C** option is passed without arguments, the tracer's thread will inherit **rtla**'s *cgroup*. Otherwise, the threads will be placed on the *cgroup* passed to the option.

**--warm-up** *s*

After starting the workload, let it run for *s* seconds before starting collecting the data, allowing the system to warm-up. Statistical data generated during warm-up is discarded.

**--trace-buffer-size** *kB*
Set the per-cpu trace buffer size in kB for the tracing output.

**-h**, **--help**

Print help menu.
4 changes: 4 additions & 0 deletions Documentation/tools/rtla/common_osnoise_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@

Specify the minimum delta between two time reads to be considered noise.
The default threshold is *5 us*.

**-t**, **--trace** \[*file*]

Save the stopped trace to [*file|osnoise_trace.txt*].
10 changes: 9 additions & 1 deletion Documentation/tools/rtla/common_timerlat_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,25 @@
Save the stack trace at the *IRQ* if a *Thread* latency is higher than the
argument in us.

**-t**, **--trace** \[*file*]

Save the stopped trace to [*file|timerlat_trace.txt*].

**--dma-latency** *us*
Set the /dev/cpu_dma_latency to *us*, aiming to bound exit from idle latencies.
*cyclictest* sets this value to *0* by default, use **--dma-latency** *0* to have
similar results.

**-k**, **--kernel-threads**

Use timerlat kernel-space threads, in contrast of **-u**.

**-u**, **--user-threads**

Set timerlat to run without a workload, and then dispatches user-space workloads
to wait on the timerlat_fd. Once the workload is awakes, it goes to sleep again
adding so the measurement for the kernel-to-user and user-to-kernel to the tracer
output.
output. **--user-threads** will be used unless the user specify **-k**.

**-U**, **--user-load**

Expand Down
2 changes: 1 addition & 1 deletion tools/tracing/rtla/Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
STOP_ERROR :=

LIBTRACEEVENT_MIN_VERSION = 1.5
LIBTRACEFS_MIN_VERSION = 1.3
LIBTRACEFS_MIN_VERSION = 1.6

define lib_setup
$(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)"))
Expand Down
55 changes: 47 additions & 8 deletions tools/tracing/rtla/src/osnoise_hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ struct osnoise_hist_params {
cpu_set_t hk_cpu_set;
struct sched_attr sched_param;
struct trace_events *events;

char no_header;
char no_summary;
char no_index;
char with_zeros;
int bucket_size;
int entries;
int warmup;
int buffer_size;
};

struct osnoise_hist_cpu {
Expand Down Expand Up @@ -436,9 +437,9 @@ static void osnoise_hist_usage(char *usage)
static const char * const msg[] = {
"",
" usage: rtla osnoise hist [-h] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
" [-T us] [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
" [-T us] [-t[file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
" [-c cpu-list] [-H cpu-list] [-P priority] [-b N] [-E N] [--no-header] [--no-summary] \\",
" [--no-index] [--with-zeros] [-C[=cgroup_name]]",
" [--no-index] [--with-zeros] [-C[=cgroup_name]] [--warm-up]",
"",
" -h/--help: print this menu",
" -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit",
Expand All @@ -452,7 +453,7 @@ static void osnoise_hist_usage(char *usage)
" -C/--cgroup[=cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
" -d/--duration time[s|m|h|d]: duration of the session",
" -D/--debug: print debug info",
" -t/--trace[=file]: save the stopped trace to [file|osnoise_trace.txt]",
" -t/--trace[file]: save the stopped trace to [file|osnoise_trace.txt]",
" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
" --filter <filter>: enable a trace event filter to the previous -e event",
" --trigger <trigger>: enable a trace event trigger to the previous -e event",
Expand All @@ -468,6 +469,8 @@ static void osnoise_hist_usage(char *usage)
" f:prio - use SCHED_FIFO with prio",
" d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
" 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",
NULL,
};

Expand Down Expand Up @@ -531,13 +534,15 @@ static struct osnoise_hist_params
{"with-zeros", no_argument, 0, '3'},
{"trigger", required_argument, 0, '4'},
{"filter", required_argument, 0, '5'},
{"warm-up", required_argument, 0, '6'},
{"trace-buffer-size", required_argument, 0, '7'},
{0, 0, 0, 0}
};

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

c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:",
c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:7:",
long_options, &option_index);

/* detect the end of the options. */
Expand Down Expand Up @@ -640,9 +645,13 @@ static struct osnoise_hist_params
params->threshold = get_llong_from_str(optarg);
break;
case 't':
if (optarg)
/* skip = */
params->trace_output = &optarg[1];
if (optarg) {
if (optarg[0] == '=')
params->trace_output = &optarg[1];
else
params->trace_output = &optarg[0];
} else if (optind < argc && argv[optind][0] != '0')
params->trace_output = argv[optind];
else
params->trace_output = "osnoise_trace.txt";
break;
Expand Down Expand Up @@ -680,6 +689,12 @@ static struct osnoise_hist_params
osnoise_hist_usage("--filter requires a previous -e\n");
}
break;
case '6':
params->warmup = get_llong_from_str(optarg);
break;
case '7':
params->buffer_size = get_llong_from_str(optarg);
break;
default:
osnoise_hist_usage("Invalid option");
}
Expand Down Expand Up @@ -886,6 +901,11 @@ int osnoise_hist_main(int argc, char *argv[])
goto out_hist;
}

if (params->buffer_size > 0) {
retval = trace_set_buffer_size(&record->trace, params->buffer_size);
if (retval)
goto out_hist;
}
}

/*
Expand All @@ -899,6 +919,25 @@ int osnoise_hist_main(int argc, char *argv[])
trace_instance_start(&record->trace);
trace_instance_start(trace);

if (params->warmup > 0) {
debug_msg("Warming up for %d seconds\n", params->warmup);
sleep(params->warmup);
if (stop_tracing)
goto out_hist;

/*
* Clean up the buffer. The osnoise workload do not run
* with tracing off to avoid creating a performance penalty
* when not needed.
*/
retval = tracefs_instance_file_write(trace->inst, "trace", "");
if (retval < 0) {
debug_msg("Error cleaning up the buffer");
goto out_hist;
}

}

tool->start_time = time(NULL);
osnoise_hist_set_signals(params);

Expand Down
55 changes: 48 additions & 7 deletions tools/tracing/rtla/src/osnoise_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ struct osnoise_top_params {
int set_sched;
int cgroup;
int hk_cpus;
int warmup;
int buffer_size;
cpu_set_t hk_cpu_set;
struct sched_attr sched_param;
struct trace_events *events;
Expand Down Expand Up @@ -281,8 +283,8 @@ static void osnoise_top_usage(struct osnoise_top_params *params, char *usage)

static const char * const msg[] = {
" [-h] [-q] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
" [-T us] [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
" [-c cpu-list] [-H cpu-list] [-P priority] [-C[=cgroup_name]]",
" [-T us] [-t[file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
" [-c cpu-list] [-H cpu-list] [-P priority] [-C[=cgroup_name]] [--warm-up s]",
"",
" -h/--help: print this menu",
" -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit",
Expand All @@ -296,7 +298,7 @@ static void osnoise_top_usage(struct osnoise_top_params *params, char *usage)
" -C/--cgroup[=cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
" -d/--duration time[s|m|h|d]: duration of the session",
" -D/--debug: print debug info",
" -t/--trace[=file]: save the stopped trace to [file|osnoise_trace.txt]",
" -t/--trace[file]: save the stopped trace to [file|osnoise_trace.txt]",
" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
" --filter <filter>: enable a trace event filter to the previous -e event",
" --trigger <trigger>: enable a trace event trigger to the previous -e event",
Expand All @@ -307,6 +309,8 @@ static void osnoise_top_usage(struct osnoise_top_params *params, char *usage)
" f:prio - use SCHED_FIFO with prio",
" d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
" 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",
NULL,
};

Expand Down Expand Up @@ -381,13 +385,15 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
{"trace", optional_argument, 0, 't'},
{"trigger", required_argument, 0, '0'},
{"filter", required_argument, 0, '1'},
{"warm-up", required_argument, 0, '2'},
{"trace-buffer-size", required_argument, 0, '3'},
{0, 0, 0, 0}
};

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

c = getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:",
c = getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:",
long_options, &option_index);

/* Detect the end of the options. */
Expand Down Expand Up @@ -480,9 +486,13 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
params->stop_total_us = get_llong_from_str(optarg);
break;
case 't':
if (optarg)
/* skip = */
params->trace_output = &optarg[1];
if (optarg) {
if (optarg[0] == '=')
params->trace_output = &optarg[1];
else
params->trace_output = &optarg[0];
} else if (optind < argc && argv[optind][0] != '-')
params->trace_output = argv[optind];
else
params->trace_output = "osnoise_trace.txt";
break;
Expand Down Expand Up @@ -511,6 +521,12 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
osnoise_top_usage(params, "--filter requires a previous -e\n");
}
break;
case '2':
params->warmup = get_llong_from_str(optarg);
break;
case '3':
params->buffer_size = get_llong_from_str(optarg);
break;
default:
osnoise_top_usage(params, "Invalid option");
}
Expand Down Expand Up @@ -719,6 +735,12 @@ int osnoise_top_main(int argc, char **argv)
if (retval)
goto out_top;
}

if (params->buffer_size > 0) {
retval = trace_set_buffer_size(&record->trace, params->buffer_size);
if (retval)
goto out_top;
}
}

/*
Expand All @@ -732,6 +754,25 @@ int osnoise_top_main(int argc, char **argv)
trace_instance_start(&record->trace);
trace_instance_start(trace);

if (params->warmup > 0) {
debug_msg("Warming up for %d seconds\n", params->warmup);
sleep(params->warmup);
if (stop_tracing)
goto out_top;

/*
* Clean up the buffer. The osnoise workload do not run
* with tracing off to avoid creating a performance penalty
* when not needed.
*/
retval = tracefs_instance_file_write(trace->inst, "trace", "");
if (retval < 0) {
debug_msg("Error cleaning up the buffer");
goto out_top;
}

}

tool->start_time = time(NULL);
osnoise_top_set_signals(params);

Expand Down
Loading

0 comments on commit 26aa834

Please sign in to comment.