Commit 00c85d5f authored by Changbin Du's avatar Changbin Du Committed by Arnaldo Carvalho de Melo

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 */
Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: http://lore.kernel.org/lkml/20200808023141.14227-14-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 59486fb0
...@@ -107,6 +107,7 @@ OPTIONS ...@@ -107,6 +107,7 @@ OPTIONS
nosleep-time - Measure on-CPU time only for function_graph tracer. nosleep-time - Measure on-CPU time only for function_graph tracer.
noirqs - Ignore functions that happen inside interrupt. noirqs - Ignore functions that happen inside interrupt.
verbose - Show process names, PIDs, timestamps, etc. verbose - Show process names, PIDs, timestamps, etc.
thresh=<n> - Setup trace duration threshold in microseconds.
SEE ALSO SEE ALSO
-------- --------
......
...@@ -48,6 +48,7 @@ struct perf_ftrace { ...@@ -48,6 +48,7 @@ struct perf_ftrace {
int graph_nosleep_time; int graph_nosleep_time;
int graph_noirqs; int graph_noirqs;
int graph_verbose; int graph_verbose;
int graph_thresh;
}; };
struct filter_entry { struct filter_entry {
...@@ -234,6 +235,9 @@ static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) ...@@ -234,6 +235,9 @@ static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
if (write_tracing_file("max_graph_depth", "0") < 0) if (write_tracing_file("max_graph_depth", "0") < 0)
return -1; return -1;
if (write_tracing_file("tracing_thresh", "0") < 0)
return -1;
reset_tracing_filters(); reset_tracing_filters();
reset_tracing_options(ftrace); reset_tracing_options(ftrace);
return 0; return 0;
...@@ -446,6 +450,20 @@ static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace) ...@@ -446,6 +450,20 @@ static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace)
return 0; return 0;
} }
static int set_tracing_thresh(struct perf_ftrace *ftrace)
{
int ret;
if (ftrace->graph_thresh == 0)
return 0;
ret = write_tracing_file_int("tracing_thresh", ftrace->graph_thresh);
if (ret < 0)
return ret;
return 0;
}
static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
{ {
char *trace_file; char *trace_file;
...@@ -545,6 +563,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) ...@@ -545,6 +563,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
goto out_reset; goto out_reset;
} }
if (set_tracing_thresh(ftrace) < 0) {
pr_err("failed to set tracing thresh\n");
goto out_reset;
}
if (write_tracing_file("current_tracer", ftrace->tracer) < 0) { if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
pr_err("failed to set current_tracer to %s\n", ftrace->tracer); pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
goto out_reset; goto out_reset;
...@@ -727,6 +750,7 @@ static int parse_graph_tracer_opts(const struct option *opt, ...@@ -727,6 +750,7 @@ static int parse_graph_tracer_opts(const struct option *opt,
{ .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time }, { .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time },
{ .name = "noirqs", .value_ptr = &ftrace->graph_noirqs }, { .name = "noirqs", .value_ptr = &ftrace->graph_noirqs },
{ .name = "verbose", .value_ptr = &ftrace->graph_verbose }, { .name = "verbose", .value_ptr = &ftrace->graph_verbose },
{ .name = "thresh", .value_ptr = &ftrace->graph_thresh },
{ .name = NULL, } { .name = NULL, }
}; };
...@@ -798,7 +822,7 @@ int cmd_ftrace(int argc, const char **argv) ...@@ -798,7 +822,7 @@ int cmd_ftrace(int argc, const char **argv)
OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth, OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth,
"Max depth for function graph tracer"), "Max depth for function graph tracer"),
OPT_CALLBACK(0, "graph-opts", &ftrace, "options", OPT_CALLBACK(0, "graph-opts", &ftrace, "options",
"graph tracer options, available options: nosleep-time,noirqs,verbose", "graph tracer options, available options: nosleep-time,noirqs,verbose,thresh=<n>",
parse_graph_tracer_opts), parse_graph_tracer_opts),
OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size", OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size",
"size of per cpu buffer", parse_buffer_size), "size of per cpu buffer", parse_buffer_size),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment