Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752728AbbGRBW1 (ORCPT ); Fri, 17 Jul 2015 21:22:27 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:34006 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751901AbbGRBW0 (ORCPT ); Fri, 17 Jul 2015 21:22:26 -0400 Subject: Re: [RFC PATCH 0/6] bpf: Introduce the new ability of eBPF programs to access hardware PMU counter To: pi3orama References: <1437129816-13176-1-git-send-email-xiakaixu@huawei.com> <55A98808.9010307@plumgrid.com> <55A9A0F5.10409@plumgrid.com> <940779A8-2D11-4D34-946F-17E32C9F8268@163.com> Cc: kaixu xia , "davem@davemloft.net" , "acme@kernel.org" , "mingo@redhat.com" , "a.p.zijlstra@chello.nl" , "masami.hiramatsu.pt@hitachi.com" , "jolsa@kernel.org" , "wangnan0@huawei.com" , "linux-kernel@vger.kernel.org" , "hekuang@huawei.com" From: Alexei Starovoitov Message-ID: <55A9AA4E.6040404@plumgrid.com> Date: Fri, 17 Jul 2015 18:22:22 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <940779A8-2D11-4D34-946F-17E32C9F8268@163.com> Content-Type: text/plain; charset=gbk; 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: 1210 Lines: 24 On 7/17/15 6:02 PM, pi3orama wrote: > An example: we want to count the number of cycles between entry and exit point of a particular library function (glibc write() for example). Context switch is possible, but we don't care cycles consumed by other tasks. Then we need to create a perf event in task context using: > > perf _event_open(&attr, pid, -1/* cpu */, ...); > Since it is a library function, we have to choose pids we interest. sure. just store that fd under whatever index in perf_event_array and use it from the program. index is not cpuid. it's just an index. > We should also probe sys_clone and create new perf event when thread creating, we haven't think how to do that now. opening a perf_event from the program? That will be very very hard. Much easier to kprobe sys_clone and signal to user space via bpf_output_trace_data() and user space will be perf_event_open-ing new event for new task. ps please tweak your email client to wrap lines. -- 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/