Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1198670 > unrolled thread
| Started by | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| First post | 2015-08-03 11:40 +0200 |
| Last post | 2015-08-03 12:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v3 2/3] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter Peter Zijlstra <peterz@infradead.org> - 2015-08-03 11:40 +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-08-03 12:40 +0200
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-08-03 11:40 +0200 |
| Subject | Re: [PATCH v3 2/3] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter |
| Message-ID | <pTknT-7ws-1@gated-at.bofh.it> |
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.
--
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/
[toc] | [next] | [standalone]
| From | xiakaixu <xiakaixu@huawei.com> |
|---|---|
| Date | 2015-08-03 12:40 +0200 |
| Message-ID | <pTljY-r2-29@gated-at.bofh.it> |
| In reply to | #1198670 |
δΊ 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.
>
> .
>
--
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/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web