Skip to content

Commit 26aa834

Browse files
committed
Merge tag 'trace-tools-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/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
2 parents fa3889d + 59c22f7 commit 26aa834

File tree

11 files changed

+653
-153
lines changed

11 files changed

+653
-153
lines changed

Documentation/tools/rtla/common_options.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414

1515
Print debug info.
1616

17-
**-t**, **--trace**\[*=file*]
18-
19-
Save the stopped trace to [*file|osnoise_trace.txt*].
20-
2117
**-e**, **--event** *sys:event*
2218

2319
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.
@@ -50,6 +46,13 @@
5046

5147
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.
5248

49+
**--warm-up** *s*
50+
51+
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.
52+
53+
**--trace-buffer-size** *kB*
54+
Set the per-cpu trace buffer size in kB for the tracing output.
55+
5356
**-h**, **--help**
5457

5558
Print help menu.

Documentation/tools/rtla/common_osnoise_options.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@
2525

2626
Specify the minimum delta between two time reads to be considered noise.
2727
The default threshold is *5 us*.
28+
29+
**-t**, **--trace** \[*file*]
30+
31+
Save the stopped trace to [*file|osnoise_trace.txt*].

Documentation/tools/rtla/common_timerlat_options.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,25 @@
2222
Save the stack trace at the *IRQ* if a *Thread* latency is higher than the
2323
argument in us.
2424

25+
**-t**, **--trace** \[*file*]
26+
27+
Save the stopped trace to [*file|timerlat_trace.txt*].
28+
2529
**--dma-latency** *us*
2630
Set the /dev/cpu_dma_latency to *us*, aiming to bound exit from idle latencies.
2731
*cyclictest* sets this value to *0* by default, use **--dma-latency** *0* to have
2832
similar results.
2933

34+
**-k**, **--kernel-threads**
35+
36+
Use timerlat kernel-space threads, in contrast of **-u**.
37+
3038
**-u**, **--user-threads**
3139

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

3745
**-U**, **--user-load**
3846

tools/tracing/rtla/Makefile.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
STOP_ERROR :=
44

55
LIBTRACEEVENT_MIN_VERSION = 1.5
6-
LIBTRACEFS_MIN_VERSION = 1.3
6+
LIBTRACEFS_MIN_VERSION = 1.6
77

88
define lib_setup
99
$(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)"))

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ struct osnoise_hist_params {
3636
cpu_set_t hk_cpu_set;
3737
struct sched_attr sched_param;
3838
struct trace_events *events;
39-
4039
char no_header;
4140
char no_summary;
4241
char no_index;
4342
char with_zeros;
4443
int bucket_size;
4544
int entries;
45+
int warmup;
46+
int buffer_size;
4647
};
4748

4849
struct osnoise_hist_cpu {
@@ -436,9 +437,9 @@ static void osnoise_hist_usage(char *usage)
436437
static const char * const msg[] = {
437438
"",
438439
" usage: rtla osnoise hist [-h] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
439-
" [-T us] [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
440+
" [-T us] [-t[file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
440441
" [-c cpu-list] [-H cpu-list] [-P priority] [-b N] [-E N] [--no-header] [--no-summary] \\",
441-
" [--no-index] [--with-zeros] [-C[=cgroup_name]]",
442+
" [--no-index] [--with-zeros] [-C[=cgroup_name]] [--warm-up]",
442443
"",
443444
" -h/--help: print this menu",
444445
" -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit",
@@ -452,7 +453,7 @@ static void osnoise_hist_usage(char *usage)
452453
" -C/--cgroup[=cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
453454
" -d/--duration time[s|m|h|d]: duration of the session",
454455
" -D/--debug: print debug info",
455-
" -t/--trace[=file]: save the stopped trace to [file|osnoise_trace.txt]",
456+
" -t/--trace[file]: save the stopped trace to [file|osnoise_trace.txt]",
456457
" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
457458
" --filter <filter>: enable a trace event filter to the previous -e event",
458459
" --trigger <trigger>: enable a trace event trigger to the previous -e event",
@@ -468,6 +469,8 @@ static void osnoise_hist_usage(char *usage)
468469
" f:prio - use SCHED_FIFO with prio",
469470
" d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
470471
" in nanoseconds",
472+
" --warm-up: let the workload run for s seconds before collecting data",
473+
" --trace-buffer-size kB: set the per-cpu trace buffer size in kB",
471474
NULL,
472475
};
473476

@@ -531,13 +534,15 @@ static struct osnoise_hist_params
531534
{"with-zeros", no_argument, 0, '3'},
532535
{"trigger", required_argument, 0, '4'},
533536
{"filter", required_argument, 0, '5'},
537+
{"warm-up", required_argument, 0, '6'},
538+
{"trace-buffer-size", required_argument, 0, '7'},
534539
{0, 0, 0, 0}
535540
};
536541

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

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

