[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150803093437.GE19282@twins.programming.kicks-ass.net>
Date: Mon, 3 Aug 2015 11:34:37 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Kaixu Xia <xiakaixu@...wei.com>
Cc: ast@...mgrid.com, davem@...emloft.net, acme@...nel.org,
mingo@...hat.com, masami.hiramatsu.pt@...achi.com,
jolsa@...nel.org, wangnan0@...wei.com,
linux-kernel@...r.kernel.org, pi3orama@....com, hekuang@...wei.com
Subject: Re: [PATCH v3 2/3] bpf: Implement function bpf_perf_event_read()
that get the selected hardware PMU conuter
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists