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

rtla/osnoise: Add the automatic trace option

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>

authored by

Daniel Bristot de Oliveira and committed by
Steven Rostedt (Google)
2b622edd d635316a

+37 -6
+5
Documentation/tools/rtla/common_osnoise_options.rst
··· 1 + **-a**, **--auto** *us* 2 + 3 + Set the automatic trace mode. This mode sets some commonly used options 4 + while debugging the system. It is equivalent to use **-s** *us* **-T 1 -t**. 5 + 1 6 **-p**, **--period** *us* 2 7 3 8 Set the *osnoise* tracer period in microseconds.
+16 -3
tools/tracing/rtla/src/osnoise_hist.c
··· 426 426 427 427 static const char * const msg[] = { 428 428 "", 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] \\", 429 + " usage: rtla osnoise hist [-h] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\", 430 + " [-T us] [-t[=file]] [-c cpu-list] [-P priority] [-b N] [-E N] [--no-header] \\", 431 431 " [--no-summary] [--no-index] [--with-zeros]", 432 432 "", 433 433 " -h/--help: print this menu", 434 + " -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit", 434 435 " -p/--period us: osnoise period in us", 435 436 " -r/--runtime us: osnoise runtime in us", 436 437 " -s/--stop us: stop trace if a single sample is higher than the argument in us", ··· 488 487 489 488 while (1) { 490 489 static struct option long_options[] = { 490 + {"auto", required_argument, 0, 'a'}, 491 491 {"bucket-size", required_argument, 0, 'b'}, 492 492 {"entries", required_argument, 0, 'E'}, 493 493 {"cpus", required_argument, 0, 'c'}, ··· 512 510 /* getopt_long stores the option index here. */ 513 511 int option_index = 0; 514 512 515 - c = getopt_long(argc, argv, "c:b:d:E:Dhp:P:r:s:S:t::T:0123", 513 + c = getopt_long(argc, argv, "a:c:b:d:E:Dhp:P:r:s:S:t::T:0123", 516 514 long_options, &option_index); 517 515 518 516 /* detect the end of the options. */ ··· 520 518 break; 521 519 522 520 switch (c) { 521 + case 'a': 522 + /* set sample stop to auto_thresh */ 523 + params->stop_us = get_llong_from_str(optarg); 524 + 525 + /* set sample threshold to 1 */ 526 + params->threshold = 1; 527 + 528 + /* set trace */ 529 + params->trace_output = "osnoise_trace.txt"; 530 + 531 + break; 523 532 case 'b': 524 533 params->bucket_size = get_llong_from_str(optarg); 525 534 if ((params->bucket_size == 0) || (params->bucket_size >= 1000000))
+16 -3
tools/tracing/rtla/src/osnoise_top.c
··· 245 245 int i; 246 246 247 247 static const char * const msg[] = { 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]", 248 + " usage: rtla osnoise [top] [-h] [-q] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\", 249 + " [-T us] [-t[=file]] [-c cpu-list] [-P priority]", 250 250 "", 251 251 " -h/--help: print this menu", 252 + " -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit", 252 253 " -p/--period us: osnoise period in us", 253 254 " -r/--runtime us: osnoise runtime in us", 254 255 " -s/--stop us: stop trace if a single sample is higher than the argument in us", ··· 295 294 296 295 while (1) { 297 296 static struct option long_options[] = { 297 + {"auto", required_argument, 0, 'a'}, 298 298 {"cpus", required_argument, 0, 'c'}, 299 299 {"debug", no_argument, 0, 'D'}, 300 300 {"duration", required_argument, 0, 'd'}, ··· 314 312 /* getopt_long stores the option index here. */ 315 313 int option_index = 0; 316 314 317 - c = getopt_long(argc, argv, "c:d:Dhp:P:qr:s:S:t::T:", 315 + c = getopt_long(argc, argv, "a:c:d:Dhp:P:qr:s:S:t::T:", 318 316 long_options, &option_index); 319 317 320 318 /* Detect the end of the options. */ ··· 322 320 break; 323 321 324 322 switch (c) { 323 + case 'a': 324 + /* set sample stop to auto_thresh */ 325 + params->stop_us = get_llong_from_str(optarg); 326 + 327 + /* set sample threshold to 1 */ 328 + params->threshold = 1; 329 + 330 + /* set trace */ 331 + params->trace_output = "osnoise_trace.txt"; 332 + 333 + break; 325 334 case 'c': 326 335 retval = parse_cpu_list(optarg, &params->monitored_cpus); 327 336 if (retval)