From patchwork Sun Sep 18 10:20:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 76458 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp471293qgf; Sun, 18 Sep 2016 03:22:00 -0700 (PDT) X-Received: by 10.66.67.9 with SMTP id j9mr37735526pat.27.1474194120404; Sun, 18 Sep 2016 03:22:00 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si16310767pfg.297.2016.09.18.03.22.00; Sun, 18 Sep 2016 03:22:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757461AbcIRKVu (ORCPT + 27 others); Sun, 18 Sep 2016 06:21:50 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:18303 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755474AbcIRKVs (ORCPT ); Sun, 18 Sep 2016 06:21:48 -0400 Received: from 172.24.1.137 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.137]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DNG04700; Sun, 18 Sep 2016 18:20:57 +0800 (CST) Received: from [127.0.0.1] (10.111.66.109) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Sun, 18 Sep 2016 18:20:07 +0800 Subject: Re: [PATCH] perf, tools: Handle events including .c and .o To: Andi Kleen , References: <1474160566-8955-1-git-send-email-andi@firstfloor.org> CC: , , Andi Kleen , From: "Wangnan (F)" Message-ID: <57DE6A54.1000407@huawei.com> Date: Sun, 18 Sep 2016 18:20:04 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <1474160566-8955-1-git-send-email-andi@firstfloor.org> X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.57DE6A8B.0006, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: cf039023de53ae4567a7c37b05407f43 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/9/18 9:02, Andi Kleen wrote: > From: Andi Kleen > > This is a generic bug fix, but it helps with Sukadev's JSON event tree > where such events can happen. > > Any event inclduing a .c/.o/.bpf currently triggers BPF compilation or loading > and then an error. This can happen for some Intel JSON events, which cannot > be used. > > Fix the scanner to only match for .o or .c or .bpf at the end. > This will prevent loading multiple BPF scripts separated with comma, > but I assume this is acceptable. > > Cc: wangnan0@huawei.com > Cc: sukadev@linux.vnet.ibm.com > Signed-off-by: Andi Kleen I tested '.c' in middle of an event: # perf trace --event 'aaa.ccc' invalid or unsupported event: 'aaa.ccc' Run 'perf list' for a list of valid events ... It is not recongnized as a BPF source. So could you please provide an example to show how this potential bug breaks the parsing of new events? > --- > tools/perf/util/parse-events.l | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l > index 7a2519435da0..64ca26e4ed2d 100644 > --- a/tools/perf/util/parse-events.l > +++ b/tools/perf/util/parse-events.l > @@ -162,8 +162,8 @@ modifier_bp [rwx]{1,3} > } > > {event_pmu} | > -{bpf_object} | > -{bpf_source} | > +({bpf_object}$) | > +({bpf_source}$) | What about putting '$' at the definition of bpf_xxx like this? num_hex 0x[a-fA-F0-9]+ Thank you. > {event} { > BEGIN(INITIAL); > REWIND(1); Tested-by: Wang Nan diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index 9f43fda..d9ff690 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -136,8 +136,8 @@ do { \ group [^,{}/]*[{][^}]*[}][^,{}/]* event_pmu [^,{}/]+[/][^/]*[/][^,{}/]* event [^,{}/]+ -bpf_object .*\.(o|bpf) -bpf_source .*\.c +bpf_object .*\.(o|bpf)$ +bpf_source .*\.c$ num_dec [0-9]+