Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756989AbbGGMdb (ORCPT ); Tue, 7 Jul 2015 08:33:31 -0400 Received: from mail-ig0-f171.google.com ([209.85.213.171]:33502 "EHLO mail-ig0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756672AbbGGMdW (ORCPT ); Tue, 7 Jul 2015 08:33:22 -0400 MIME-Version: 1.0 In-Reply-To: <1436240327-181705-1-git-send-email-wangnan0@huawei.com> References: <1436240327-181705-1-git-send-email-wangnan0@huawei.com> From: Namhyung Kim Date: Tue, 7 Jul 2015 21:33:02 +0900 X-Google-Sender-Auth: msp96JaX5WTKdsxfHni9cVGuaio Message-ID: Subject: Re: [PATCH v2] perf tools: Allow passing perf's own pid to '--filter' To: Wang Nan Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , 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 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1919 Lines: 62 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? 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 -- 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/