All of lore.kernel.org
 help / color / mirror / Atom feed
From: xiakaixu <xiakaixu@huawei.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: <ast@plumgrid.com>, <davem@davemloft.net>, <acme@kernel.org>,
	<mingo@redhat.com>, <masami.hiramatsu.pt@hitachi.com>,
	<jolsa@kernel.org>, <wangnan0@huawei.com>,
	<linux-kernel@vger.kernel.org>, <pi3orama@163.com>,
	<hekuang@huawei.com>
Subject: Re: [PATCH v3 2/3] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter
Date: Mon, 3 Aug 2015 18:32:45 +0800	[thread overview]
Message-ID: <55BF434D.4000005@huawei.com> (raw)
In-Reply-To: <20150803093437.GE19282@twins.programming.kicks-ass.net>

于 2015/8/3 17:34, Peter Zijlstra 写道:
> On Thu, Jul 23, 2015 at 09:42:41AM +0000, Kaixu Xia wrote:
>> +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;
>> +
>> +	if (event->state != PERF_EVENT_STATE_ACTIVE)
>> +		return -ENOENT;
>> +
>> +	if (event->oncpu != raw_smp_processor_id() &&
>> +	    event->ctx->task != current)
>> +		return -EINVAL;
>> +
>> +	if (event->attr.inherit)
>> +		return -EINVAL;
>> +
>> +	__perf_event_read(event);
>> +
>> +	return perf_event_count(event);
>> +}
> 
> Please no poking of event internal state outside of perf code.

Thanks for your review. I will move it to kernel/events/core.c.
> 
> .
> 



  reply	other threads:[~2015-08-03 10:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23  9:42 [PATCH v3 0/3] bpf: Introduce the new ability of eBPF programs to access hardware PMU counter Kaixu Xia
2015-07-23  9:42 ` [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event Kaixu Xia
2015-07-23 22:54   ` Alexei Starovoitov
2015-07-24  2:22     ` xiakaixu
2015-07-24  2:26       ` Alexei Starovoitov
2015-08-03  9:38   ` Peter Zijlstra
2015-07-23  9:42 ` [PATCH v3 2/3] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter Kaixu Xia
2015-07-23 22:56   ` Alexei Starovoitov
2015-07-24  1:57     ` xiakaixu
2015-08-03  9:34   ` Peter Zijlstra
2015-08-03 10:32     ` xiakaixu [this message]
2015-07-23  9:42 ` [PATCH v3 3/3] samples/bpf: example of get selected PMU counter value Kaixu Xia
2015-07-23 22:59   ` Alexei Starovoitov
2015-07-24  1:54     ` xiakaixu
2015-07-24  2:23       ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55BF434D.4000005@huawei.com \
    --to=xiakaixu@huawei.com \
    --cc=acme@kernel.org \
    --cc=ast@plumgrid.com \
    --cc=davem@davemloft.net \
    --cc=hekuang@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pi3orama@163.com \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.