lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 7 Jul 2015 22:19:12 +0800
From:	"Wangnan (F)" <wangnan0@...wei.com>
To:	Namhyung Kim <namhyung@...nel.org>
CC:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Jiri Olsa <jolsa@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	"Liang, Kan" <kan.liang@...el.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Andi Kleen <ak@...ux.intel.com>, <jacob.w.shin@...il.com>,
	<standby24x7@...il.com>, Li Zefan <lizefan@...wei.com>,
	<yunlong.song@...wei.com>, Steven Rostedt <rostedt@...dmis.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	<pi3orama@....com>
Subject: Re: [PATCH v2] perf tools: Allow passing perf's own pid to '--filter'



On 2015/7/7 20:33, Namhyung Kim wrote:
> Hi,
>
> On Tue, Jul 7, 2015 at 12:38 PM, Wang Nan <wangnan0@...wei.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@...wei.com>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