Re: [PATCH] perf, tools: Add PERF_PID
From: Brendan Gregg
Date: Tue Sep 09 2014 - 21:08:45 EST
On Tue, Sep 9, 2014 at 5:03 PM, Andi Kleen <andi@xxxxxxxxxxxxxx> wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> It's currently difficult to filter out perf itself using a filter.
> This can give cascading effects during IO tracing when the IO
> perf does itself causes more trace output.
>
> The best way to filter is to use the pid. But it's difficult to get the pid
> of perf without using hacks.
>
> Add a PERF_PID meta variable to the perf filter that contains the current pid.
>
> With this patch the following works
>
> % perf record -e syscalls:sys_enter_write -a --filter 'common_pid != PERF_PID' ...
>
> This won't work for more complex perf pipe lines with multiple processes,
> but at least solves the problem nicely for a single perf.
Thank you, this will be handy. I tested it and it works.
It will mean I can avoid hacks like this:
https://github.com/brendangregg/perf-tools/blob/d30e8a1a9f136d532ba78c6d48aedb99dc316be9/syscount#L144
I think it's unrelated to this patch, but the very next test I tried
didn't work as expected:
# perf record -e 'syscalls:sys_enter_*' --filter 'common_pid !=
PERF_PID' -a sleep 5
It only filters the last event from the wildcard expansion, leaving
write() unfiltered. Looks like it's because parse_filter() is only
setting the filter for perf_evlist__last(), instead of doing an
evlist__for_each(). How best to deal with this can be addressed in a
separate patch later.
Brendan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/