543548
/* detect the end of the options. */
@@ -640,9 +645,13 @@ static struct osnoise_hist_params
640645
params->threshold = get_llong_from_str(optarg);
641646
break;
642647
case 't':
643-
if (optarg)
644-
/* skip = */
645-
params->trace_output = &optarg[1];
648+
if (optarg) {
649+
if (optarg[0] == '=')
650+
params->trace_output = &optarg[1];
651+
else
652+
params->trace_output = &optarg[0];
653+
} else if (optind < argc && argv[optind][0] != '0')
654+
params->trace_output = argv[optind];
646655
else
647656
params->trace_output = "osnoise_trace.txt";
648657
break;
@@ -680,6 +689,12 @@ static struct osnoise_hist_params
680689
osnoise_hist_usage("--filter requires a previous -e\n");
681690
}
682691
break;
692+
case '6':
693+
params->warmup = get_llong_from_str(optarg);
694+
break;
695+
case '7':
696+
params->buffer_size = get_llong_from_str(optarg);
697+
break;
683698
default:
684699
osnoise_hist_usage("Invalid option");
685700
}
@@ -886,6 +901,11 @@ int osnoise_hist_main(int argc, char *argv[])
886901
goto out_hist;
887902
}
888903

904+
if (params->buffer_size > 0) {
905+
retval = trace_set_buffer_size(&record->trace, params->buffer_size);
906+
if (retval)
907+
goto out_hist;
908+
}
889909
}
890910

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

