perf ftrace: Select function/function_graph tracer automatically
authorChangbin Du <changbin.du@gmail.com>
Sat, 8 Aug 2020 02:31:24 +0000 (10:31 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 14 Aug 2020 11:36:31 +0000 (08:36 -0300)
commiteb6d31ae22d7767789e3c079444157ea40114884
treeaa00def0c939d22c962ac5d385f4c9dc81a275b8
parent2db13a9b30f7e438777eb1a462c4b055ba948b89
perf ftrace: Select function/function_graph tracer automatically

The '-g/-G' options have already implied function_graph tracer should be
used instead of function tracer. So we don't need extra option
'--tracer' in this case.

This patch changes the behavior as below:

  - If '-g' or '-G' option is on, then function_graph tracer is used.
  - If '-T' or '-N' option is on, then function tracer is used.
  - The function_graph has priority over function tracer.
  - The option '--tracer' only take effect if neither -g/-G nor -T/-N
    is specified.

Here are some examples.

This will start tracing all functions using default tracer:

  $ sudo perf ftrace

This will trace all functions using function graph tracer:

  $ sudo perf ftrace -G '*'

This will trace function vfs_read using function graph tracer:

  $ sudo perf ftrace -G vfs_read

This will trace function vfs_read using function tracer:

  $ sudo perf ftrace -T vfs_read

Committer notes:

Using '-h -G' will tell what that option is about, so to further clarify
the above examples:

  # perf ftrace -h -G

    -G, --graph-funcs <func> Set graph filter on given functions

  # perf ftrace -h -g

    -g, --nograph-funcs <func> Set nograph filter on given functions

  # perf ftrace -h -T

    -T, --trace-funcs <func> trace given functions only

  # perf ftrace -h -N

    -N, --notrace-funcs <func> do not trace given functions

  #

Signed-off-by: Changbin Du <changbin.du@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
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-2-changbin.du@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-config.txt
tools/perf/Documentation/perf-ftrace.txt
tools/perf/builtin-ftrace.c