History

perf ftrace: Add support for trace option tracing_thresh

This adds an option '--graph-opts thresh' to setup trace duration threshold for funcgraph tracer. $ sudo ./perf ftrace -G '*' --graph-opts thresh=100 3) ! 184.060 us | } /* schedule */ 3) ! 185.600 us | } /* exit_to_usermode_loop */ 2) ! 225.989 us | } /* schedule_idle */ 2) # 4140.051 us | } /* do_idle */

Changbin Du committed 6 years ago

Commit 00c85d51 parent 59486fb2 files · +26 −1Browse files

Unified · Split

2 files
  1. tools/perf/Documentation/perf-ftrace.txt +1 −0
  2. tools/perf/builtin-ftrace.c +25 −1
tools/perf/Documentation/perf-ftrace.txt+1−0
@@ -107,6 +107,7 @@ OPTIONS · 106 unmodified lines
107 nosleep-time - Measure on-CPU time only for function_graph tracer.107 nosleep-time - Measure on-CPU time only for function_graph tracer.
108 noirqs - Ignore functions that happen inside interrupt.108 noirqs - Ignore functions that happen inside interrupt.
109 verbose - Show process names, PIDs, timestamps, etc.109 verbose - Show process names, PIDs, timestamps, etc.
110 thresh=<n> - Setup trace duration threshold in microseconds.
110 111
111SEE ALSO112SEE ALSO
112--------113--------
tools/perf/builtin-ftrace.c+25−1
@@ -48,6 +48,7 @@ struct perf_ftrace { · 47 unmodified lines
48 int graph_nosleep_time;48 int graph_nosleep_time;
49 int graph_noirqs;49 int graph_noirqs;
50 int graph_verbose;50 int graph_verbose;
51 int graph_thresh;
51};52};
52 53
53struct filter_entry {54struct filter_entry {
@@ -234,6 +235,9 @@ static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) · 180 unmodified lines
234 if (write_tracing_file("max_graph_depth", "0") < 0)235 if (write_tracing_file("max_graph_depth", "0") < 0)
235 return -1;236 return -1;
236 237
238 if (write_tracing_file("tracing_thresh", "0") < 0)
239 return -1;
240
237 reset_tracing_filters();241 reset_tracing_filters();
238 reset_tracing_options(ftrace);242 reset_tracing_options(ftrace);
239 return 0;243 return 0;
@@ -446,6 +450,20 @@ static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace) · 206 unmodified lines
446 return 0;450 return 0;
447}451}
448 452
453static int set_tracing_thresh(struct perf_ftrace *ftrace)
454{
455 int ret;
456
457 if (ftrace->graph_thresh == 0)
458 return 0;
459
460 ret = write_tracing_file_int("tracing_thresh", ftrace->graph_thresh);
461 if (ret < 0)
462 return ret;
463
464 return 0;
465}
466
449static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)467static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
450{468{
451 char *trace_file;469 char *trace_file;
@@ -545,6 +563,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) · 93 unmodified lines
545 goto out_reset;563 goto out_reset;
546 }564 }
547 565
566 if (set_tracing_thresh(ftrace) < 0) {
567 pr_err("failed to set tracing thresh\n");
568 goto out_reset;
569 }
570
548 if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {571 if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
549 pr_err("failed to set current_tracer to %s\n", ftrace->tracer);572 pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
550 goto out_reset;573 goto out_reset;
@@ -727,6 +750,7 @@ static int parse_graph_tracer_opts(const struct option *opt, · 176 unmodified lines
727 { .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time },750 { .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time },
728 { .name = "noirqs", .value_ptr = &ftrace->graph_noirqs },751 { .name = "noirqs", .value_ptr = &ftrace->graph_noirqs },
729 { .name = "verbose", .value_ptr = &ftrace->graph_verbose },752 { .name = "verbose", .value_ptr = &ftrace->graph_verbose },
753 { .name = "thresh", .value_ptr = &ftrace->graph_thresh },
730 { .name = NULL, }754 { .name = NULL, }
731 };755 };
732 756
@@ -798,7 +822,7 @@ int cmd_ftrace(int argc, const char **argv) · 65 unmodified lines
798 OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth,822 OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth,
799 "Max depth for function graph tracer"),823 "Max depth for function graph tracer"),
800 OPT_CALLBACK(0, "graph-opts", &ftrace, "options",824 OPT_CALLBACK(0, "graph-opts", &ftrace, "options",
801 "graph tracer options, available options: nosleep-time,noirqs,verbose",825 "graph tracer options, available options: nosleep-time,noirqs,verbose,thresh=<n>",
802 parse_graph_tracer_opts),826 parse_graph_tracer_opts),
803 OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size",827 OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size",
804 "size of per cpu buffer", parse_buffer_size),828 "size of per cpu buffer", parse_buffer_size),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t