1 1 2 %option reentrant 2 %option reentrant 3 %option bison-bridge 3 %option bison-bridge 4 %option prefix="parse_events_" 4 %option prefix="parse_events_" 5 %option stack 5 %option stack 6 %option bison-locations 6 %option bison-locations 7 %option yylineno 7 %option yylineno 8 %option reject 8 %option reject 9 9 10 %{ 10 %{ 11 #include <errno.h> 11 #include <errno.h> 12 #include <sys/types.h> 12 #include <sys/types.h> 13 #include <sys/stat.h> 13 #include <sys/stat.h> 14 #include <unistd.h> 14 #include <unistd.h> >> 15 #include "../perf.h" 15 #include "parse-events.h" 16 #include "parse-events.h" 16 #include "parse-events-bison.h" 17 #include "parse-events-bison.h" 17 #include "evsel.h" 18 #include "evsel.h" 18 19 19 char *parse_events_get_text(yyscan_t yyscanner 20 char *parse_events_get_text(yyscan_t yyscanner); 20 YYSTYPE *parse_events_get_lval(yyscan_t yyscan 21 YYSTYPE *parse_events_get_lval(yyscan_t yyscanner); 21 int parse_events_get_column(yyscan_t yyscanner << 22 int parse_events_get_leng(yyscan_t yyscanner); << 23 22 24 static int get_column(yyscan_t scanner) !! 23 static int __value(YYSTYPE *yylval, char *str, int base, int token) 25 { 24 { 26 return parse_events_get_column(scanner << 27 } << 28 << 29 static int value(struct parse_events_state *pa << 30 { << 31 YYSTYPE *yylval = parse_events_get_lva << 32 char *text = parse_events_get_text(sca << 33 u64 num; 25 u64 num; 34 26 35 errno = 0; 27 errno = 0; 36 num = strtoull(text, NULL, base); !! 28 num = strtoull(str, NULL, base); 37 if (errno) { !! 29 if (errno) 38 struct parse_events_error *err << 39 char *help = NULL; << 40 << 41 if (asprintf(&help, "Bad base << 42 parse_events_error__ha << 43 << 44 return PE_ERROR; 30 return PE_ERROR; 45 } << 46 31 47 yylval->num = num; 32 yylval->num = num; 48 return PE_VALUE; !! 33 return token; >> 34 } >> 35 >> 36 static int value(yyscan_t scanner, int base) >> 37 { >> 38 YYSTYPE *yylval = parse_events_get_lval(scanner); >> 39 char *text = parse_events_get_text(scanner); >> 40 >> 41 return __value(yylval, text, base, PE_VALUE); 49 } 42 } 50 43 51 static int str(yyscan_t scanner, int token) 44 static int str(yyscan_t scanner, int token) 52 { 45 { 53 YYSTYPE *yylval = parse_events_get_lva 46 YYSTYPE *yylval = parse_events_get_lval(scanner); 54 char *text = parse_events_get_text(sca 47 char *text = parse_events_get_text(scanner); 55 48 56 if (text[0] != '\'') { 49 if (text[0] != '\'') { 57 yylval->str = strdup(text); 50 yylval->str = strdup(text); 58 } else { 51 } else { 59 /* 52 /* 60 * If a text tag specified on 53 * If a text tag specified on the command line 61 * contains opening single qui 54 * contains opening single quite ' then it is 62 * expected that the tag ends 55 * expected that the tag ends with single quote 63 * as well, like this: 56 * as well, like this: 64 * name=\'CPU_CLK_UNHALTED 57 * name=\'CPU_CLK_UNHALTED.THREAD:cmask=1\' 65 * quotes need to be escaped t 58 * quotes need to be escaped to bypass shell 66 * processing. 59 * processing. 67 */ 60 */ 68 yylval->str = strndup(&text[1] 61 yylval->str = strndup(&text[1], strlen(text) - 2); 69 } 62 } 70 63 71 return token; 64 return token; 72 } 65 } 73 66 74 static int lc_str(yyscan_t scanner, const stru !! 67 static int raw(yyscan_t scanner) 75 { 68 { 76 return str(scanner, state->match_legac !! 69 YYSTYPE *yylval = parse_events_get_lval(scanner); >> 70 char *text = parse_events_get_text(scanner); >> 71 >> 72 if (perf_pmu__parse_check(text) == PMU_EVENT_SYMBOL) >> 73 return str(scanner, PE_NAME); >> 74 >> 75 return __value(yylval, text + 1, 16, PE_RAW); >> 76 } >> 77 >> 78 static bool isbpf_suffix(char *text) >> 79 { >> 80 int len = strlen(text); >> 81 >> 82 if (len < 2) >> 83 return false; >> 84 if ((text[len - 1] == 'c' || text[len - 1] == 'o') && >> 85 text[len - 2] == '.') >> 86 return true; >> 87 if (len > 4 && !strcmp(text + len - 4, ".obj")) >> 88 return true; >> 89 return false; >> 90 } >> 91 >> 92 static bool isbpf(yyscan_t scanner) >> 93 { >> 94 char *text = parse_events_get_text(scanner); >> 95 struct stat st; >> 96 >> 97 if (!isbpf_suffix(text)) >> 98 return false; >> 99 >> 100 return stat(text, &st) == 0; 77 } 101 } 78 102 79 /* 103 /* 80 * This function is called when the parser get 104 * This function is called when the parser gets two kind of input: 81 * 105 * 82 * @cfg1 or @cfg2=config 106 * @cfg1 or @cfg2=config 83 * 107 * 84 * The leading '@' is stripped off before 'cfg 108 * The leading '@' is stripped off before 'cfg1' and 'cfg2=config' are given to 85 * bison. In the latter case it is necessary 109 * bison. In the latter case it is necessary to keep the string intact so that 86 * the PMU kernel driver can determine what co 110 * the PMU kernel driver can determine what configurable is associated to 87 * 'config'. 111 * 'config'. 88 */ 112 */ 89 static int drv_str(yyscan_t scanner, int token 113 static int drv_str(yyscan_t scanner, int token) 90 { 114 { 91 YYSTYPE *yylval = parse_events_get_lva 115 YYSTYPE *yylval = parse_events_get_lval(scanner); 92 char *text = parse_events_get_text(sca 116 char *text = parse_events_get_text(scanner); 93 117 94 /* Strip off the '@' */ 118 /* Strip off the '@' */ 95 yylval->str = strdup(text + 1); 119 yylval->str = strdup(text + 1); 96 return token; 120 return token; 97 } 121 } 98 122 99 /* << 100 * Use yyless to return all the characaters to << 101 * location debugging. If __alloc is non-zero << 102 * returned token's value. << 103 */ << 104 #define REWIND(__alloc) 123 #define REWIND(__alloc) \ 105 do { 124 do { \ 106 YYSTYPE *__yylval = parse_events_get_l 125 YYSTYPE *__yylval = parse_events_get_lval(yyscanner); \ 107 char *text = parse_events_get_text(yys 126 char *text = parse_events_get_text(yyscanner); \ 108 127 \ 109 if (__alloc) 128 if (__alloc) \ 110 __yylval->str = strdup(text); 129 __yylval->str = strdup(text); \ 111 130 \ 112 yycolumn -= strlen(text); 131 yycolumn -= strlen(text); \ 113 yyless(0); 132 yyless(0); \ 114 } while (0) 133 } while (0) 115 134 >> 135 static int pmu_str_check(yyscan_t scanner) >> 136 { >> 137 YYSTYPE *yylval = parse_events_get_lval(scanner); >> 138 char *text = parse_events_get_text(scanner); >> 139 >> 140 yylval->str = strdup(text); >> 141 switch (perf_pmu__parse_check(text)) { >> 142 case PMU_EVENT_SYMBOL_PREFIX: >> 143 return PE_PMU_EVENT_PRE; >> 144 case PMU_EVENT_SYMBOL_SUFFIX: >> 145 return PE_PMU_EVENT_SUF; >> 146 case PMU_EVENT_SYMBOL: >> 147 return PE_KERNEL_PMU_EVENT; >> 148 default: >> 149 return PE_NAME; >> 150 } >> 151 } >> 152 116 static int sym(yyscan_t scanner, int type, int 153 static int sym(yyscan_t scanner, int type, int config) 117 { 154 { 118 YYSTYPE *yylval = parse_events_get_lva 155 YYSTYPE *yylval = parse_events_get_lval(scanner); 119 156 120 yylval->num = (type << 16) + config; 157 yylval->num = (type << 16) + config; 121 return type == PERF_TYPE_HARDWARE ? PE 158 return type == PERF_TYPE_HARDWARE ? PE_VALUE_SYM_HW : PE_VALUE_SYM_SW; 122 } 159 } 123 160 124 static int tool(yyscan_t scanner, enum perf_to 161 static int tool(yyscan_t scanner, enum perf_tool_event event) 125 { 162 { 126 YYSTYPE *yylval = parse_events_get_lva 163 YYSTYPE *yylval = parse_events_get_lval(scanner); 127 164 128 yylval->num = event; 165 yylval->num = event; 129 return PE_VALUE_SYM_TOOL; 166 return PE_VALUE_SYM_TOOL; 130 } 167 } 131 168 132 static int term(yyscan_t scanner, enum parse_e !! 169 static int term(yyscan_t scanner, int type) 133 { 170 { 134 YYSTYPE *yylval = parse_events_get_lva 171 YYSTYPE *yylval = parse_events_get_lval(scanner); 135 172 136 yylval->term_type = type; !! 173 yylval->num = type; 137 return PE_TERM; 174 return PE_TERM; 138 } 175 } 139 176 140 static int hw_term(yyscan_t scanner, int confi << 141 { << 142 YYSTYPE *yylval = parse_events_get_lva << 143 char *text = parse_events_get_text(sca << 144 << 145 yylval->hardware_term.str = strdup(tex << 146 yylval->hardware_term.num = PERF_TYPE_ << 147 return PE_TERM_HW; << 148 } << 149 << 150 static void modifiers_error(struct parse_event << 151 int pos, char mod_ << 152 { << 153 struct parse_events_error *error = par << 154 char *help = NULL; << 155 << 156 if (asprintf(&help, "Duplicate modifie << 157 parse_events_error__handle(err << 158 } << 159 << 160 static int modifiers(struct parse_events_state << 161 { << 162 YYSTYPE *yylval = parse_events_get_lva << 163 char *text = parse_events_get_text(sca << 164 struct parse_events_modifier mod = { . << 165 << 166 for (size_t i = 0, n = strlen(text); i << 167 #define CASE(c, field) << 168 case c: << 169 if (mod.field) { << 170 modifiers_erro << 171 return PE_ERRO << 172 } << 173 mod.field = true; << 174 break << 175 << 176 switch (text[i]) { << 177 CASE('u', user); << 178 CASE('k', kernel); << 179 CASE('h', hypervisor); << 180 CASE('I', non_idle); << 181 CASE('G', guest); << 182 CASE('H', host); << 183 case 'p': << 184 mod.precise++; << 185 /* << 186 * precise ip: << 187 * << 188 * 0 - SAMPLE_IP can << 189 * 1 - SAMPLE_IP must << 190 * 2 - SAMPLE_IP requ << 191 * 3 - SAMPLE_IP must << 192 * << 193 * See also PERF_RECO << 194 */ << 195 if (mod.precise > 3) { << 196 struct parse_e << 197 char *help = s << 198 << 199 if (help) { << 200 parse_ << 201 << 202 } << 203 return PE_ERRO << 204 } << 205 break; << 206 CASE('P', precise_max); << 207 CASE('S', sample_read); << 208 CASE('D', pinned); << 209 CASE('W', weak); << 210 CASE('e', exclusive); << 211 CASE('b', bpf); << 212 CASE('R', retire_lat); << 213 default: << 214 return PE_ERROR; << 215 } << 216 #undef CASE << 217 } << 218 yylval->mod = mod; << 219 return PE_MODIFIER_EVENT; << 220 } << 221 << 222 #define YY_USER_ACTION 177 #define YY_USER_ACTION \ 223 do { 178 do { \ 224 yylloc->last_column = yylloc->first_c 179 yylloc->last_column = yylloc->first_column; \ 225 yylloc->first_column = yycolumn; 180 yylloc->first_column = yycolumn; \ 226 yycolumn += yyleng; 181 yycolumn += yyleng; \ 227 } while (0); 182 } while (0); 228 183 229 #define USER_REJECT \ 184 #define USER_REJECT \ 230 yycolumn -= yyleng; \ 185 yycolumn -= yyleng; \ 231 REJECT 186 REJECT 232 187 233 %} 188 %} 234 189 235 %x mem 190 %x mem 236 %s config 191 %s config 237 %x event 192 %x event >> 193 %x array 238 194 239 group [^,{}/]*[{][^}]*[}][^,{}/]* 195 group [^,{}/]*[{][^}]*[}][^,{}/]* 240 event_pmu [^,{}/]+[/][^/]*[/][^,{}/]* 196 event_pmu [^,{}/]+[/][^/]*[/][^,{}/]* 241 event [^,{}/]+ 197 event [^,{}/]+ >> 198 bpf_object [^,{}]+\.(o|bpf)[a-zA-Z0-9._]* >> 199 bpf_source [^,{}]+\.c[a-zA-Z0-9._]* 242 200 243 num_dec [0-9]+ 201 num_dec [0-9]+ 244 num_hex 0x[a-fA-F0-9]{1,16} !! 202 num_hex 0x[a-fA-F0-9]+ 245 num_raw_hex [a-fA-F0-9]{1,16} !! 203 num_raw_hex [a-fA-F0-9]+ 246 name [a-zA-Z0-9_*?\[\]][a-zA-Z0-9_* !! 204 name [a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]]* 247 name_tag [\'][a-zA-Z0-9_*?\[\]][a-zA-Z0 !! 205 name_tag [\'][a-zA-Z_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=]*[\'] 248 name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]* 206 name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]* 249 drv_cfg_term [a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*? 207 drv_cfg_term [a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)? 250 /* !! 208 /* If you add a modifier you need to update check_modifier() */ 251 * If you add a modifier you need to update ch !! 209 modifier_event [ukhpPGHSDIW]+ 252 * Also, the letters in modifier_event must no << 253 */ << 254 modifier_event [ukhpPGHSDIWebR]{1,16} << 255 modifier_bp [rwx]{1,3} 210 modifier_bp [rwx]{1,3} 256 lc_type (L1-dcache|l1-d|l1d|L1-data|L1 << 257 lc_op_result (load|loads|read|store|stores| << 258 digit [0-9] << 259 non_digit [^0-9] << 260 211 261 %% 212 %% 262 213 263 %{ 214 %{ 264 struct parse_events_state *_parse_stat 215 struct parse_events_state *_parse_state = parse_events_get_extra(yyscanner); >> 216 265 { 217 { 266 int start_token = _parse_state 218 int start_token = _parse_state->stoken; 267 219 268 if (start_token == PE_START_TE 220 if (start_token == PE_START_TERMS) 269 BEGIN(config); 221 BEGIN(config); 270 else if (start_token == PE_STA 222 else if (start_token == PE_START_EVENTS) 271 BEGIN(event); 223 BEGIN(event); 272 224 273 if (start_token) { 225 if (start_token) { 274 _parse_state->stoken = 226 _parse_state->stoken = 0; 275 /* 227 /* 276 * The flex parser doe 228 * The flex parser does not init locations variable 277 * via the scan_string 229 * via the scan_string interface, so we need do the 278 * init in here. 230 * init in here. 279 */ 231 */ 280 yycolumn = 0; 232 yycolumn = 0; 281 return start_token; 233 return start_token; 282 } 234 } 283 } 235 } 284 %} 236 %} 285 237 286 <event>{ 238 <event>{ 287 239 288 {group} { 240 {group} { 289 BEGIN(INITIAL); 241 BEGIN(INITIAL); 290 REWIND(0); 242 REWIND(0); 291 } 243 } 292 244 293 {event_pmu} | 245 {event_pmu} | >> 246 {bpf_object} | >> 247 {bpf_source} | 294 {event} { 248 {event} { 295 BEGIN(INITIAL); 249 BEGIN(INITIAL); 296 REWIND(1); 250 REWIND(1); 297 return PE_EVENT_NAME; 251 return PE_EVENT_NAME; 298 } 252 } 299 253 300 <<EOF>> { 254 <<EOF>> { 301 BEGIN(INITIAL); 255 BEGIN(INITIAL); 302 REWIND(0); 256 REWIND(0); 303 } 257 } 304 , { 258 , { 305 return ','; 259 return ','; 306 } 260 } 307 } 261 } 308 262 >> 263 <array>{ >> 264 "]" { BEGIN(config); return ']'; } >> 265 {num_dec} { return value(yyscanner, 10); } >> 266 {num_hex} { return value(yyscanner, 16); } >> 267 , { return ','; } >> 268 "\.\.\." { return PE_ARRAY_RANGE; } >> 269 } >> 270 309 <config>{ 271 <config>{ 310 /* 272 /* 311 * Please update config_term_names whe 273 * Please update config_term_names when new static term is added. 312 */ 274 */ 313 config { return term(yyscanne 275 config { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); } 314 config1 { return term(yyscanne 276 config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); } 315 config2 { return term(yyscanne 277 config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); } 316 config3 { return term(yyscanne << 317 name { return term(yyscanne 278 name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); } 318 period { return term(yyscanne 279 period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); } 319 freq { return term(yyscanne 280 freq { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ); } 320 branch_type { return term(yyscanne 281 branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); } 321 time { return term(yyscanne 282 time { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); } 322 call-graph { return term(yyscanne 283 call-graph { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CALLGRAPH); } 323 stack-size { return term(yyscanne 284 stack-size { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_STACKSIZE); } 324 max-stack { return term(yyscanne 285 max-stack { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_MAX_STACK); } 325 nr { return term(yyscanne 286 nr { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_MAX_EVENTS); } 326 inherit { return term(yyscanne 287 inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_INHERIT); } 327 no-inherit { return term(yyscanne 288 no-inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOINHERIT); } 328 overwrite { return term(yyscanne 289 overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_OVERWRITE); } 329 no-overwrite { return term(yyscanne 290 no-overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOOVERWRITE); } 330 percore { return term(yyscanne 291 percore { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_PERCORE); } 331 aux-output { return term(yyscanne 292 aux-output { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT); } 332 aux-sample-size { return term(yyscanne 293 aux-sample-size { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE); } 333 metric-id { return term(yyscanne !! 294 r{num_raw_hex} { return raw(yyscanner); } 334 cpu-cycles|cycles << 335 stalled-cycles-frontend|idle-cycles-frontend << 336 stalled-cycles-backend|idle-cycles-backend << 337 instructions << 338 cache-references << 339 cache-misses << 340 branch-instructions|branches << 341 branch-misses << 342 bus-cycles << 343 ref-cycles << 344 r{num_raw_hex} { return str(yyscanner << 345 r0x{num_raw_hex} { return str(yyscanner << 346 , { return ','; } 295 , { return ','; } 347 "/" { BEGIN(INITIAL); retu 296 "/" { BEGIN(INITIAL); return '/'; } 348 {lc_type} { return lc_st << 349 {lc_type}-{lc_op_result} { return lc_st << 350 {lc_type}-{lc_op_result}-{lc_op_result} { retu << 351 {name_minus} { return str(yyscanner 297 {name_minus} { return str(yyscanner, PE_NAME); } >> 298 \[all\] { return PE_ARRAY_ALL; } >> 299 "[" { BEGIN(array); return '['; } 352 @{drv_cfg_term} { return drv_str(yysca 300 @{drv_cfg_term} { return drv_str(yyscanner, PE_DRV_CFG_TERM); } 353 } 301 } 354 302 355 <mem>{ 303 <mem>{ 356 {modifier_bp} { return str(yyscanner 304 {modifier_bp} { return str(yyscanner, PE_MODIFIER_BP); } 357 /* !! 305 : { return ':'; } 358 * The colon before memory access modi !! 306 "/" { return '/'; } 359 * colon before event modifiers. Fortu !! 307 {num_dec} { return value(yyscanner, 10); } 360 * are the same, so trailing context c !! 308 {num_hex} { return value(yyscanner, 16); } 361 * cases. << 362 */ << 363 ":"/{modifier_bp} { return PE_BP_COLON; << 364 /* << 365 * The slash before memory length can << 366 * config terms. Fortunately config te << 367 * digit, so trailing context can be u << 368 */ << 369 "/"/{digit} { return PE_BP_SLASH; << 370 "/"/{non_digit} { BEGIN(config); retur << 371 {num_dec} { return value(_parse_ << 372 {num_hex} { return value(_parse_ << 373 /* 309 /* 374 * We need to separate 'mem:' scanner 310 * We need to separate 'mem:' scanner part, in order to get specific 375 * modifier bits parsed out. Otherwise 311 * modifier bits parsed out. Otherwise we would need to handle PE_NAME 376 * and we'd need to parse it manually. 312 * and we'd need to parse it manually. During the escape from <mem> 377 * state we need to put the escaping c 313 * state we need to put the escaping char back, so we dont miss it. 378 */ 314 */ 379 . { unput(*yytext); BEGI 315 . { unput(*yytext); BEGIN(INITIAL); } 380 /* 316 /* 381 * We destroy the scanner after reachi 317 * We destroy the scanner after reaching EOF, 382 * but anyway just to be sure get back 318 * but anyway just to be sure get back to INIT state. 383 */ 319 */ 384 <<EOF>> { BEGIN(INITIAL); } 320 <<EOF>> { BEGIN(INITIAL); } 385 } 321 } 386 322 387 cpu-cycles|cycles 323 cpu-cycles|cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); } 388 stalled-cycles-frontend|idle-cycles-frontend 324 stalled-cycles-frontend|idle-cycles-frontend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); } 389 stalled-cycles-backend|idle-cycles-backend 325 stalled-cycles-backend|idle-cycles-backend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); } 390 instructions 326 instructions { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); } 391 cache-references 327 cache-references { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES); } 392 cache-misses 328 cache-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); } 393 branch-instructions|branches 329 branch-instructions|branches { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); } 394 branch-misses 330 branch-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); } 395 bus-cycles 331 bus-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); } 396 ref-cycles 332 ref-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES); } 397 cpu-clock 333 cpu-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); } 398 task-clock 334 task-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); } 399 page-faults|faults 335 page-faults|faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); } 400 minor-faults 336 minor-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN); } 401 major-faults 337 major-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ); } 402 context-switches|cs 338 context-switches|cs { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES); } 403 cpu-migrations|migrations 339 cpu-migrations|migrations { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS); } 404 alignment-faults 340 alignment-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS); } 405 emulation-faults 341 emulation-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS); } 406 dummy 342 dummy { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_DUMMY); } 407 duration_time 343 duration_time { return tool(yyscanner, PERF_TOOL_DURATION_TIME); } 408 user_time << 409 system_time << 410 bpf-output 344 bpf-output { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_BPF_OUTPUT); } 411 cgroup-switches << 412 345 413 {lc_type} { return str(y !! 346 /* 414 {lc_type}-{lc_op_result} { return str(y !! 347 * We have to handle the kernel PMU event cycles-ct/cycles-t/mem-loads/mem-stores separately. 415 {lc_type}-{lc_op_result}-{lc_op_result} { retu !! 348 * Because the prefix cycles is mixed up with cpu-cycles. 416 mem: { BEGIN(mem); return P !! 349 * loads and stores are mixed up with cache event 417 r{num_raw_hex} { return str(yyscanner !! 350 */ 418 {num_dec} { return value(_parse_ !! 351 cycles-ct | 419 {num_hex} { return value(_parse_ !! 352 cycles-t | >> 353 mem-loads | >> 354 mem-stores | >> 355 topdown-[a-z-]+ | >> 356 tx-capacity-[a-z-]+ | >> 357 el-capacity-[a-z-]+ { return str(yyscanner, PE_KERNEL_PMU_EVENT); } >> 358 >> 359 L1-dcache|l1-d|l1d|L1-data | >> 360 L1-icache|l1-i|l1i|L1-instruction | >> 361 LLC|L2 | >> 362 dTLB|d-tlb|Data-TLB | >> 363 iTLB|i-tlb|Instruction-TLB | >> 364 branch|branches|bpu|btb|bpc | >> 365 node { return str(yyscanner, PE_NAME_CACHE_TYPE); } >> 366 >> 367 load|loads|read | >> 368 store|stores|write | >> 369 prefetch|prefetches | >> 370 speculative-read|speculative-load | >> 371 refs|Reference|ops|access | >> 372 misses|miss { return str(yyscanner, PE_NAME_CACHE_OP_RESULT); } 420 373 421 {modifier_event} { return modifiers(_pa !! 374 mem: { BEGIN(mem); return PE_PREFIX_MEM; } 422 {name} { return str(yyscanner !! 375 r{num_raw_hex} { return raw(yyscanner); } >> 376 {num_dec} { return value(yyscanner, 10); } >> 377 {num_hex} { return value(yyscanner, 16); } >> 378 >> 379 {modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); } >> 380 {bpf_object} { if (!isbpf(yyscanner)) { USER_REJECT }; return str(yyscanner, PE_BPF_OBJECT); } >> 381 {bpf_source} { if (!isbpf(yyscanner)) { USER_REJECT }; return str(yyscanner, PE_BPF_SOURCE); } >> 382 {name} { return pmu_str_check(yyscanner); } 423 {name_tag} { return str(yyscanner 383 {name_tag} { return str(yyscanner, PE_NAME); } 424 "/" { BEGIN(config); retur 384 "/" { BEGIN(config); return '/'; } >> 385 - { return '-'; } 425 , { BEGIN(event); return 386 , { BEGIN(event); return ','; } 426 : { return ':'; } 387 : { return ':'; } 427 "{" { BEGIN(event); return 388 "{" { BEGIN(event); return '{'; } 428 "}" { return '}'; } 389 "}" { return '}'; } 429 = { return '='; } 390 = { return '='; } 430 \n { } 391 \n { } 431 . { } 392 . { } 432 393 433 %% 394 %% 434 395 435 int parse_events_wrap(void *scanner __maybe_un 396 int parse_events_wrap(void *scanner __maybe_unused) 436 { 397 { 437 return 1; 398 return 1; 438 } 399 }
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.