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


Groups > linux.kernel > #1198675 > unrolled thread

Re: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

Started byPeter Zijlstra <peterz@infradead.org>
First post2015-08-03 11:40 +0200
Last post2015-08-03 11:40 +0200
Articles 1 — 1 participant

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.


Contents

  Re: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to  struct perf_event Peter Zijlstra <peterz@infradead.org> - 2015-08-03 11:40 +0200

#1198675 — Re: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event

FromPeter Zijlstra <peterz@infradead.org>
Date2015-08-03 11:40 +0200
SubjectRe: [PATCH v3 1/3] bpf: Add new bpf map type to store the pointer to struct perf_event
Message-ID<pTknU-7ws-29@gated-at.bofh.it>
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@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] | [standalone]


Back to top | Article view | linux.kernel


csiph-web