Skip to content

Commit 44f3a37

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
rtla: Add --filter support
Add --filter option. This option enables a trace event filtering of the previous -e sys:event argument. This option is available for all current tools. Link: https://lkml.kernel.org/r/509d70b6348d3e5bcbf1f07ab725ce08d063149a.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 5487b6c commit 44f3a37

5 files changed

Lines changed: 70 additions & 10 deletions

File tree

Documentation/tools/rtla/common_options.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
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.
2020

21+
**--filter** *<filter>*
22+
23+
Filter the previous **-e** *sys:event* event with *<filter>*. For further information about event filtering see https://www.kernel.org/doc/html/latest/trace/events.html#event-filtering.
24+
2125
**--trigger** *<trigger>*
2226
Enable a trace event trigger to the previous **-e** *sys:event*. For further information about event trigger see https://www.kernel.org/doc/html/latest/trace/events.html#event-triggers.
2327

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,9 @@ static void osnoise_hist_usage(char *usage)
428428
static const char * const msg[] = {
429429
"",
430430
" usage: rtla osnoise hist [-h] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
431-
" [-T us] [-t[=file]] [-e sys[:event]] [--trigger <trigger>] [-c cpu-list] [-P priority] \\",
432-
" [-b N] [-E N] [--no-header] [--no-summary] [--no-index] [--with-zeros]",
431+
" [-T us] [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
432+
" [-c cpu-list] [-P priority] [-b N] [-E N] [--no-header] [--no-summary] [--no-index] \\",
433+
" [--with-zeros]",
433434
"",
434435
" -h/--help: print this menu",
435436
" -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit",
@@ -443,6 +444,7 @@ static void osnoise_hist_usage(char *usage)
443444
" -D/--debug: print debug info",
444445
" -t/--trace[=file]: save the stopped trace to [file|osnoise_trace.txt]",
445446
" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
447+
" --filter <filter>: enable a trace event filter to the previous -e event",
446448
" --trigger <trigger>: enable a trace event trigger to the previous -e event",
447449
" -b/--bucket-size N: set the histogram bucket size (default 1)",
448450
" -E/--entries N: set the number of entries of the histogram (default 256)",
@@ -512,13 +514,14 @@ static struct osnoise_hist_params
512514
{"no-index", no_argument, 0, '2'},
513515
{"with-zeros", no_argument, 0, '3'},
514516
{"trigger", required_argument, 0, '4'},
517+
{"filter", required_argument, 0, '5'},
515518
{0, 0, 0, 0}
516519
};
517520

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

521-
c = getopt_long(argc, argv, "a:c:b:d:e:E:Dhp:P:r:s:S:t::T:01234:",
524+
c = getopt_long(argc, argv, "a:c:b:d:e:E:Dhp:P:r:s:S:t::T:01234:5:",
522525
long_options, &option_index);
523526

524527
/* detect the end of the options. */
@@ -632,6 +635,17 @@ static struct osnoise_hist_params
632635
osnoise_hist_usage("--trigger requires a previous -e\n");
633636
}
634637
break;
638+
case '5': /* filter */
639+
if (params->events) {
640+
retval = trace_event_add_filter(params->events, optarg);
641+
if (retval) {
642+
err_msg("Error adding filter %s\n", optarg);
643+
exit(EXIT_FAILURE);
644+
}
645+
} else {
646+
osnoise_hist_usage("--filter requires a previous -e\n");
647+
}
648+
break;
635649
default:
636650
osnoise_hist_usage("Invalid option");
637651
}

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ void osnoise_top_usage(char *usage)
247247

248248
static const char * const msg[] = {
249249
" usage: rtla osnoise [top] [-h] [-q] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
250-
" [-T us] [-t[=file]] [-e sys[:event]] [--trigger <trigger>] [-c cpu-list] [-P priority]",
250+
" [-T us] [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
251+
" [-c cpu-list] [-P priority]",
251252
"",
252253
" -h/--help: print this menu",
253254
" -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit",
@@ -261,6 +262,7 @@ void osnoise_top_usage(char *usage)
261262
" -D/--debug: print debug info",
262263
" -t/--trace[=file]: save the stopped trace to [file|osnoise_trace.txt]",
263264
" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
265+
" --filter <filter>: enable a trace event filter to the previous -e event",
264266
" --trigger <trigger>: enable a trace event trigger to the previous -e event",
265267
" -q/--quiet print only a summary at the end",
266268
" -P/--priority o:prio|r:prio|f:prio|d:runtime:period : set scheduling parameters",
@@ -314,13 +316,14 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
314316
{"threshold", required_argument, 0, 'T'},
315317
{"trace", optional_argument, 0, 't'},
316318
{"trigger", required_argument, 0, '0'},
319+
{"filter", required_argument, 0, '1'},
317320
{0, 0, 0, 0}
318321
};
319322

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

