Skip to content

Commit 0f22381

Browse files
namhyungacmel
authored andcommitted
perf ftrace: Add 'profile' command
The 'perf ftrace profile' command is to get function execution profiles using function-graph tracer so that users can see the total, average, max execution time as well as the number of invocations easily. The following is a profile for the perf_event_open syscall. $ sudo perf ftrace profile -G __x64_sys_perf_event_open -- \ perf stat -e cycles -C1 true 2> /dev/null | head # Total (us) Avg (us) Max (us) Count Function 65.611 65.611 65.611 1 __x64_sys_perf_event_open 30.527 30.527 30.527 1 anon_inode_getfile 30.260 30.260 30.260 1 __anon_inode_getfile 29.700 29.700 29.700 1 alloc_file_pseudo 17.578 17.578 17.578 1 d_alloc_pseudo 17.382 17.382 17.382 1 __d_alloc 16.738 16.738 16.738 1 kmem_cache_alloc_lru 15.686 15.686 15.686 1 perf_event_alloc 14.012 7.006 11.264 2 obj_cgroup_charge # Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Changbin Du <changbin.du@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt (VMware) <rostedt@goodmis.org> Link: https://lore.kernel.org/lkml/20240729004127.238611-4-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 608585f commit 0f22381

3 files changed

Lines changed: 359 additions & 3 deletions

File tree

tools/perf/Documentation/perf-ftrace.txt

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ perf-ftrace - simple wrapper for kernel's ftrace functionality
99
SYNOPSIS
1010
--------
1111
[verse]
12-
'perf ftrace' {trace|latency} <command>
12+
'perf ftrace' {trace|latency|profile} <command>
1313

1414
DESCRIPTION
1515
-----------
@@ -23,6 +23,9 @@ kernel's ftrace infrastructure.
2323
'perf ftrace latency' calculates execution latency of a given function
2424
(optionally with BPF) and display it as a histogram.
2525

26+
'perf ftrace profile' show a execution profile for each function including
27+
total, average, max time and the number of calls.
28+
2629
The following options apply to perf ftrace.
2730

2831
COMMON OPTIONS
@@ -146,6 +149,43 @@ OPTIONS for 'perf ftrace latency'
146149
Use nano-second instead of micro-second as a base unit of the histogram.
147150

148151

152+
OPTIONS for 'perf ftrace profile'
153+
---------------------------------
154+
155+
-T::
156+
--trace-funcs=::
157+
Set function filter on the given function (or a glob pattern).
158+
Multiple functions can be given by using this option more than once.
159+
The function argument also can be a glob pattern. It will be passed
160+
to 'set_ftrace_filter' in tracefs.
161+
162+
-N::
163+
--notrace-funcs=::
164+
Do not trace functions given by the argument. Like -T option, this
165+
can be used more than once to specify multiple functions (or glob
166+
patterns). It will be passed to 'set_ftrace_notrace' in tracefs.
167+
168+
-G::
169+
--graph-funcs=::
170+
Set graph filter on the given function (or a glob pattern). This is
171+
useful to trace for functions executed from the given function. This
172+
can be used more than once to specify multiple functions. It will be
173+
passed to 'set_graph_function' in tracefs.
174+
175+
-g::
176+
--nograph-funcs=::
177+
Set graph notrace filter on the given function (or a glob pattern).
178+
Like -G option, this is useful for the function_graph tracer only and
179+
disables tracing for function executed from the given function. This
180+
can be used more than once to specify multiple functions. It will be
181+
passed to 'set_graph_notrace' in tracefs.
182+
183+
-m::
184+
--buffer-size::
185+
Set the size of per-cpu tracing buffer, <size> is expected to
186+
be a number with appended unit character - B/K/M/G.
187+
188+
149189
SEE ALSO
150190
--------
151191
linkperf:perf-record[1], linkperf:perf-trace[1]

0 commit comments

Comments
 (0)