Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752649AbbGBDun (ORCPT ); Wed, 1 Jul 2015 23:50:43 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:36859 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751263AbbGBDuh (ORCPT ); Wed, 1 Jul 2015 23:50:37 -0400 Message-ID: <5594B50A.3010705@plumgrid.com> Date: Wed, 01 Jul 2015 20:50:34 -0700 From: Alexei Starovoitov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: He Kuang , rostedt@goodmis.org, masami.hiramatsu.pt@hitachi.com, mingo@redhat.com, acme@redhat.com, a.p.zijlstra@chello.nl, jolsa@kernel.org, namhyung@kernel.org CC: wangnan0@huawei.com, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 1/5] bpf: Put perf_events check ahead of bpf prog References: <1435719455-91155-1-git-send-email-hekuang@huawei.com> <1435719455-91155-2-git-send-email-hekuang@huawei.com> In-Reply-To: <1435719455-91155-2-git-send-email-hekuang@huawei.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1294 Lines: 26 On 6/30/15 7:57 PM, He Kuang wrote: > When we add a kprobe point and record events by perf, the execution path > of all threads on each cpu will enter this point, but perf may only > record events on a particular thread or cpu at this kprobe point, a > check on call->perf_events list filters out the threads which perf is > not recording. I think there is a better way to do that. You're adding artificial per_cpu filtering whereas you really need per_pid filtering. The patch kinda worked, but looks more by accident. The accurate way to do per_pid filtering is to automatically add 'if ((u32)bpf_get_current_pid_tgid() != expected_pid) return 0;' as the first statement of the program. You already have nice infra to add prologue to the program. So I think adding above 'if' on user space side of perf is a preferred way to achieve that. Also such per_pid filtering should be smart. The command 'perf record -a -e my_prog.o -- sleep 10' should collect all things that my_prog was attached to and not only things that happened as part of sleep. -- 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/