Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757786AbbGGOiq (ORCPT ); Tue, 7 Jul 2015 10:38:46 -0400 Received: from mail.kernel.org ([198.145.29.136]:49041 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753327AbbGGOii (ORCPT ); Tue, 7 Jul 2015 10:38:38 -0400 Date: Tue, 7 Jul 2015 11:38:31 -0300 From: Arnaldo Carvalho de Melo To: "Wangnan (F)" Cc: Namhyung Kim , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Peter Zijlstra , "Liang, Kan" , Adrian Hunter , Andi Kleen , jacob.w.shin@gmail.com, standby24x7@gmail.com, Li Zefan , yunlong.song@huawei.com, Steven Rostedt , "linux-kernel@vger.kernel.org" , pi3orama@163.com Subject: Re: [PATCH v2] perf tools: Allow passing perf's own pid to '--filter' Message-ID: <20150707143831.GH3326@kernel.org> References: <1436240327-181705-1-git-send-email-wangnan0@huawei.com> <559BDFE0.7090904@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <559BDFE0.7090904@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3035 Lines: 81 Em Tue, Jul 07, 2015 at 10:19:12PM +0800, Wangnan (F) escreveu: > > > On 2015/7/7 20:33, Namhyung Kim wrote: > >Hi, > > > >On Tue, Jul 7, 2015 at 12:38 PM, Wang Nan 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 > >> > >>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. One other thing I thought is that the current way to apply --filter is per tracepoint, i.e. parse_filter() goes on being called as we go on parsing the command line and then it gets applied to the last --event parsed, so if we want to apply the same filter to all tracepoints in a more complex command line, then we must use that expression in each tracepoint, no? That provides more flexibility, as does being able to ask for some specific tracepoint to be recorded only for the perf tool itself, and for some specific tracepoint at that. So it seems that for the problem you have at hand, i.e. exclude the perf tool from all tracepoints in the command line, --exclude-perf seems more compact, but since you already wrote the other patch to support $PERF_PID, probably we should apply both? - Arnaldo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/