Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Daniel Bristot de Oliveira and committed by
Steven Rostedt (Google)
d635316a 61c57d57

+40 -7
+5
Documentation/tools/rtla/common_osnoise_options.rst
··· 15 15 16 16 Stop the trace if the total sample is higher than the argument in microseconds. 17 17 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*.
+18 -4
tools/tracing/rtla/src/osnoise_hist.c
··· 21 21 char *trace_output; 22 22 unsigned long long runtime; 23 23 unsigned long long period; 24 + long long threshold; 24 25 long long stop_us; 25 26 long long stop_total_us; 26 27 int sleep_time; ··· 426 425 427 426 static const char * const msg[] = { 428 427 "", 429 - " usage: rtla osnoise hist [-h] [-D] [-d s] [-p us] [-r us] [-s us] [-S us] [-t[=file]] \\", 430 - " [-c cpu-list] [-P priority] [-b N] [-E N] [--no-header] [--no-summary] \\", 431 - " [--no-index] [--with-zeros]", 428 + " usage: rtla osnoise hist [-h] [-D] [-d s] [-p us] [-r us] [-s us] [-S us] [-T us] \\", 429 + " [-t[=file]] [-c cpu-list] [-P priority] [-b N] [-E N] [--no-header] \\", 430 + " [--no-summary] [--no-index] [--with-zeros]", 432 431 "", 433 432 " -h/--help: print this menu", 434 433 " -p/--period us: osnoise period in us", 435 434 " -r/--runtime us: osnoise runtime in us", 436 435 " -s/--stop us: stop trace if a single sample is higher than the argument in us", 437 436 " -S/--stop-total us: stop trace if the total sample is higher than the argument in us", 437 + " -T/--threshold us: the minimum delta to be considered a noise", 438 438 " -c/--cpus cpu-list: list of cpus to run osnoise threads", 439 439 " -d/--duration time[s|m|h|d]: duration of the session", 440 440 " -D/--debug: print debug info", ··· 499 497 {"stop", required_argument, 0, 's'}, 500 498 {"stop-total", required_argument, 0, 'S'}, 501 499 {"trace", optional_argument, 0, 't'}, 500 + {"threshold", required_argument, 0, 'T'}, 502 501 {"no-header", no_argument, 0, '0'}, 503 502 {"no-summary", no_argument, 0, '1'}, 504 503 {"no-index", no_argument, 0, '2'}, ··· 510 507 /* getopt_long stores the option index here. */ 511 508 int option_index = 0; 512 509 513 - c = getopt_long(argc, argv, "c:b:d:E:Dhp:P:r:s:S:t::0123", 510 + c = getopt_long(argc, argv, "c:b:d:E:Dhp:P:r:s:S:t::T:0123", 514 511 long_options, &option_index); 515 512 516 513 /* detect the end of the options. */ ··· 567 564 break; 568 565 case 'S': 569 566 params->stop_total_us = get_llong_from_str(optarg); 567 + break; 568 + case 'T': 569 + params->threshold = get_llong_from_str(optarg); 570 570 break; 571 571 case 't': 572 572 if (optarg) ··· 647 641 retval = osnoise_set_stop_total_us(tool->context, params->stop_total_us); 648 642 if (retval) { 649 643 err_msg("Failed to set stop total us\n"); 644 + goto out_err; 645 + } 646 + } 647 + 648 + if (params->threshold) { 649 + retval = osnoise_set_tracing_thresh(tool->context, params->threshold); 650 + if (retval) { 651 + err_msg("Failed to set tracing_thresh\n"); 650 652 goto out_err; 651 653 } 652 654 }
+17 -3
tools/tracing/rtla/src/osnoise_top.c
··· 23 23 char *trace_output; 24 24 unsigned long long runtime; 25 25 unsigned long long period; 26 + long long threshold; 26 27 long long stop_us; 27 28 long long stop_total_us; 28 29 int sleep_time; ··· 245 244 int i; 246 245 247 246 static const char * const msg[] = { 248 - " usage: rtla osnoise [top] [-h] [-q] [-D] [-d s] [-p us] [-r us] [-s us] [-S us] [-t[=file]] \\", 249 - " [-c cpu-list] [-P priority]", 247 + " usage: rtla osnoise [top] [-h] [-q] [-D] [-d s] [-p us] [-r us] [-s us] [-S us] [-T us] \\", 248 + " [-t[=file]] [-c cpu-list] [-P priority]", 250 249 "", 251 250 " -h/--help: print this menu", 252 251 " -p/--period us: osnoise period in us", 253 252 " -r/--runtime us: osnoise runtime in us", 254 253 " -s/--stop us: stop trace if a single sample is higher than the argument in us", 255 254 " -S/--stop-total us: stop trace if the total sample is higher than the argument in us", 255 + " -T/--threshold us: the minimum delta to be considered a noise", 256 256 " -c/--cpus cpu-list: list of cpus to run osnoise threads", 257 257 " -d/--duration time[s|m|h|d]: duration of the session", 258 258 " -D/--debug: print debug info", ··· 304 302 {"runtime", required_argument, 0, 'r'}, 305 303 {"stop", required_argument, 0, 's'}, 306 304 {"stop-total", required_argument, 0, 'S'}, 305 + {"threshold", required_argument, 0, 'T'}, 307 306 {"trace", optional_argument, 0, 't'}, 308 307 {0, 0, 0, 0} 309 308 }; ··· 312 309 /* getopt_long stores the option index here. */ 313 310 int option_index = 0; 314 311 315 - c = getopt_long(argc, argv, "c:d:Dhp:P:qr:s:S:t::", 312 + c = getopt_long(argc, argv, "c:d:Dhp:P:qr:s:S:t::T:", 316 313 long_options, &option_index); 317 314 318 315 /* Detect the end of the options. */ ··· 370 367 else 371 368 params->trace_output = "osnoise_trace.txt"; 372 369 break; 370 + case 'T': 371 + params->threshold = get_llong_from_str(optarg); 372 + break; 373 373 default: 374 374 osnoise_top_usage("Invalid option"); 375 375 } ··· 427 421 retval = osnoise_set_stop_total_us(tool->context, params->stop_total_us); 428 422 if (retval) { 429 423 err_msg("Failed to set stop total us\n"); 424 + goto out_err; 425 + } 426 + } 427 + 428 + if (params->threshold) { 429 + retval = osnoise_set_tracing_thresh(tool->context, params->threshold); 430 + if (retval) { 431 + err_msg("Failed to set tracing_thresh\n"); 430 432 goto out_err; 431 433 } 432 434 }