323-
c = getopt_long(argc, argv, "a:c:d:De:hp:P:qr:s:S:t::T:0:",
326+
c = getopt_long(argc, argv, "a:c:d:De:hp:P:qr:s:S:t::T:0:1:",
324327
long_options, &option_index);
325328

326329
/* Detect the end of the options. */
@@ -415,6 +418,17 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
415418
osnoise_top_usage("--trigger requires a previous -e\n");
416419
}
417420
break;
421+
case '1': /* filter */
422+
if (params->events) {
423+
retval = trace_event_add_filter(params->events, optarg);
424+
if (retval) {
425+
err_msg("Error adding filter %s\n", optarg);
426+
exit(EXIT_FAILURE);
427+
}
428+
} else {
429+
osnoise_top_usage("--filter requires a previous -e\n");
430+
}
431+
break;
418432
default:
419433
osnoise_top_usage("Invalid option");
420434
}

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,9 @@ static void timerlat_hist_usage(char *usage)
430430
char *msg[] = {
431431
"",
432432
" usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-a us] [-p us] [-i us] [-T us] [-s us] \\",
433-
" [-t[=file]] [-e sys[:event]] [--trigger <trigger>] [-c cpu-list] [-P priority] [-E N] \\",
434-
" [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] [--no-index] [--with-zeros]",
433+
" [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] \\",
434+
" [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\",
435+
" [--no-index] [--with-zeros]",
435436
"",
436437
" -h/--help: print this menu",
437438
" -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit",
@@ -444,6 +445,7 @@ static void timerlat_hist_usage(char *usage)
444445
" -D/--debug: print debug info",
445446
" -t/--trace[=file]: save the stopped trace to [file|timerlat_trace.txt]",
446447
" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
448+
" --filter <filter>: enable a trace event filter to the previous -e event",
447449
" --trigger <trigger>: enable a trace event trigger to the previous -e event",
448450
" -n/--nano: display data in nanoseconds",
449451
" -b/--bucket-size N: set the histogram bucket size (default 1)",
@@ -519,13 +521,14 @@ static struct timerlat_hist_params
519521
{"no-index", no_argument, 0, '4'},
520522
{"with-zeros", no_argument, 0, '5'},
521523
{"trigger", required_argument, 0, '6'},
524+
{"filter", required_argument, 0, '7'},
522525
{0, 0, 0, 0}
523526
};
524527

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

528-
c = getopt_long(argc, argv, "a:c:b:d:e:E:Dhi:np:P:s:t::T:0123456:",
531+
c = getopt_long(argc, argv, "a:c:b:d:e:E:Dhi:np:P:s:t::T:0123456:7:",
529532
long_options, &option_index);
530533

531534
/* detect the end of the options. */
@@ -645,6 +648,17 @@ static struct timerlat_hist_params
645648
timerlat_hist_usage("--trigger requires a previous -e\n");
646649
}
647650
break;
651+
case '7': /* filter */
652+
if (params->events) {
653+
retval = trace_event_add_filter(params->events, optarg);
654+
if (retval) {
655+
err_msg("Error adding filter %s\n", optarg);
656+
exit(EXIT_FAILURE);
657+
}
658+
} else {
659+
timerlat_hist_usage("--filter requires a previous -e\n");
660+
}
661+
break;
648662
default:
649663
timerlat_hist_usage("Invalid option");
650664
}

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ static void timerlat_top_usage(char *usage)
268268
static const char *const msg[] = {
269269
"",
270270
" usage: rtla timerlat [top] [-h] [-q] [-a us] [-d s] [-D] [-n] [-p us] [-i us] [-T us] [-s us] \\",
271-
" [[-t[=file]] [-e sys[:event]] [--trigger <trigger>] [-c cpu-list] [-P priority]",
271+
" [[-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] \\",
272+
" [-P priority]",
272273
"",
273274
" -h/--help: print this menu",
274275
" -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit",
@@ -281,6 +282,7 @@ static void timerlat_top_usage(char *usage)
281282
" -D/--debug: print debug info",
282283
" -t/--trace[=file]: save the stopped trace to [file|timerlat_trace.txt]",
283284
" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
285+
" --filter <command>: enable a trace event filter to the previous -e event",
284286
" --trigger <command>: enable a trace event trigger to the previous -e event",
285287
" -n/--nano: display data in nanoseconds",
286288
" -q/--quiet print only a summary at the end",
@@ -340,13 +342,14 @@ static struct timerlat_top_params
340342
{"thread", required_argument, 0, 'T'},
341343
{"trace", optional_argument, 0, 't'},
342344
{"trigger", required_argument, 0, '0'},
345+
{"filter", required_argument, 0, '1'},
343346
{0, 0, 0, 0}
344347
};
345348

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

349-
c = getopt_long(argc, argv, "a:c:d:De:hi:np:P:qs:t::T:0:",
352+
c = getopt_long(argc, argv, "a:c:d:De:hi:np:P:qs:t::T:0:1:",
350353
long_options, &option_index);
351354

352355
/* detect the end of the options. */
@@ -440,6 +443,17 @@ static struct timerlat_top_params
440443
timerlat_top_usage("--trigger requires a previous -e\n");
441444
}
442445
break;
446+
case '1': /* filter */
447+
if (params->events) {
448+
retval = trace_event_add_filter(params->events, optarg);
449+
if (retval) {
450+
err_msg("Error adding filter %s\n", optarg);
451+
exit(EXIT_FAILURE);
452+
}
453+
} else {
454+
timerlat_top_usage("--filter requires a previous -e\n");
455+
}
456+
break;
443457
default:
444458
timerlat_top_usage("Invalid option");
445459
}

0 commit comments

Comments
 (0)