Skip to content

Commit d635316

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
rtla/osnoise: Add an option to set the threshold
Add the -T/--threshold option to set the minimum threshold to be considered a noise to osnoise top and hist commands. Also update the man pages. Link: https://lkml.kernel.org/r/031861200ffdb24a1df4aa72c458706889a20d5d.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 61c57d5 commit d635316

3 files changed

Lines changed: 40 additions & 7 deletions

File tree

Documentation/tools/rtla/common_osnoise_options.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@
1515

1616
Stop the trace if the total sample is higher than the argument in microseconds.
1717
If **-T** is set, it will also save the trace to the output.
18+
19+
**-T**, **--threshold** *us*
20+
21+
Specify the minimum delta between two time reads to be considered noise.
22+
The default threshold is *5 us*.

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct osnoise_hist_params {
2121
char *trace_output;
2222
unsigned long long runtime;
2323
unsigned long long period;
24+
long long threshold;
2425
long long stop_us;
2526
long long stop_total_us;
2627
int sleep_time;
@@ -425,15 +426,16 @@ static void osnoise_hist_usage(char *usage)
425426

426427
static const char * const msg[] = {
427428
"",
428-
" usage: rtla osnoise hist [-h] [-D] [-d s] [-p us] [-r us] [-s us] [-S us] [-t[=file]] \\",
429-
" [-c cpu-list] [-P priority] [-b N] [-E N] [--no-header] [--no-summary] \\",
430-
" [--no-index] [--with-zeros]",
429+
" usage: rtla osnoise hist [-h] [-D] [-d s] [-p us] [-r us] [-s us] [-S us] [-T us] \\",
430+
" [-t[=file]] [-c cpu-list] [-P priority] [-b N] [-E N] [--no-header] \\",
431+
" [--no-summary] [--no-index] [--with-zeros]",
431432
"",
432433
" -h/--help: print this menu",
433434
" -p/--period us: osnoise period in us",
434435
" -r/--runtime us: osnoise runtime in us",
435436
" -s/--stop us: stop trace if a single sample is higher than the argument in us",
436437
" -S/--stop-total us: stop trace if the total sample is higher than the argument in us",
438+
" -T/--threshold us: the minimum delta to be considered a noise",
437439
" -c/--cpus cpu-list: list of cpus to run osnoise threads",
438440
" -d/--duration time[s|m|h|d]: duration of the session",
439441
" -D/--debug: print debug info",
@@ -497,6 +499,7 @@ static struct osnoise_hist_params
497499
{"stop", required_argument, 0, 's'},
498500
{"stop-total", required_argument, 0, 'S'},
499501
{"trace", optional_argument, 0, 't'},
502+
{"threshold", required_argument, 0, 'T'},
500503
{"no-header", no_argument, 0, '0'},
501504
{"no-summary", no_argument, 0, '1'},
502505
{"no-index", no_argument, 0, '2'},
@@ -507,7 +510,7 @@ static struct osnoise_hist_params
507510
/* getopt_long stores the option index here. */
508511
int option_index = 0;
509512

510-
c = getopt_long(argc, argv, "c:b:d:E:Dhp:P:r:s:S:t::0123",
513+
c = getopt_long(argc, argv, "c:b:d:E:Dhp:P:r:s:S:t::T:0123",
511514
long_options, &option_index);
512515

513516
/* detect the end of the options. */
@@ -565,6 +568,9 @@ static struct osnoise_hist_params
565568
case 'S':
566569
params->stop_total_us = get_llong_from_str(optarg);
567570
break;
571+
case 'T':
572+
params->threshold = get_llong_from_str(optarg);
573+
break;
568574
case 't':
569575
if (optarg)
570576
/* skip = */
@@ -645,6 +651,14 @@ osnoise_hist_apply_config(struct osnoise_tool *tool, struct osnoise_hist_params
645651
}
646652
}
647653

654+
if (params->threshold) {
655+
retval = osnoise_set_tracing_thresh(tool->context, params->threshold);
656+
if (retval) {
657+
err_msg("Failed to set tracing_thresh\n");
658+
goto out_err;
659+
}
660+
}
661+
648662
return 0;
649663

650664
out_err:

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct osnoise_top_params {
2323
char *trace_output;
2424
unsigned long long runtime;
2525
unsigned long long period;
26+
long long threshold;
2627
long long stop_us;
2728
long long stop_total_us;
2829
int sleep_time;
@@ -244,14 +245,15 @@ void osnoise_top_usage(char *usage)
244245
int i;
245246

246247
static const char * const msg[] = {
247-
" usage: rtla osnoise [top] [-h] [-q] [-D] [-d s] [-p us] [-r us] [-s us] [-S us] [-t[=file]] \\",
248-
" [-c cpu-list] [-P priority]",
248+
" usage: rtla osnoise [top] [-h] [-q] [-D] [-d s] [-p us] [-r us] [-s us] [-S us] [-T us] \\",
249+
" [-t[=file]] [-c cpu-list] [-P priority]",
249250
"",
250251
" -h/--help: print this menu",
251252
" -p/--period us: osnoise period in us",
252253
" -r/--runtime us: osnoise runtime in us",
253254
" -s/--stop us: stop trace if a single sample is higher than the argument in us",
254255
" -S/--stop-total us: stop trace if the total sample is higher than the argument in us",
256+
" -T/--threshold us: the minimum delta to be considered a noise",
255257
" -c/--cpus cpu-list: list of cpus to run osnoise threads",
256258
" -d/--duration time[s|m|h|d]: duration of the session",
257259
" -D/--debug: print debug info",
@@ -302,14 +304,15 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
302304
{"runtime", required_argument, 0, 'r'},
303305
{"stop", required_argument, 0, 's'},
304306
{"stop-total", required_argument, 0, 'S'},
307+
{"threshold", required_argument, 0, 'T'},
305308
{"trace", optional_argument, 0, 't'},
306309
{0, 0, 0, 0}
307310
};
308311

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

312-
c = getopt_long(argc, argv, "c:d:Dhp:P:qr:s:S:t::",
315+
c = getopt_long(argc, argv, "c:d:Dhp:P:qr:s:S:t::T:",
313316
long_options, &option_index);
314317

315318
/* Detect the end of the options. */
@@ -367,6 +370,9 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
367370
else
368371
params->trace_output = "osnoise_trace.txt";
369372
break;
373+
case 'T':
374+
params->threshold = get_llong_from_str(optarg);
375+
break;
370376
default:
371377
osnoise_top_usage("Invalid option");
372378
}
@@ -425,6 +431,14 @@ osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_top_params *p
425431
}
426432
}
427433

434+
if (params->threshold) {
435+
retval = osnoise_set_tracing_thresh(tool->context, params->threshold);
436+
if (retval) {
437+
err_msg("Failed to set tracing_thresh\n");
438+
goto out_err;
439+
}
440+
}
441+
428442
return 0;
429443

430444
out_err:

0 commit comments

Comments
 (0)