Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752641AbbGRBDt (ORCPT ); Fri, 17 Jul 2015 21:03:49 -0400 Received: from m12-18.163.com ([220.181.12.18]:56476 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751890AbbGRBDs convert rfc822-to-8bit (ORCPT ); Fri, 17 Jul 2015 21:03:48 -0400 Content-Type: text/plain; charset=gb2312 Mime-Version: 1.0 (1.0) Subject: Re: [RFC PATCH 0/6] bpf: Introduce the new ability of eBPF programs to access hardware PMU counter From: pi3orama X-Mailer: iPhone Mail (12H143) In-Reply-To: <55A9A0F5.10409@plumgrid.com> Date: Sat, 18 Jul 2015 09:02:58 +0800 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" Content-Transfer-Encoding: 8BIT Message-Id: <940779A8-2D11-4D34-946F-17E32C9F8268@163.com> References: <1437129816-13176-1-git-send-email-xiakaixu@huawei.com> <55A98808.9010307@plumgrid.com> <55A9A0F5.10409@plumgrid.com> To: Alexei Starovoitov X-CM-TRANSID: EsCowEApBUjCpalVjPuLAA--.25389S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7WrWxXFy8trW7tr18Zr4UXFb_yoW8trWrpF 4ayF4akF1DtF4vvrZIgw1xXw1Fq3ykJFs8Xrn8Kr18Kws0grykCF4jkayakan8Cr1xAFW2 q3yq9347Ca4qyaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jUKsbUUUUU= X-Originating-IP: [210.73.4.168] X-CM-SenderInfo: lslt02xdpdqiywtou0bp/1tbiEwQ7QFD+VVT1TQAAs7 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2507 Lines: 50 ?????ҵ? iPhone > ?? 2015??7??18?գ?????8:42??Alexei Starovoitov д???? > >> On 7/17/15 4:27 PM, pi3orama wrote: >> Then we also need another BPF_MAP_TYPE_PERF_EVENT_HASHMAP for events in task context. > > hmm. why? don't see a use case yet. 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. We should also probe sys_clone and create new perf event when thread creating, we haven't think how to do that now. Then when inserting into map, the meaning of key should not 'cpuid'. Pid should be mush reasonable. Although we can use a auxiliary map which maps pid to array index... Thank you. > >> I choose current implementation because I think we may need perf event not wrapped in map in future (for example, tracepoints). With the design you suggested in this case we have to create a map with only 1 element in it. > > what you had also needs a map of one element. > also I don't think perf_events can be 'detached'. User space always will > perf_event_open one first and only then program will use it. > So passing FD from user space to the program is inevitable. > Other than storing FD into map the other alternative is to use ld_imm64 > mechanism. Then the helper will only have one argument, > but then you'd need to extend 'used_maps' logic with 'used_fds'. > It's doable as well, but I think the use case of only one pmu counter > per cpu is artificial. You'll always have an array of events. One for > each cpu. So perf_event_array mechanism fits the best. > >>> >btw, make sure you do your tests with lockdep and other debugs on. >>> >and for the sample code please use C for the bpf program. Not many >>> >people can read bpf asm ;) >>> > >> We still need some perf side code to make a c program work. > > no, what I meant is to do sample code as tracex[1-5]* > where there is distinct kernel and user space parts. Both in C. > At this stage perf patches are way too early. -- 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/