blob: 5b6e4b5249cffe81bf6f274df1eef119fa14c739 [file] [log] [blame]
Jiri Olsa89812fc2012-03-15 20:09:15 +01001
Zheng Yanac20de6f2012-06-15 14:31:39 +08002%option reentrant
3%option bison-bridge
Jiri Olsa89812fc2012-03-15 20:09:15 +01004%option prefix="parse_events_"
Jiri Olsa08d2f762012-05-21 09:12:52 +02005%option stack
Jiri Olsa6297d422015-04-22 21:10:17 +02006%option bison-locations
7%option yylineno
Jiri Olsab6af53b2017-11-08 16:43:09 +01008%option reject
Jiri Olsa89812fc2012-03-15 20:09:15 +01009
10%{
11#include <errno.h>
Jiri Olsa29479bf2017-10-13 10:37:35 +020012#include <sys/types.h>
13#include <sys/stat.h>
14#include <unistd.h>
Jiri Olsa8f707d82012-03-15 20:09:16 +010015#include "parse-events.h"
Wang Nane571e022016-02-22 09:10:35 +000016#include "parse-events-bison.h"
Andi Kleenf0fbb112019-03-26 15:18:21 -070017#include "evsel.h"
Jiri Olsa89812fc2012-03-15 20:09:15 +010018
Zheng Yanac20de6f2012-06-15 14:31:39 +080019char *parse_events_get_text(yyscan_t yyscanner);
20YYSTYPE *parse_events_get_lval(yyscan_t yyscanner);
21
22static int __value(YYSTYPE *yylval, char *str, int base, int token)
Jiri Olsa89812fc2012-03-15 20:09:15 +010023{
Robert Richterb527bab2012-08-07 19:43:13 +020024 u64 num;
Jiri Olsa89812fc2012-03-15 20:09:15 +010025
26 errno = 0;
Robert Richterb527bab2012-08-07 19:43:13 +020027 num = strtoull(str, NULL, base);
Jiri Olsa89812fc2012-03-15 20:09:15 +010028 if (errno)
29 return PE_ERROR;
30
Zheng Yanac20de6f2012-06-15 14:31:39 +080031 yylval->num = num;
Jiri Olsa89812fc2012-03-15 20:09:15 +010032 return token;
33}
34
Zheng Yanac20de6f2012-06-15 14:31:39 +080035static int value(yyscan_t scanner, int base)
Jiri Olsa89812fc2012-03-15 20:09:15 +010036{
Zheng Yanac20de6f2012-06-15 14:31:39 +080037 YYSTYPE *yylval = parse_events_get_lval(scanner);
38 char *text = parse_events_get_text(scanner);
39
40 return __value(yylval, text, base, PE_VALUE);
Jiri Olsa89812fc2012-03-15 20:09:15 +010041}
42
Zheng Yanac20de6f2012-06-15 14:31:39 +080043static int str(yyscan_t scanner, int token)
Jiri Olsa89812fc2012-03-15 20:09:15 +010044{
Zheng Yanac20de6f2012-06-15 14:31:39 +080045 YYSTYPE *yylval = parse_events_get_lval(scanner);
46 char *text = parse_events_get_text(scanner);
47
Alexey Budankovf92da712018-06-04 09:50:56 +030048 if (text[0] != '\'') {
49 yylval->str = strdup(text);
50 } else {
51 /*
52 * If a text tag specified on the command line
53 * contains opening single quite ' then it is
54 * expected that the tag ends with single quote
55 * as well, like this:
56 * name=\'CPU_CLK_UNHALTED.THREAD:cmask=1\'
57 * quotes need to be escaped to bypass shell
58 * processing.
59 */
60 yylval->str = strndup(&text[1], strlen(text) - 2);
61 }
62
Jiri Olsa89812fc2012-03-15 20:09:15 +010063 return token;
64}
65
Jiri Olsa4929e952020-07-26 09:52:44 +020066static int raw(yyscan_t scanner)
67{
68 YYSTYPE *yylval = parse_events_get_lval(scanner);
69 char *text = parse_events_get_text(scanner);
70
71 if (perf_pmu__parse_check(text) == PMU_EVENT_SYMBOL)
72 return str(scanner, PE_NAME);
73
74 return __value(yylval, text + 1, 16, PE_RAW);
75}
76
Jiri Olsa29479bf2017-10-13 10:37:35 +020077static bool isbpf_suffix(char *text)
Andi Kleen77d08712017-08-11 16:26:19 -070078{
Andi Kleen77d08712017-08-11 16:26:19 -070079 int len = strlen(text);
80
81 if (len < 2)
82 return false;
83 if ((text[len - 1] == 'c' || text[len - 1] == 'o') &&
84 text[len - 2] == '.')
85 return true;
86 if (len > 4 && !strcmp(text + len - 4, ".obj"))
87 return true;
88 return false;
89}
90
Jiri Olsa29479bf2017-10-13 10:37:35 +020091static bool isbpf(yyscan_t scanner)
92{
93 char *text = parse_events_get_text(scanner);
94 struct stat st;
95
96 if (!isbpf_suffix(text))
97 return false;
98
99 return stat(text, &st) == 0;
100}
101
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600102/*
103 * This function is called when the parser gets two kind of input:
104 *
105 * @cfg1 or @cfg2=config
106 *
107 * The leading '@' is stripped off before 'cfg1' and 'cfg2=config' are given to
108 * bison. In the latter case it is necessary to keep the string intact so that
109 * the PMU kernel driver can determine what configurable is associated to
110 * 'config'.
111 */
112static int drv_str(yyscan_t scanner, int token)
113{
114 YYSTYPE *yylval = parse_events_get_lval(scanner);
115 char *text = parse_events_get_text(scanner);
116
117 /* Strip off the '@' */
118 yylval->str = strdup(text + 1);
119 return token;
120}
121
Jiri Olsa6297d422015-04-22 21:10:17 +0200122#define REWIND(__alloc) \
123do { \
124 YYSTYPE *__yylval = parse_events_get_lval(yyscanner); \
125 char *text = parse_events_get_text(yyscanner); \
126 \
127 if (__alloc) \
128 __yylval->str = strdup(text); \
129 \
130 yycolumn -= strlen(text); \
131 yyless(0); \
132} while (0)
133
Jiri Olsa387ad332020-06-02 23:47:29 +0200134static int pmu_str_check(yyscan_t scanner, struct parse_events_state *parse_state)
Kan Liangba32a452014-10-07 11:08:51 -0400135{
136 YYSTYPE *yylval = parse_events_get_lval(scanner);
137 char *text = parse_events_get_text(scanner);
138
139 yylval->str = strdup(text);
Jiri Olsa387ad332020-06-02 23:47:29 +0200140
Ian Rogersec5c5b32021-10-15 10:21:27 -0700141 /*
142 * If we're not testing then parse check determines the PMU event type
143 * which if it isn't a PMU returns PE_NAME. When testing the result of
144 * parse check can't be trusted so we return PE_PMU_EVENT_FAKE unless
145 * an '!' is present in which case the text can't be a PMU name.
146 */
Kan Liangba32a452014-10-07 11:08:51 -0400147 switch (perf_pmu__parse_check(text)) {
148 case PMU_EVENT_SYMBOL_PREFIX:
149 return PE_PMU_EVENT_PRE;
150 case PMU_EVENT_SYMBOL_SUFFIX:
151 return PE_PMU_EVENT_SUF;
John Garry864bc8c2022-01-17 23:10:13 +0800152 case PMU_EVENT_SYMBOL_SUFFIX2:
153 return PE_PMU_EVENT_SUF2;
Kan Liangba32a452014-10-07 11:08:51 -0400154 case PMU_EVENT_SYMBOL:
Ian Rogersec5c5b32021-10-15 10:21:27 -0700155 return parse_state->fake_pmu
156 ? PE_PMU_EVENT_FAKE : PE_KERNEL_PMU_EVENT;
Kan Liangba32a452014-10-07 11:08:51 -0400157 default:
Ian Rogersec5c5b32021-10-15 10:21:27 -0700158 return parse_state->fake_pmu && !strchr(text,'!')
159 ? PE_PMU_EVENT_FAKE : PE_NAME;
Kan Liangba32a452014-10-07 11:08:51 -0400160 }
161}
162
Zheng Yanac20de6f2012-06-15 14:31:39 +0800163static int sym(yyscan_t scanner, int type, int config)
Jiri Olsa89812fc2012-03-15 20:09:15 +0100164{
Zheng Yanac20de6f2012-06-15 14:31:39 +0800165 YYSTYPE *yylval = parse_events_get_lval(scanner);
166
167 yylval->num = (type << 16) + config;
Jiri Olsacf3506d2012-07-04 00:00:43 +0200168 return type == PERF_TYPE_HARDWARE ? PE_VALUE_SYM_HW : PE_VALUE_SYM_SW;
Jiri Olsa89812fc2012-03-15 20:09:15 +0100169}
170
Andi Kleenf0fbb112019-03-26 15:18:21 -0700171static int tool(yyscan_t scanner, enum perf_tool_event event)
172{
173 YYSTYPE *yylval = parse_events_get_lval(scanner);
174
175 yylval->num = event;
176 return PE_VALUE_SYM_TOOL;
177}
178
Zheng Yanac20de6f2012-06-15 14:31:39 +0800179static int term(yyscan_t scanner, int type)
Jiri Olsa8f707d82012-03-15 20:09:16 +0100180{
Zheng Yanac20de6f2012-06-15 14:31:39 +0800181 YYSTYPE *yylval = parse_events_get_lval(scanner);
182
183 yylval->num = type;
Jiri Olsa8f707d82012-03-15 20:09:16 +0100184 return PE_TERM;
185}
186
Jiri Olsa6297d422015-04-22 21:10:17 +0200187#define YY_USER_ACTION \
188do { \
189 yylloc->last_column = yylloc->first_column; \
190 yylloc->first_column = yycolumn; \
191 yycolumn += yyleng; \
192} while (0);
193
Jiri Olsa94454642017-10-12 17:03:38 +0200194#define USER_REJECT \
195 yycolumn -= yyleng; \
196 REJECT
197
Jiri Olsa89812fc2012-03-15 20:09:15 +0100198%}
199
Jiri Olsa08d2f762012-05-21 09:12:52 +0200200%x mem
Robert Richterac2ba9f2012-08-16 21:10:21 +0200201%s config
202%x event
Wang Nane571e022016-02-22 09:10:35 +0000203%x array
Robert Richterac2ba9f2012-08-16 21:10:21 +0200204
205group [^,{}/]*[{][^}]*[}][^,{}/]*
206event_pmu [^,{}/]+[/][^/]*[/][^,{}/]*
207event [^,{}/]+
Andi Kleen77d08712017-08-11 16:26:19 -0700208bpf_object [^,{}]+\.(o|bpf)[a-zA-Z0-9._]*
209bpf_source [^,{}]+\.c[a-zA-Z0-9._]*
Jiri Olsa08d2f762012-05-21 09:12:52 +0200210
Jiri Olsa89812fc2012-03-15 20:09:15 +0100211num_dec [0-9]+
212num_hex 0x[a-fA-F0-9]+
213num_raw_hex [a-fA-F0-9]+
Ian Rogersec5c5b32021-10-15 10:21:27 -0700214name [a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
Alexey Budankovf92da712018-06-04 09:50:56 +0300215name_tag [\'][a-zA-Z_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=]*[\']
Wang Nana34f3be2016-02-22 09:10:31 +0000216name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600217drv_cfg_term [a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
Michael Ellermane9a7c412013-08-06 23:28:05 +1000218/* If you add a modifier you need to update check_modifier() */
Song Liu01bd8efc2021-04-25 14:43:32 -0700219modifier_event [ukhpPGHSDIWeb]+
Jiri Olsa75827322012-06-29 09:22:54 +0200220modifier_bp [rwx]{1,3}
Jiri Olsa89812fc2012-03-15 20:09:15 +0100221
222%%
Jiri Olsa90e2b222012-06-15 14:31:40 +0800223
224%{
Jiri Olsa1244a322020-05-25 00:42:08 +0200225 struct parse_events_state *_parse_state = parse_events_get_extra(yyscanner);
Jiri Olsa90e2b222012-06-15 14:31:40 +0800226
Jiri Olsa1244a322020-05-25 00:42:08 +0200227 {
228 int start_token = _parse_state->stoken;
Robert Richterac2ba9f2012-08-16 21:10:21 +0200229
230 if (start_token == PE_START_TERMS)
231 BEGIN(config);
232 else if (start_token == PE_START_EVENTS)
233 BEGIN(event);
234
Jiri Olsa90e2b222012-06-15 14:31:40 +0800235 if (start_token) {
Jiri Olsa1244a322020-05-25 00:42:08 +0200236 _parse_state->stoken = 0;
Jiri Olsa6297d422015-04-22 21:10:17 +0200237 /*
238 * The flex parser does not init locations variable
239 * via the scan_string interface, so we need do the
240 * init in here.
241 */
242 yycolumn = 0;
Jiri Olsa90e2b222012-06-15 14:31:40 +0800243 return start_token;
244 }
245 }
246%}
247
Robert Richterac2ba9f2012-08-16 21:10:21 +0200248<event>{
249
250{group} {
Jiri Olsa6297d422015-04-22 21:10:17 +0200251 BEGIN(INITIAL);
252 REWIND(0);
Robert Richterac2ba9f2012-08-16 21:10:21 +0200253 }
254
255{event_pmu} |
Wang Nan84c86ca2015-10-14 12:41:14 +0000256{bpf_object} |
Wang Nand509db02015-10-14 12:41:20 +0000257{bpf_source} |
Robert Richterac2ba9f2012-08-16 21:10:21 +0200258{event} {
Jiri Olsa6297d422015-04-22 21:10:17 +0200259 BEGIN(INITIAL);
260 REWIND(1);
Robert Richterac2ba9f2012-08-16 21:10:21 +0200261 return PE_EVENT_NAME;
262 }
263
Robert Richterac2ba9f2012-08-16 21:10:21 +0200264<<EOF>> {
Jiri Olsa6297d422015-04-22 21:10:17 +0200265 BEGIN(INITIAL);
266 REWIND(0);
Robert Richterac2ba9f2012-08-16 21:10:21 +0200267 }
Jiri Olsaae762642020-05-20 09:40:50 +0200268, {
269 return ',';
270 }
Robert Richterac2ba9f2012-08-16 21:10:21 +0200271}
272
Wang Nane571e022016-02-22 09:10:35 +0000273<array>{
274"]" { BEGIN(config); return ']'; }
275{num_dec} { return value(yyscanner, 10); }
276{num_hex} { return value(yyscanner, 16); }
277, { return ','; }
278"\.\.\." { return PE_ARRAY_RANGE; }
279}
280
Jiri Olsa82004222013-09-27 18:29:58 +0200281<config>{
Jiri Olsae64b0202015-04-22 21:10:21 +0200282 /*
Wang Nan17cb5f82016-02-19 11:43:57 +0000283 * Please update config_term_names when new static term is added.
Jiri Olsae64b0202015-04-22 21:10:21 +0200284 */
Jiri Olsa82004222013-09-27 18:29:58 +0200285config { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); }
286config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); }
287config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); }
288name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); }
289period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
Namhyung Kim09af2a52015-08-09 15:45:23 +0900290freq { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ); }
Jiri Olsa82004222013-09-27 18:29:58 +0200291branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
Kan Liang32067712015-08-04 04:30:19 -0400292time { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); }
Kan Liangd457c962015-08-11 06:30:47 -0400293call-graph { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CALLGRAPH); }
294stack-size { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_STACKSIZE); }
Arnaldo Carvalho de Melo792d48b2016-04-28 19:03:42 -0300295max-stack { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_MAX_STACK); }
Arnaldo Carvalho de Melo2fda5ad2018-10-19 15:47:34 -0300296nr { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_MAX_EVENTS); }
Wang Nan374ce932015-10-28 10:55:02 +0000297inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_INHERIT); }
298no-inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOINHERIT); }
Wang Nan626a6b72016-07-14 08:34:45 +0000299overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_OVERWRITE); }
300no-overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOOVERWRITE); }
Jin Yao064b4e82019-04-12 21:59:47 +0800301percore { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_PERCORE); }
Adrian Hunter1b992152019-08-06 11:46:05 +0300302aux-output { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT); }
Adrian Huntereb7a52d2019-11-15 14:42:17 +0200303aux-sample-size { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE); }
Ian Rogers2b62b3a2021-10-15 10:21:25 -0700304metric-id { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_METRIC_ID); }
Jiri Olsa3a6c51e2020-04-17 00:14:05 +0200305r{num_raw_hex} { return raw(yyscanner); }
Jiri Olsac33cdf52020-07-25 14:19:58 +0200306r0x{num_raw_hex} { return raw(yyscanner); }
Jiri Olsa82004222013-09-27 18:29:58 +0200307, { return ','; }
308"/" { BEGIN(INITIAL); return '/'; }
309{name_minus} { return str(yyscanner, PE_NAME); }
Wang Nane571e022016-02-22 09:10:35 +0000310\[all\] { return PE_ARRAY_ALL; }
311"[" { BEGIN(array); return '['; }
Mathieu Poirierdd60fba2016-09-06 10:37:15 -0600312@{drv_cfg_term} { return drv_str(yyscanner, PE_DRV_CFG_TERM); }
Jiri Olsa82004222013-09-27 18:29:58 +0200313}
314
315<mem>{
316{modifier_bp} { return str(yyscanner, PE_MODIFIER_BP); }
317: { return ':'; }
Jacob Shin3741eb92014-05-29 17:26:51 +0200318"/" { return '/'; }
Jiri Olsa82004222013-09-27 18:29:58 +0200319{num_dec} { return value(yyscanner, 10); }
320{num_hex} { return value(yyscanner, 16); }
321 /*
322 * We need to separate 'mem:' scanner part, in order to get specific
323 * modifier bits parsed out. Otherwise we would need to handle PE_NAME
324 * and we'd need to parse it manually. During the escape from <mem>
325 * state we need to put the escaping char back, so we dont miss it.
326 */
327. { unput(*yytext); BEGIN(INITIAL); }
328 /*
329 * We destroy the scanner after reaching EOF,
330 * but anyway just to be sure get back to INIT state.
331 */
332<<EOF>> { BEGIN(INITIAL); }
333}
334
Zheng Yanac20de6f2012-06-15 14:31:39 +0800335cpu-cycles|cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); }
336stalled-cycles-frontend|idle-cycles-frontend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); }
337stalled-cycles-backend|idle-cycles-backend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); }
338instructions { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); }
339cache-references { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES); }
340cache-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); }
341branch-instructions|branches { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); }
342branch-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); }
343bus-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); }
344ref-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES); }
345cpu-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); }
346task-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); }
347page-faults|faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); }
348minor-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN); }
349major-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ); }
350context-switches|cs { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES); }
351cpu-migrations|migrations { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS); }
352alignment-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS); }
353emulation-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS); }
Adrian Hunterd22d1a22013-08-31 21:50:52 +0300354dummy { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_DUMMY); }
Andi Kleenf0fbb112019-03-26 15:18:21 -0700355duration_time { return tool(yyscanner, PERF_TOOL_DURATION_TIME); }
Wang Nan03e0a7d2016-02-22 09:10:37 +0000356bpf-output { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_BPF_OUTPUT); }
Namhyung Kimfb6c79d2021-02-10 17:33:27 +0900357cgroup-switches { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CGROUP_SWITCHES); }
Jiri Olsa89812fc2012-03-15 20:09:15 +0100358
Kan Liangba32a452014-10-07 11:08:51 -0400359 /*
360 * We have to handle the kernel PMU event cycles-ct/cycles-t/mem-loads/mem-stores separately.
361 * Because the prefix cycles is mixed up with cpu-cycles.
362 * loads and stores are mixed up with cache event
363 */
Adrian Hunter47327f562020-03-26 10:01:47 +0200364cycles-ct |
365cycles-t |
366mem-loads |
Kan Liang2a57d402021-02-02 12:09:06 -0800367mem-loads-aux |
Adrian Hunter47327f562020-03-26 10:01:47 +0200368mem-stores |
369topdown-[a-z-]+ |
370tx-capacity-[a-z-]+ |
371el-capacity-[a-z-]+ { return str(yyscanner, PE_KERNEL_PMU_EVENT); }
Kan Liangba32a452014-10-07 11:08:51 -0400372
Jiri Olsa89812fc2012-03-15 20:09:15 +0100373L1-dcache|l1-d|l1d|L1-data |
374L1-icache|l1-i|l1i|L1-instruction |
375LLC|L2 |
376dTLB|d-tlb|Data-TLB |
377iTLB|i-tlb|Instruction-TLB |
378branch|branches|bpu|btb|bpc |
Zheng Yanac20de6f2012-06-15 14:31:39 +0800379node { return str(yyscanner, PE_NAME_CACHE_TYPE); }
Jiri Olsa89812fc2012-03-15 20:09:15 +0100380
381load|loads|read |
382store|stores|write |
383prefetch|prefetches |
384speculative-read|speculative-load |
385refs|Reference|ops|access |
Zheng Yanac20de6f2012-06-15 14:31:39 +0800386misses|miss { return str(yyscanner, PE_NAME_CACHE_OP_RESULT); }
Jiri Olsa89812fc2012-03-15 20:09:15 +0100387
Jiri Olsa08d2f762012-05-21 09:12:52 +0200388mem: { BEGIN(mem); return PE_PREFIX_MEM; }
Zheng Yanac20de6f2012-06-15 14:31:39 +0800389r{num_raw_hex} { return raw(yyscanner); }
390{num_dec} { return value(yyscanner, 10); }
391{num_hex} { return value(yyscanner, 16); }
Jiri Olsa89812fc2012-03-15 20:09:15 +0100392
Zheng Yanac20de6f2012-06-15 14:31:39 +0800393{modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); }
Jiri Olsaa271bfa2017-11-09 10:02:10 +0100394{bpf_object} { if (!isbpf(yyscanner)) { USER_REJECT }; return str(yyscanner, PE_BPF_OBJECT); }
395{bpf_source} { if (!isbpf(yyscanner)) { USER_REJECT }; return str(yyscanner, PE_BPF_SOURCE); }
Jiri Olsa387ad332020-06-02 23:47:29 +0200396{name} { return pmu_str_check(yyscanner, _parse_state); }
Alexey Budankovf92da712018-06-04 09:50:56 +0300397{name_tag} { return str(yyscanner, PE_NAME); }
Robert Richterac2ba9f2012-08-16 21:10:21 +0200398"/" { BEGIN(config); return '/'; }
Jiri Olsa89812fc2012-03-15 20:09:15 +0100399- { return '-'; }
Robert Richterac2ba9f2012-08-16 21:10:21 +0200400, { BEGIN(event); return ','; }
Jiri Olsa89812fc2012-03-15 20:09:15 +0100401: { return ':'; }
Robert Richterac2ba9f2012-08-16 21:10:21 +0200402"{" { BEGIN(event); return '{'; }
Jiri Olsa89efb022012-08-08 12:14:14 +0200403"}" { return '}'; }
Jiri Olsa89812fc2012-03-15 20:09:15 +0100404= { return '='; }
Jiri Olsa8c5f0a82012-07-04 00:00:39 +0200405\n { }
Jiri Olsa82004222013-09-27 18:29:58 +0200406. { }
Jiri Olsa08d2f762012-05-21 09:12:52 +0200407
Jiri Olsa89812fc2012-03-15 20:09:15 +0100408%%
409
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300410int parse_events_wrap(void *scanner __maybe_unused)
Jiri Olsa89812fc2012-03-15 20:09:15 +0100411{
412 return 1;
413}