From: "Wangnan (F)" <wangnan0@huawei.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
"Liang, Kan" <kan.liang@intel.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Andi Kleen <ak@linux.intel.com>, <jacob.w.shin@gmail.com>,
<standby24x7@gmail.com>, Li Zefan <lizefan@huawei.com>,
<yunlong.song@huawei.com>, Steven Rostedt <rostedt@goodmis.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
<pi3orama@163.com>
Subject: Re: [PATCH v2] perf tools: Allow passing perf's own pid to '--filter'
Date: Tue, 7 Jul 2015 22:19:12 +0800 [thread overview]
Message-ID: <559BDFE0.7090904@huawei.com> (raw)
In-Reply-To: <CAM9d7cg3wL1iVVaOr2jGG60QXO-huvv-mV9tauU2om0nEH0sHw@mail.gmail.com>
On 2015/7/7 20:33, Namhyung Kim wrote:
> 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?
I thought this idea. Please see one of my previous email:
http://lkml.kernel.org/r/559B3CC3.2030503@huawei.com
This patch gives user full control of their filters. They can create
filters like 'common_pid == $PERFPID' to profile perf itself, or use it
in some complex expressions.
But if most of you like adding new option, I can post a v3 with
'--exclude-perf' added. Yes, the code of it can be much simpler than
this patch.
> 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>
next prev parent reply other threads:[~2015-07-07 14:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 3:38 [PATCH v2] perf tools: Allow passing perf's own pid to '--filter' Wang Nan
2015-07-07 12:33 ` Namhyung Kim
2015-07-07 13:27 ` Arnaldo Carvalho de Melo
2015-07-07 14:19 ` Wangnan (F) [this message]
2015-07-07 14:38 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=559BDFE0.7090904@huawei.com \
--to=wangnan0@huawei.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=jacob.w.shin@gmail.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=pi3orama@163.com \
--cc=rostedt@goodmis.org \
--cc=standby24x7@gmail.com \
--cc=yunlong.song@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).