Re: [PATCH 2/2] perf script: Support dso filter

From: Jiri Olsa
Date: Wed Jan 27 2021 - 17:17:23 EST


On Mon, Jan 25, 2021 at 07:27:50AM +0800, Jin Yao wrote:
> Other perf tool builtins have already supported dso filter.
>
> For example,
> perf report --dso, which only considers symbols in these dsos.
>
> Now dso filter is supported for perf-script.
>
> root@kbl-ppc:~# ./perf script --dso "[kernel.kallsyms]"
> perf 18123 [000] 6142863.075104: 1 cycles: ffffffff9ca77308 native_write_msr+0x8 ([kernel.kallsyms])
> perf 18123 [000] 6142863.075107: 1 cycles: ffffffff9ca77308 native_write_msr+0x8 ([kernel.kallsyms])
> perf 18123 [000] 6142863.075108: 10 cycles: ffffffff9ca77308 native_write_msr+0x8 ([kernel.kallsyms])
> perf 18123 [000] 6142863.075109: 273 cycles: ffffffff9ca7730a native_write_msr+0xa ([kernel.kallsyms])
> perf 18123 [000] 6142863.075110: 7684 cycles: ffffffff9ca3c9c0 native_sched_clock+0x50 ([kernel.kallsyms])
> perf 18123 [000] 6142863.075112: 213017 cycles: ffffffff9d765a92 syscall_exit_to_user_mode+0x32 ([kernel.kallsyms])
> perf 18123 [001] 6142863.075156: 1 cycles: ffffffff9ca77308 native_write_msr+0x8 ([kernel.kallsyms])
> perf 18123 [001] 6142863.075158: 1 cycles: ffffffff9ca77308 native_write_msr+0x8 ([kernel.kallsyms])
> perf 18123 [001] 6142863.075159: 17 cycles: ffffffff9ca77308 native_write_msr+0x8 ([kernel.kallsyms])
>
> Signed-off-by: Jin Yao <yao.jin@xxxxxxxxxxxxxxx>

Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>

thanks,
jirka

> ---
> tools/perf/Documentation/perf-script.txt | 3 +++
> tools/perf/builtin-script.c | 2 ++
> 2 files changed, 5 insertions(+)
>
> diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
> index 0ef2261baeb9..6e32b2f9b828 100644
> --- a/tools/perf/Documentation/perf-script.txt
> +++ b/tools/perf/Documentation/perf-script.txt
> @@ -444,6 +444,9 @@ include::itrace.txt[]
> [0x4007a0, 0x0x4007a9]:
> perf script -S 0x4007a0 --addr-range 10
>
> +--dsos=::
> + Only consider symbols in these dsos.
> +
> --call-trace::
> Show call stream for intel_pt traces. The CPUs are interleaved, but
> can be filtered with -C.
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index e0feda33dbb9..f8d3d8582ea2 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -3523,6 +3523,8 @@ int cmd_script(int argc, const char **argv)
> parse_output_fields),
> OPT_BOOLEAN('a', "all-cpus", &system_wide,
> "system-wide collection from all CPUs"),
> + OPT_STRING(0, "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
> + "only consider symbols in these dsos"),
> OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
> "only consider these symbols"),
> OPT_INTEGER(0, "addr-range", &symbol_conf.addr_range,
> --
> 2.17.1
>