Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752939AbbHCKfK (ORCPT ); Mon, 3 Aug 2015 06:35:10 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:24367 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752427AbbHCKfI (ORCPT ); Mon, 3 Aug 2015 06:35:08 -0400 Message-ID: <55BF434D.4000005@huawei.com> Date: Mon, 3 Aug 2015 18:32:45 +0800 From: xiakaixu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Peter Zijlstra CC: , , , , , , , , , Subject: Re: [PATCH v3 2/3] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter References: <1437644562-84431-1-git-send-email-xiakaixu@huawei.com> <1437644562-84431-3-git-send-email-xiakaixu@huawei.com> <20150803093437.GE19282@twins.programming.kicks-ass.net> In-Reply-To: <20150803093437.GE19282@twins.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.111.101.23] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.55BF4362.0018,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f52d9da79c0205061469ac661c50686e Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1228 Lines: 43 于 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/