lkml.org 
[lkml]   [2015]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] perf tools: Allow passing perf's own pid to '--filter'
Hi,

On Tue, Jul 7, 2015 at 12:38 PM, Wang Nan <wangnan0@huawei.com> wrote:
> This patch allows passing perf's own PID to '--filter' by using
> '$PERFPID'. This should be useful when system-widely capturing
> tracepoints events.
>
> Before this patch, when doing something like:
>
> # perf record -a -e syscalls:sys_enter_write <cmd>
>
> One could easily get result like this:
>
> # 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 introduces '$PERFPID' placeholder to perf's filter. Now
> user is allowed to do the above work with:
>
> # perf record -e ... --filter='common_pid != $PERFPID' -a sleep 10

Instead, what about adding an option to do the same thing, like
--exclude-perf or something?

Thanks,
Namhyung


>
> This patch adds the variable replacement code to perf_evsel__apply_filter(),
> before PERF_EVENT_IOC_SET_FILTER ioctl, so not only 'perf record', all
> subcommands which uses filter can utilize $PERFPID.
>
> Andi Kleen sent a similar patch at 2014, but wasn't applied, the
> reason is not clear.
>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>


\
 
 \ /
  Last update: 2015-07-07 14:41    [W:0.055 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site