G'Day Andi, On Tue, Jul 8, 2014 at 1:45 PM, Andi Kleen <a...@firstfloor.org> wrote: > David Ahern <dsah...@gmail.com> writes: > >> On 7/7/14, 12:38 PM, Brendan Gregg wrote: >>> G'Day perf users, >>> >>> Is there a way to filter perf from tracing itself? >>> >>> Here's an idle system: >>> >>> # ./perf record -e syscalls:sys_enter_read -a sleep 5 >>> [ perf record: Woken up 2 times to write data ] >>> [ perf record: Captured and wrote 0.569 MB perf.data (~24864 samples) ] >>> # ./perf record -e syscalls:sys_enter_write -a sleep 5 >>> [ perf record: Woken up 0 times to write data ] >>> [ perf record: Captured and wrote 150.381 MB perf.data (~6570251 samples) ] >>> >>> Note the disparity. perf is capturing its own writes, creating a feedback >>> loop. >> >> Not a filter, but works around the problem using mmap'ed output file: >> >> https://github.com/dsahern/linux/commit/ae2d7010256f5a5b247fb4df9f764a911a34a2f3 > > The problem is just getting the perf pid into the filter, right? > > Something like this patch should work. > > Actually it works most of the time, sometimes there are still EINVALs.
Thanks; this is neat and simple. :) So this will solve many use cases, where I'm dumping to a perf.data file and then processing later. T(he mmap() patch is also desirable, to reduce the overheads of doing the write.) But for when I'm piping perf record into perf script, I need a way to filter both perf's. If I'm desperate I can write a C program to perf_event_open() and mmap() directly, and filter the pid in the same way (gitpid()). But I think there can be some simple one liners where perf record | perf script are sufficient, provided I'm not tracing perf. Brendan -- http://www.brendangregg.com -- To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html