922+
if (params->warmup > 0) {
923+
debug_msg("Warming up for %d seconds\n", params->warmup);
924+
sleep(params->warmup);
925+
if (stop_tracing)
926+
goto out_hist;
927+
928+
/*
929+
* Clean up the buffer. The osnoise workload do not run
930+
* with tracing off to avoid creating a performance penalty
931+
* when not needed.
932+
*/
933+
retval = tracefs_instance_file_write(trace->inst, "trace", "");
934+
if (retval < 0) {
935+
debug_msg("Error cleaning up the buffer");
936+
goto out_hist;
937+
}
938+
939+
}
940+
902941
tool->start_time = time(NULL);
903942
osnoise_hist_set_signals(params);
904943

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ struct osnoise_top_params {
4040
int set_sched;
4141
int cgroup;
4242
int hk_cpus;
43+
int warmup;
44+
int buffer_size;
4345
cpu_set_t hk_cpu_set;
4446
struct sched_attr sched_param;
4547
struct trace_events *events;
@@ -281,8 +283,8 @@ static void osnoise_top_usage(struct osnoise_top_params *params, char *usage)
281283

282284
static const char * const msg[] = {
283285
" [-h] [-q] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
284-
" [-T us] [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
285-
" [-c cpu-list] [-H cpu-list] [-P priority] [-C[=cgroup_name]]",
286+
" [-T us] [-t[file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
287+
" [-c cpu-list] [-H cpu-list] [-P priority] [-C[=cgroup_name]] [--warm-up s]",
286288
"",
287289
" -h/--help: print this menu",
288290
" -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit",
@@ -296,7 +298,7 @@ static void osnoise_top_usage(struct osnoise_top_params *params, char *usage)
296298
" -C/--cgroup[=cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
297299
" -d/--duration time[s|m|h|d]: duration of the session",
298300
" -D/--debug: print debug info",
299-
" -t/--trace[=file]: save the stopped trace to [file|osnoise_trace.txt]",
301+
" -t/--trace[file]: save the stopped trace to [file|osnoise_trace.txt]",
300302
" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
301303
" --filter <filter>: enable a trace event filter to the previous -e event",
302304
" --trigger <trigger>: enable a trace event trigger to the previous -e event",
@@ -307,6 +309,8 @@ static void osnoise_top_usage(struct osnoise_top_params *params, char *usage)
307309
" f:prio - use SCHED_FIFO with prio",
308310
" d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
309311
" in nanoseconds",
312+
" --warm-up s: let the workload run for s seconds before collecting data",
313+
" --trace-buffer-size kB: set the per-cpu trace buffer size in kB",
310314
NULL,
311315
};
312316

@@ -381,13 +385,15 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
381385
{"trace", optional_argument, 0, 't'},
382386
{"trigger", required_argument, 0, '0'},
383387
{"filter", required_argument, 0, '1'},
388+
{"warm-up", required_argument, 0, '2'},
389+
{"trace-buffer-size", required_argument, 0, '3'},
384390
{0, 0, 0, 0}
385391
};
386392

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

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

393399
/* Detect the end of the options. */
@@ -480,9 +486,13 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
480486
params->stop_total_us = get_llong_from_str(optarg);
481487
break;
482488
case 't':
483-
if (optarg)
484-
/* skip = */
485-
params->trace_output = &optarg[1];
489+
if (optarg) {
490+
if (optarg[0] == '=')
491+
params->trace_output = &optarg[1];
492+
else
493+
params->trace_output = &optarg[0];
494+
} else if (optind < argc && argv[optind][0] != '-')
495+
params->trace_output = argv[optind];
486496
else
487497
params->trace_output = "osnoise_trace.txt";
488498
break;
@@ -511,6 +521,12 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
511521
osnoise_top_usage(params, "--filter requires a previous -e\n");
512522
}
513523
break;
524+
case '2':
525+
params->warmup = get_llong_from_str(optarg);
526+
break;
527+
case '3':
528+
params->buffer_size = get_llong_from_str(optarg);
529+
break;
514530
default:
515531
osnoise_top_usage(params, "Invalid option");
516532
}
@@ -719,6 +735,12 @@ int osnoise_top_main(int argc, char **argv)
719735
if (retval)
720736
goto out_top;
721737
}
738+
739+
if (params->buffer_size > 0) {
740+
retval = trace_set_buffer_size(&record->trace, params->buffer_size);
741+
if (retval)
742+
goto out_top;
743+
}
722744
}
723745

724746
/*
@@ -732,6 +754,25 @@ int osnoise_top_main(int argc, char **argv)
732754
trace_instance_start(&record->trace);
733755
trace_instance_start(trace);
734756

757+
if (params->warmup > 0) {
758+
debug_msg("Warming up for %d seconds\n", params->warmup);
759+
sleep(params->warmup);
760+
if (stop_tracing)
761+
goto out_top;
762+
763+
/*
764+
* Clean up the buffer. The osnoise workload do not run
765+
* with tracing off to avoid creating a performance penalty
766+
* when not needed.
767+
*/
768+
retval = tracefs_instance_file_write(trace->inst, "trace", "");
769+
if (retval < 0) {
770+
debug_msg("Error cleaning up the buffer");
771+
goto out_top;
772+
}
773+
774+
}
775+
735776
tool->start_time = time(NULL);
736777
osnoise_top_set_signals(params);
737778

0 commit comments

Comments
 (0)