Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf expr: Add expr_scanner_ctx object

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 <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Anju T Sudhakar <anju@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
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 <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
871f9f59 aecce63e

+13 -7
+4 -2
tools/perf/util/expr.c
··· 3 3 #include <assert.h> 4 4 #include "expr.h" 5 5 #include "expr-bison.h" 6 - #define YY_EXTRA_TYPE int 7 6 #include "expr-flex.h" 8 7 9 8 #ifdef PARSER_DEBUG ··· 29 30 __expr__parse(double *val, struct expr_parse_ctx *ctx, const char *expr, 30 31 int start) 31 32 { 33 + struct expr_scanner_ctx scanner_ctx = { 34 + .start_token = start, 35 + }; 32 36 YY_BUFFER_STATE buffer; 33 37 void *scanner; 34 38 int ret; 35 39 36 - ret = expr_lex_init_extra(start, &scanner); 40 + ret = expr_lex_init_extra(&scanner_ctx, &scanner); 37 41 if (ret) 38 42 return ret; 39 43
+4
tools/perf/util/expr.h
··· 15 15 struct expr_parse_id ids[MAX_PARSE_ID]; 16 16 }; 17 17 18 + struct expr_scanner_ctx { 19 + int start_token; 20 + }; 21 + 18 22 void expr__ctx_init(struct expr_parse_ctx *ctx); 19 23 void expr__add_id(struct expr_parse_ctx *ctx, const char *id, double val); 20 24 int expr__parse(double *final_val, struct expr_parse_ctx *ctx, const char *expr);
+5 -5
tools/perf/util/expr.l
··· 76 76 symbol {spec}*{sym}*{spec}*{sym}* 77 77 78 78 %% 79 + struct expr_scanner_ctx *sctx = expr_get_extra(yyscanner); 80 + 79 81 { 80 - int start_token; 82 + int start_token = sctx->start_token; 81 83 82 - start_token = expr_get_extra(yyscanner); 83 - 84 - if (start_token) { 85 - expr_set_extra(NULL, yyscanner); 84 + if (sctx->start_token) { 85 + sctx->start_token = 0; 86 86 return start_token; 87 87 } 88 88 }