[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150803093801.GF19282@twins.programming.kicks-ass.net>
Date: Mon, 3 Aug 2015 11:38:01 +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 1/3] bpf: Add new bpf map type to store the pointer to
struct perf_event
On Thu, Jul 23, 2015 at 09:42:40AM +0000, Kaixu Xia wrote:
> +static struct perf_event *convert_map_with_perf_event(void *value)
> +{
> + struct perf_event *event;
> + u32 fd;
> +
> + fd = *(u32 *)value;
> +
> + event = perf_event_get(fd);
> + if (IS_ERR(event))
> + return NULL;
> +
> + /* limit the event type to PERF_TYPE_RAW
> + * and PERF_TYPE_HARDWARE.
> + */
> + if (event->attr.type != PERF_TYPE_RAW &&
> + event->attr.type != PERF_TYPE_HARDWARE)
> + return NULL;
Aside from the ref-leak already mentioned; please introduce something
like:
const struct perf_event_attr *perf_event_attrs(struct perf_event *event);
To avoid having to poke inside of the event outside of perf code.
> +
> + return event;
> +}
--
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