From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932847AbbJNV3D (ORCPT ); Wed, 14 Oct 2015 17:29:03 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:36263 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932606AbbJNV3A (ORCPT ); Wed, 14 Oct 2015 17:29:00 -0400 Subject: Re: [PATCH V2 2/2] bpf: control a set of perf events by creating a new ioctl PERF_EVENT_IOC_SET_ENABLER To: Kaixu Xia , davem@davemloft.net, acme@kernel.org, mingo@redhat.com, a.p.zijlstra@chello.nl, masami.hiramatsu.pt@hitachi.com, jolsa@kernel.org, daniel@iogearbox.net References: <1444826277-94060-1-git-send-email-xiakaixu@huawei.com> <1444826277-94060-3-git-send-email-xiakaixu@huawei.com> Cc: wangnan0@huawei.com, linux-kernel@vger.kernel.org, pi3orama@163.com, hekuang@huawei.com, netdev@vger.kernel.org From: Alexei Starovoitov Message-ID: <561EC917.8090001@plumgrid.com> Date: Wed, 14 Oct 2015 14:28:55 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1444826277-94060-3-git-send-email-xiakaixu@huawei.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/14/15 5:37 AM, Kaixu Xia wrote: > + event->p_sample_disable = &enabler_event->sample_disable; I don't like it as a concept and it's buggy implementation. What happens here when enabler is alive, but other event is destroyed? > --- a/kernel/trace/bpf_trace.c > +++ b/kernel/trace/bpf_trace.c > @@ -221,9 +221,12 @@ static u64 bpf_perf_event_sample_control(u64 r1, u64 index, u64 flag, u64 r4, u6 > struct bpf_array *array = container_of(map, struct bpf_array, map); > struct perf_event *event; > > - if (unlikely(index >= array->map.max_entries)) > + if (unlikely(index > array->map.max_entries)) > return -E2BIG; > > + if (index == array->map.max_entries) > + index = 0; what is this hack for ? Either use notification and user space disable or call bpf_perf_event_sample_control() manually for each cpu.