Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1191434

Re: [PATCH v3 2/3] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter

Path csiph.com!aioe.org!goblin2!goblin.stu.neva.ru!gothmog.csi.it!bofh.it!news.nic.it!robomod
From xiakaixu <xiakaixu@huawei.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3 2/3] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter
Date Fri, 24 Jul 2015 04:00:02 +0200
Message-ID <pPArg-85G-13@gated-at.bofh.it> (permalink)
References <pPlix-2VS-3@gated-at.bofh.it> <pPliy-2VS-21@gated-at.bofh.it> <pPxD5-433-31@gated-at.bofh.it>
X-Original-To Alexei Starovoitov <ast@plumgrid.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
MIME-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8bit
X-Originating-IP [10.111.101.23]
X-Cfilter-Loop Reflected
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 44
Organization linux.* mail to news gateway
X-Original-Cc <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>, <pi3orama@163.com>, <hekuang@huawei.com>
X-Original-Date Fri, 24 Jul 2015 09:57:14 +0800
X-Original-Message-ID <55B19B7A.4030400@huawei.com>
X-Original-References <1437644562-84431-1-git-send-email-xiakaixu@huawei.com> <1437644562-84431-3-git-send-email-xiakaixu@huawei.com> <55B17139.2070707@plumgrid.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1191434

Show key headers only | View raw


于 2015/7/24 6:56, Alexei Starovoitov 写道:
> On 7/23/15 2:42 AM, Kaixu Xia wrote:
>> According to the perf_event_map_fd and index, the function
>> bpf_perf_event_read() can convert the corresponding map
>> value to the pointer to struct perf_event and return the
>> Hardware PMU counter value.
>>
>> Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
> ...
>> +static u64 bpf_perf_event_read(u64 r1, u64 index, u64 r3, u64 r4, u64 r5)
>> +{
>> +    struct bpf_map *map = (struct bpf_map *) (unsigned long) r1;
>> +    struct bpf_array *array = container_of(map, struct bpf_array, map);
>> +    struct perf_event *event;
>> +
>> +    if (index >= array->map.max_entries)
>> +        return -E2BIG;
>> +
>> +    event = array->events[index];
>> +    if (!event)
>> +        return -EBADF;
> 
> probably ENOENT makes more sense here.
> 
>> +
>> +    if (event->state != PERF_EVENT_STATE_ACTIVE)
>> +        return -ENOENT;
> 
> and -EINVAL here?

Yeah, the errno is better.

Thanks!
> 
> 
> .
> 


--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH v3 2/3] bpf: Implement function bpf_perf_event_read() that  get the selected hardware PMU conuter Alexei Starovoitov <ast@plumgrid.com> - 2015-07-24 01:00 +0200
  Re: [PATCH v3 2/3] bpf: Implement function bpf_perf_event_read()  that get the selected hardware PMU conuter xiakaixu <xiakaixu@huawei.com> - 2015-07-24 04:00 +0200

csiph-web