From patchwork Thu Jul 21 14:54:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 9241833 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A1E1D607D3 for ; Thu, 21 Jul 2016 14:56:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93A2C27DE0 for ; Thu, 21 Jul 2016 14:56:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87DF427EE2; Thu, 21 Jul 2016 14:56:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3585827DE0 for ; Thu, 21 Jul 2016 14:56:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bQFNN-0008NU-36; Thu, 21 Jul 2016 14:55:01 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bQFNJ-0008Iq-QN for linux-arm-kernel@lists.infradead.org; Thu, 21 Jul 2016 14:54:58 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C786811DF; Thu, 21 Jul 2016 14:54:36 +0000 (UTC) Received: from krava (dhcp-1-251.brq.redhat.com [10.34.1.251]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u6LEsY7n014550; Thu, 21 Jul 2016 10:54:34 -0400 Date: Thu, 21 Jul 2016 16:54:34 +0200 From: Jiri Olsa To: Mathieu Poirier Subject: Re: [PATCH V2 3/6] perf tools: add infrastructure for PMU specific configuration Message-ID: <20160721145434.GA15915@krava> References: <1469047100-18131-1-git-send-email-mathieu.poirier@linaro.org> <1469047100-18131-4-git-send-email-mathieu.poirier@linaro.org> <20160721074722.GB7192@krava> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.2 (2016-07-01) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 21 Jul 2016 14:54:36 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160721_075457_908448_98940BA6 X-CRM114-Status: GOOD ( 21.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , "linux-kernel@vger.kernel.org" , Arnaldo Carvalho de Melo , Alexander Shishkin , Ingo Molnar , jolsa@kernel.org, "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Jul 21, 2016 at 08:44:53AM -0600, Mathieu Poirier wrote: SNIP > >> diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l > >> index 7a2519435da0..1f7e11a6c5b3 100644 > >> --- a/tools/perf/util/parse-events.l > >> +++ b/tools/perf/util/parse-events.l > >> @@ -53,6 +53,16 @@ static int str(yyscan_t scanner, int token) > >> return token; > >> } > >> > >> +static int drv_str(yyscan_t scanner, int token) > >> +{ > >> + YYSTYPE *yylval = parse_events_get_lval(scanner); > >> + char *text = parse_events_get_text(scanner); > >> + > >> + /* Strip off the '@' */ > >> + yylval->str = strdup(text + 1); > >> + return token; > >> +} > > > > why don't let bison parse this with rule like: > > > > | '@' PE_DRV_CFG_TERM > > { > > ... > > } > > > > > > you could omit the drv_str function then > > I simply thought it was simple and clean to do it that way - and it > follows the trend already in place. Are you sure you want me to move > this to bison? Either way we have to add code... > > Many thanks for the review, > Mathieu hum, i might be missing something, but what I meant was something like below thanks, jirka diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index 1f7e11a6c5b3..9b00f9b9caa2 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -53,16 +53,6 @@ static int str(yyscan_t scanner, int token) return token; } -static int drv_str(yyscan_t scanner, int token) -{ - YYSTYPE *yylval = parse_events_get_lval(scanner); - char *text = parse_events_get_text(scanner); - - /* Strip off the '@' */ - yylval->str = strdup(text + 1); - return token; -} - #define REWIND(__alloc) \ do { \ YYSTYPE *__yylval = parse_events_get_lval(yyscanner); \ @@ -220,7 +210,7 @@ no-overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOOVERWRITE); } {name_minus} { return str(yyscanner, PE_NAME); } \[all\] { return PE_ARRAY_ALL; } "[" { BEGIN(array); return '['; } -@{drv_cfg_term} { return drv_str(yyscanner, PE_DRV_CFG_TERM); } +{drv_cfg_term} { return PE_DRV_CFG_TERM; } } { diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 879115f93edc..b7af1b834fda 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -602,12 +602,12 @@ PE_NAME array '=' PE_VALUE $$ = term; } | -PE_DRV_CFG_TERM +'@' PE_DRV_CFG_TERM { struct parse_events_term *term; ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG, - $1, $1, &@1, NULL)); + $2, $2, &@2, NULL)); $$ = term; }