Skip to content

Commit 00c85d5

Browse files
changbinduacmel
authored andcommitted
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: Changbin Du <[email protected]> Acked-by: Namhyung Kim <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt (VMware) <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 59486fb commit 00c85d5

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

tools/perf/Documentation/perf-ftrace.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ OPTIONS
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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct perf_ftrace {
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)
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)
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)
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,
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)
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),

0 commit comments

Comments
 (0)