Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3540597ybz; Mon, 20 Apr 2020 04:59:15 -0700 (PDT) X-Google-Smtp-Source: APiQypKZK6bWvOAz7obNeL0wDrZ6LBiOYVrLEiRAuLE6JOAesoYyaWAqB/Aa+XJf8gAdNOJMjp7/ X-Received: by 2002:a50:b003:: with SMTP id i3mr13909318edd.303.1587383955053; Mon, 20 Apr 2020 04:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587383954; cv=none; d=google.com; s=arc-20160816; b=TJ2Twd52726ECinE22vLDLAO/C434PtujR0bB0slaSP62JZu6QISedV/3zbGVNvPUl UKbQM4MBAdLXGkaDpfxggJZa1DFVIdIRG5cd31vNp+1LDH0qJqX8/dH1HbtTr/UScOWW D7NGDCEZHcAG0EJ5TOsov27Je53wNQBalMXq4J7uN8bGy7DXLA8IlTnv3+AFHNo99JQk uB6DeSI6/Ad4uPtltBlO9AuII7y/zOYvhmqpzzKz7pUyvzL6hthrz56vE7aDfAiZrOBE 33qf5YQMvtEddsojpE3V4hDJJ9g2I2G3ZOLVFXpk2B1lFSBOqvibd1sMEgTFHaYMF3bh 3/aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mN/Cn6edCJSho5ukwriErdQqCH9WPUu3sFJ71WgGG60=; b=CtR+z989WBEdnqQ/2N8T37hRiC1vhXhnF5TiAyBcrFHmOFIEz7MMWg1p2IjBRg1HGE y5lnkoUvrtTWNcYNiQIcaJvlt2eZ00MEIbm0QNNyhIe90BEkHpN9Tao3yr+Ea2c52bHF c0T3k/Hn+JuHjQdHdsWnlvWJi49vtANt2JBk9KV/34R9IMLVOXwj1jNka9cJjUBz0Q0H 6u5XlQUzoy4bE0pr7K1q/PCj04an5G96yvcyub1dhC9TQ4X1llssvn4s140nFCbX7n8g MXcWo379xh7+9wRPqjZ7mEcvm6VanmjhDJ3G0e/by3qV1EunZ1xYlktm4P8ku6gkz5nx tq6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ekxw3HM6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si389572eju.478.2020.04.20.04.58.52; Mon, 20 Apr 2020 04:59:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ekxw3HM6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726907AbgDTLzW (ORCPT + 99 others); Mon, 20 Apr 2020 07:55:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:39360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbgDTLzU (ORCPT ); Mon, 20 Apr 2020 07:55:20 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0BBB620724; Mon, 20 Apr 2020 11:55:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587383719; bh=6wrPEIoM9YaePAw3gUAanS3QlSnerW821ZjtRcMHPTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ekxw3HM6NI+rDNtXQAF/vFxPPCHJVPmEJVKPgwmw+f/swuO0tmk+pjKK3/j8NTp9C 7zttxvTqoPGvj+90XhYLb24Ov3Eqgm2kCuhi+tu94npauFrBix9lHyl2bUCmCHKTZ2 ZuEb3O/f27FBc7hwzSf6q0Rs9mZIHh/ancAD9HS8= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Alexander Shishkin , Andi Kleen , Anju T Sudhakar , Benjamin Herrenschmidt , Greg Kroah-Hartman , Jin Yao , Joe Mario , Kajol Jain , Kan Liang , Madhavan Srinivasan , Mamatha Inamdar , Mark Rutland , Michael Ellerman , Michael Petlan , Paul Mackerras , Peter Zijlstra , Ravi Bangoria , Sukadev Bhattiprolu , linuxppc-dev@lists.ozlabs.org, Arnaldo Carvalho de Melo Subject: [PATCH 22/60] perf expr: Add expr_scanner_ctx object Date: Mon, 20 Apr 2020 08:52:38 -0300 Message-Id: <20200420115316.18781-23-acme@kernel.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200420115316.18781-1-acme@kernel.org> References: <20200420115316.18781-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa Add the expr_scanner_ctx object to hold user data for the expr scanner. Currently it holds only start_token, Kajol Jain will use it to hold 24x7 runtime param. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Anju T Sudhakar Cc: Benjamin Herrenschmidt Cc: Greg Kroah-Hartman Cc: Jin Yao Cc: Joe Mario Cc: Kajol Jain Cc: Kan Liang Cc: Madhavan Srinivasan Cc: Mamatha Inamdar Cc: Mark Rutland Cc: Michael Ellerman Cc: Michael Petlan Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Ravi Bangoria Cc: Sukadev Bhattiprolu Cc: Thomas Gleixner Cc: linuxppc-dev@lists.ozlabs.org Link: http://lore.kernel.org/lkml/20200401203340.31402-3-kjain@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/expr.c | 6 ++++-- tools/perf/util/expr.h | 4 ++++ tools/perf/util/expr.l | 10 +++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c index c8ccc548a585..c3382d58cf40 100644 --- a/tools/perf/util/expr.c +++ b/tools/perf/util/expr.c @@ -3,7 +3,6 @@ #include #include "expr.h" #include "expr-bison.h" -#define YY_EXTRA_TYPE int #include "expr-flex.h" #ifdef PARSER_DEBUG @@ -30,11 +29,14 @@ static int __expr__parse(double *val, struct expr_parse_ctx *ctx, const char *expr, int start) { + struct expr_scanner_ctx scanner_ctx = { + .start_token = start, + }; YY_BUFFER_STATE buffer; void *scanner; int ret; - ret = expr_lex_init_extra(start, &scanner); + ret = expr_lex_init_extra(&scanner_ctx, &scanner); if (ret) return ret; diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h index b9e53f2b5844..0938ad166ece 100644 --- a/tools/perf/util/expr.h +++ b/tools/perf/util/expr.h @@ -15,6 +15,10 @@ struct expr_parse_ctx { struct expr_parse_id ids[MAX_PARSE_ID]; }; +struct expr_scanner_ctx { + int start_token; +}; + void expr__ctx_init(struct expr_parse_ctx *ctx); void expr__add_id(struct expr_parse_ctx *ctx, const char *id, double val); int expr__parse(double *final_val, struct expr_parse_ctx *ctx, const char *expr); diff --git a/tools/perf/util/expr.l b/tools/perf/util/expr.l index eaad29243c23..2582c2464938 100644 --- a/tools/perf/util/expr.l +++ b/tools/perf/util/expr.l @@ -76,13 +76,13 @@ sym [0-9a-zA-Z_\.:@]+ symbol {spec}*{sym}*{spec}*{sym}* %% - { - int start_token; + struct expr_scanner_ctx *sctx = expr_get_extra(yyscanner); - start_token = expr_get_extra(yyscanner); + { + int start_token = sctx->start_token; - if (start_token) { - expr_set_extra(NULL, yyscanner); + if (sctx->start_token) { + sctx->start_token = 0; return start_token; } } -- 2.21.1