Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752812AbbHEJnJ (ORCPT ); Wed, 5 Aug 2015 05:43:09 -0400 Received: from casper.infradead.org ([85.118.1.10]:34971 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752324AbbHEJnH (ORCPT ); Wed, 5 Aug 2015 05:43:07 -0400 Date: Wed, 5 Aug 2015 11:43:05 +0200 From: Peter Zijlstra To: Kaixu Xia Cc: ast@plumgrid.com, davem@davemloft.net, acme@kernel.org, mingo@redhat.com, masami.hiramatsu.pt@hitachi.com, jolsa@kernel.org, daniel@iogearbox.net, wangnan0@huawei.com, linux-kernel@vger.kernel.org, pi3orama@163.com, hekuang@huawei.com, netdev@vger.kernel.org Subject: Re: [PATCH v6 2/4] bpf: Add new bpf map type to store the pointer to struct perf_event Message-ID: <20150805094305.GY25159@twins.programming.kicks-ass.net> References: <1438678696-88289-1-git-send-email-xiakaixu@huawei.com> <1438678696-88289-3-git-send-email-xiakaixu@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438678696-88289-3-git-send-email-xiakaixu@huawei.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 970 Lines: 33 On Tue, Aug 04, 2015 at 08:58:14AM +0000, Kaixu Xia wrote: > +static void *perf_event_fd_array_get_ptr(struct bpf_map *map, int fd) > +{ > + struct perf_event *event; > + struct perf_event_attr *attr; > + > + event = perf_event_get(fd); > + if (IS_ERR(event)) > + return event; > + > + attr = perf_event_attrs(event); > + if (IS_ERR(attr)) { perf_event_release_kernel(event); > + return attr; } And maybe I should do a tree wide: s/perf_event_release_kernel/perf_event_put/, but that's not too important and can be done at any time. > + > + if (attr->type != PERF_TYPE_RAW && > + attr->type != PERF_TYPE_HARDWARE) { > + perf_event_release_kernel(event); > + return ERR_PTR(-EINVAL); > + } > + 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/