linux_dsm_epyc7002/tools/perf
Wang Nan 4ba1faa19f perf record: Allow filtering perf's pid via --exclude-perf
This patch allows 'perf record' to exclude events issued by perf itself
by '--exclude-perf' option.

Before this patch, when doing something like:

 # perf record -a -e syscalls:sys_enter_write <cmd>

One could easily get result like this:

 # /tmp/perf report --stdio
 ...
  # Overhead  Command  Shared Object       Symbol
  # ........  .......  ..................  ....................
  #
      99.99%  perf     libpthread-2.18.so  [.] __write_nocancel
      0.01%   ls       libc-2.18.so        [.] write
      0.01%   sshd     libc-2.18.so        [.] write
 ...

Where most events are generated by perf itself.

A shell trick can be done to filter perf itself out:

 # cat << EOF > ./tmp
 > #!/bin/sh
 > exec perf record -e ... --filter="common_pid != \$\$" -a sleep 10
 > EOF
 # chmod a+x ./tmp
 # ./tmp

However, doing so is user unfriendly.

This patch extracts evsel iteration framework introduced by patch 'perf
record: Apply filter to all events in a glob matching' into
foreach_evsel_in_last_glob(), and makes exclude_perf() function append
new filter expression to each evsel selected by a '-e' selector.

To avoid losing filters if user pass '--filter' after '--exclude-perf',
this patch uses perf_evsel__append_filter() in both case, instead of
perf_evsel__set_filter() which removes old filter. As a side effect, now
it is possible to use multiple '--filter' option for one selector. They
are combinded with '&&'.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1436513770-8896-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-07-20 17:49:17 -03:00
..
arch
bench
config perf trace: Support 'strace' syscall event groups 2015-07-20 15:16:32 -03:00
Documentation perf record: Allow filtering perf's pid via --exclude-perf 2015-07-20 17:49:17 -03:00
python
scripts
tests perf stat: Make stats work over the thread dimension 2015-06-26 11:20:02 -03:00
trace/strace/groups perf trace: Support 'strace' syscall event groups 2015-07-20 15:16:32 -03:00
ui
util perf record: Allow filtering perf's pid via --exclude-perf 2015-07-20 17:49:17 -03:00
.gitignore
Build perf trace: Support 'strace' syscall event groups 2015-07-20 15:16:32 -03:00
builtin-annotate.c
builtin-bench.c
builtin-buildid-cache.c perf strlist: Make dupstr be the default and part of an extensible config parm 2015-07-20 12:13:34 -03:00
builtin-buildid-list.c
builtin-data.c
builtin-diff.c
builtin-evlist.c
builtin-help.c
builtin-inject.c perf inject: Fill in the missing session freeing after an error occurs 2015-07-01 17:53:49 -03:00
builtin-kmem.c perf kmem: Fill in the missing session freeing after an error occurs 2015-07-01 17:53:49 -03:00
builtin-kvm.c perf kvm: Fill in the missing session freeing after an error occurs 2015-07-01 17:53:49 -03:00
builtin-list.c
builtin-lock.c
builtin-mem.c perf mem: Fill in the missing session freeing after an error occurs 2015-07-01 17:53:49 -03:00
builtin-probe.c perf probe: Delete an unnecessary check before the function call "strfilter__delete" 2015-07-06 08:58:36 -03:00
builtin-record.c perf record: Allow filtering perf's pid via --exclude-perf 2015-07-20 17:49:17 -03:00
builtin-report.c perf report: Fill in the missing session freeing after an error occurs 2015-07-01 17:53:49 -03:00
builtin-sched.c
builtin-script.c
builtin-stat.c perf stat: Introduce --per-thread option 2015-06-26 12:05:04 -03:00
builtin-timechart.c
builtin-top.c
builtin-trace.c perf trace: Support 'strace' syscall event groups 2015-07-20 15:16:32 -03:00
builtin.h
command-list.txt
CREDITS
design.txt
Makefile
Makefile.perf perf trace: Support 'strace' syscall event groups 2015-07-20 15:16:32 -03:00
MANIFEST tools: Copy rbtree_augmented.h from the kernel 2015-07-05 22:59:05 -03:00
perf-archive.sh
perf-completion.sh
perf-read-vdso.c
perf-sys.h
perf-with-kcore.sh
perf.c
perf.h perf record: Let user have timestamps with per-thread recording 2015-07-06 08:58:36 -03:00