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
107107 nosleep-time - Measure on-CPU time only for function_graph tracer.
108108 noirqs - Ignore functions that happen inside interrupt.
109109 verbose - Show process names, PIDs, timestamps, etc.
110+ thresh=<n> - Setup trace duration threshold in microseconds.
110111
111112 SEE ALSO
112113 --------
tools/perf/builtin-ftrace.c+25−1
@@ -48,6 +48,7 @@ struct perf_ftrace { · 47 unmodified lines
4848 int graph_nosleep_time;
4949 int graph_noirqs;
5050 int graph_verbose;
51+ int graph_thresh;
5152 };
5253
5354 struct filter_entry {
@@ -234,6 +235,9 @@ static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) · 180 unmodified lines
234235 if (write_tracing_file("max_graph_depth", "0") < 0)
235236 return -1;
236237
238+ if (write_tracing_file("tracing_thresh", "0") < 0)
239+ return -1;
240+
237241 reset_tracing_filters();
238242 reset_tracing_options(ftrace);
239243 return 0;
@@ -446,6 +450,20 @@ static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace) · 206 unmodified lines
446450 return 0;
447451 }
448452
453+static 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+
449467 static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
450468 {
451469 char *trace_file;
@@ -545,6 +563,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) · 93 unmodified lines
545563 goto out_reset;
546564 }
547565
566+ if (set_tracing_thresh(ftrace) < 0) {
567+ pr_err("failed to set tracing thresh\n");
568+ goto out_reset;
569+ }
570+
548571 if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
549572 pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
550573 goto out_reset;
@@ -727,6 +750,7 @@ static int parse_graph_tracer_opts(const struct option *opt, · 176 unmodified lines
727750 { .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time },
728751 { .name = "noirqs", .value_ptr = &ftrace->graph_noirqs },
729752 { .name = "verbose", .value_ptr = &ftrace->graph_verbose },
753+ { .name = "thresh", .value_ptr = &ftrace->graph_thresh },
730754 { .name = NULL, }
731755 };
732756
@@ -798,7 +822,7 @@ int cmd_ftrace(int argc, const char **argv) · 65 unmodified lines
798822 OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth,
799823 "Max depth for function graph tracer"),
800824 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>",
802826 parse_graph_tracer_opts),
803827 OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size",
804828 "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