aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-03-15 15:09:18 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-03-16 13:30:13 -0400
commit5f537a26590e696466aae7f41e6b77e92c8486d1 (patch)
tree6946ba5b2a4cc1133ab11d8a81c37465f794e655 /tools/perf
parentcd82a32e9924d3a82bd27f830755d23e4ded25bc (diff)
perf tools: Add support to specify pmu style event
Added new event rule to the event definition grammar: event_def: event_pmu | ... event_pmu: PE_NAME '/' event_config '/' Using this rule, event could be now specified like: cpu/config=1,config1=2,config2=3/u where pmu name 'cpu' is looked up via following path: ${sysfs_mount}/bus/event_source/devices/${pmu} and config options are bound to the pmu's format definiton: ${sysfs_mount}/bus/event_source/devices/${pmu}/format The hardcoded config options still stays and have precedence over any format field defined with same name. Acked-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-50d8nr94f8k4wkezutrxvthe@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-test.c20
-rw-r--r--tools/perf/util/parse-events-bison.c209
-rw-r--r--tools/perf/util/parse-events.c31
-rw-r--r--tools/perf/util/parse-events.h2
-rw-r--r--tools/perf/util/parse-events.y10
5 files changed, 172 insertions, 100 deletions
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 58bfe8bde5ee..86874238a350 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -877,6 +877,22 @@ static int test__checkevent_genhw_modifier(struct perf_evlist *evlist)
877 return test__checkevent_genhw(evlist); 877 return test__checkevent_genhw(evlist);
878} 878}
879 879
880static int test__checkevent_pmu(struct perf_evlist *evlist)
881{
882
883 struct perf_evsel *evsel = list_entry(evlist->entries.next,
884 struct perf_evsel, node);
885
886 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
887 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
888 TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config);
889 TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1);
890 TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2);
891 TEST_ASSERT_VAL("wrong period", 1000 == evsel->attr.sample_period);
892
893 return 0;
894}
895
880static struct test__event_st { 896static struct test__event_st {
881 const char *name; 897 const char *name;
882 __u32 type; 898 __u32 type;
@@ -958,6 +974,10 @@ static struct test__event_st {
958 .name = "L1-dcache-load-miss:kp", 974 .name = "L1-dcache-load-miss:kp",
959 .check = test__checkevent_genhw_modifier, 975 .check = test__checkevent_genhw_modifier,
960 }, 976 },
977 {
978 .name = "cpu/config=10,config1,config2=3,period=1000/u",
979 .check = test__checkevent_pmu,
980 },
961}; 981};
962 982
963#define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st)) 983#define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st))
diff --git a/tools/perf/util/parse-events-bison.c b/tools/perf/util/parse-events-bison.c
index ace593a25182..4a0fd6d5cebf 100644
--- a/tools/perf/util/parse-events-bison.c
+++ b/tools/perf/util/parse-events-bison.c
@@ -381,18 +381,18 @@ union yyalloc
381#endif 381#endif
382 382
383/* YYFINAL -- State number of the termination state. */ 383/* YYFINAL -- State number of the termination state. */
384#define YYFINAL 23 384#define YYFINAL 25
385/* YYLAST -- Last index in YYTABLE. */ 385/* YYLAST -- Last index in YYTABLE. */
386#define YYLAST 38 386#define YYLAST 43
387 387
388/* YYNTOKENS -- Number of terminals. */ 388/* YYNTOKENS -- Number of terminals. */
389#define YYNTOKENS 20 389#define YYNTOKENS 20
390/* YYNNTS -- Number of nonterminals. */ 390/* YYNNTS -- Number of nonterminals. */
391#define YYNNTS 14 391#define YYNNTS 15
392/* YYNRULES -- Number of rules. */ 392/* YYNRULES -- Number of rules. */
393#define YYNRULES 33 393#define YYNRULES 35
394/* YYNRULES -- Number of states. */ 394/* YYNRULES -- Number of states. */
395#define YYNSTATES 53 395#define YYNSTATES 57
396 396
397/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 397/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
398#define YYUNDEFTOK 2 398#define YYUNDEFTOK 2
@@ -438,34 +438,35 @@ static const yytype_uint8 yytranslate[] =
438 YYRHS. */ 438 YYRHS. */
439static const yytype_uint8 yyprhs[] = 439static const yytype_uint8 yyprhs[] =
440{ 440{
441 0, 0, 3, 7, 9, 12, 14, 16, 19, 21, 441 0, 0, 3, 7, 9, 12, 14, 16, 18, 21,
442 24, 27, 30, 35, 38, 44, 48, 50, 56, 60, 442 23, 26, 29, 32, 37, 42, 45, 51, 55, 57,
443 64, 68, 70, 74, 76, 80, 84, 86, 90, 92, 443 63, 67, 71, 75, 77, 81, 83, 87, 91, 93,
444 94, 95, 97, 99 444 97, 99, 101, 102, 104, 106
445}; 445};
446 446
447/* YYRHS -- A `-1'-separated list of the rules' RHS. */ 447/* YYRHS -- A `-1'-separated list of the rules' RHS. */
448static const yytype_int8 yyrhs[] = 448static const yytype_int8 yyrhs[] =
449{ 449{
450 21, 0, -1, 21, 15, 22, -1, 22, -1, 23, 450 21, 0, -1, 21, 15, 22, -1, 22, -1, 23,
451 8, -1, 23, -1, 24, -1, 25, 32, -1, 26, 451 8, -1, 23, -1, 24, -1, 25, -1, 26, 33,
452 -1, 27, 32, -1, 28, 32, -1, 29, 32, -1, 452 -1, 27, -1, 28, 33, -1, 29, 33, -1, 30,
453 4, 16, 30, 16, -1, 4, 33, -1, 10, 17, 453 33, -1, 7, 16, 31, 16, -1, 4, 16, 31,
454 11, 17, 11, -1, 10, 17, 11, -1, 10, -1, 454 16, -1, 4, 34, -1, 10, 17, 11, 17, 11,
455 12, 3, 18, 9, 32, -1, 12, 3, 32, -1, 455 -1, 10, 17, 11, -1, 10, -1, 12, 3, 18,
456 7, 18, 7, -1, 3, 18, 3, -1, 5, -1, 456 9, 33, -1, 12, 3, 33, -1, 7, 18, 7,
457 30, 15, 31, -1, 31, -1, 7, 19, 7, -1, 457 -1, 3, 18, 3, -1, 5, -1, 31, 15, 32,
458 7, 19, 3, -1, 7, -1, 6, 19, 3, -1, 458 -1, 32, -1, 7, 19, 7, -1, 7, 19, 3,
459 6, -1, 18, -1, -1, 16, -1, 18, -1, -1 459 -1, 7, -1, 6, 19, 3, -1, 6, -1, 18,
460 -1, -1, 16, -1, 18, -1, -1
460}; 461};
461 462
462/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 463/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
463static const yytype_uint8 yyrline[] = 464static const yytype_uint8 yyrline[] =
464{ 465{
465 0, 54, 54, 54, 57, 62, 64, 65, 66, 67, 466 0, 54, 54, 54, 57, 62, 64, 65, 66, 67,
466 68, 69, 72, 81, 90, 95, 100, 106, 111, 117, 467 68, 69, 70, 73, 80, 89, 98, 103, 108, 114,
467 123, 129, 135, 145, 157, 166, 175, 184, 192, 200, 468 119, 125, 131, 137, 143, 153, 165, 174, 183, 192,
468 200, 202, 202, 202 469 200, 208, 208, 210, 210, 210
469}; 470};
470#endif 471#endif
471 472
@@ -478,10 +479,10 @@ static const char *const yytname[] =
478 "PE_TERM", "PE_NAME", "PE_MODIFIER_EVENT", "PE_MODIFIER_BP", 479 "PE_TERM", "PE_NAME", "PE_MODIFIER_EVENT", "PE_MODIFIER_BP",
479 "PE_NAME_CACHE_TYPE", "PE_NAME_CACHE_OP_RESULT", "PE_PREFIX_MEM", 480 "PE_NAME_CACHE_TYPE", "PE_NAME_CACHE_OP_RESULT", "PE_PREFIX_MEM",
480 "PE_PREFIX_RAW", "PE_ERROR", "','", "'/'", "'-'", "':'", "'='", 481 "PE_PREFIX_RAW", "PE_ERROR", "','", "'/'", "'-'", "':'", "'='",
481 "$accept", "events", "event", "event_def", "event_legacy_symbol", 482 "$accept", "events", "event", "event_def", "event_pmu",
482 "event_legacy_cache", "event_legacy_mem", "event_legacy_tracepoint", 483 "event_legacy_symbol", "event_legacy_cache", "event_legacy_mem",
483 "event_legacy_numeric", "event_legacy_raw", "event_config", "event_term", 484 "event_legacy_tracepoint", "event_legacy_numeric", "event_legacy_raw",
484 "sep_dc", "sep_slash_dc", 0 485 "event_config", "event_term", "sep_dc", "sep_slash_dc", 0
485}; 486};
486#endif 487#endif
487 488
@@ -499,18 +500,18 @@ static const yytype_uint16 yytoknum[] =
499static const yytype_uint8 yyr1[] = 500static const yytype_uint8 yyr1[] =
500{ 501{
501 0, 20, 21, 21, 22, 22, 23, 23, 23, 23, 502 0, 20, 21, 21, 22, 22, 23, 23, 23, 23,
502 23, 23, 24, 24, 25, 25, 25, 26, 26, 27, 503 23, 23, 23, 24, 25, 25, 26, 26, 26, 27,
503 28, 29, 30, 30, 31, 31, 31, 31, 31, 32, 504 27, 28, 29, 30, 31, 31, 32, 32, 32, 32,
504 32, 33, 33, 33 505 32, 33, 33, 34, 34, 34
505}; 506};
506 507
507/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 508/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
508static const yytype_uint8 yyr2[] = 509static const yytype_uint8 yyr2[] =
509{ 510{
510 0, 2, 3, 1, 2, 1, 1, 2, 1, 2, 511 0, 2, 3, 1, 2, 1, 1, 1, 2, 1,
511 2, 2, 4, 2, 5, 3, 1, 5, 3, 3, 512 2, 2, 2, 4, 4, 2, 5, 3, 1, 5,
512 3, 1, 3, 1, 3, 3, 1, 3, 1, 1, 513 3, 3, 3, 1, 3, 1, 3, 3, 1, 3,
513 0, 1, 1, 0 514 1, 1, 0, 1, 1, 0
514}; 515};
515 516
516/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 517/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -518,39 +519,39 @@ static const yytype_uint8 yyr2[] =
518 means the default is an error. */ 519 means the default is an error. */
519static const yytype_uint8 yydefact[] = 520static const yytype_uint8 yydefact[] =
520{ 521{
521 0, 0, 33, 21, 0, 16, 0, 0, 3, 5, 522 0, 0, 35, 23, 0, 18, 0, 0, 3, 5,
522 6, 30, 8, 30, 30, 30, 0, 31, 32, 13, 523 6, 7, 32, 9, 32, 32, 32, 0, 33, 34,
523 0, 0, 30, 1, 0, 4, 29, 7, 9, 10, 524 15, 0, 0, 0, 32, 1, 0, 4, 31, 8,
524 11, 20, 28, 26, 0, 23, 19, 15, 29, 18, 525 10, 11, 12, 22, 30, 28, 0, 25, 0, 21,
525 2, 0, 0, 0, 12, 0, 30, 27, 25, 24, 526 17, 31, 20, 2, 0, 0, 0, 14, 13, 0,
526 22, 14, 17 527 32, 29, 27, 26, 24, 16, 19
527}; 528};
528 529
529/* YYDEFGOTO[NTERM-NUM]. */ 530/* YYDEFGOTO[NTERM-NUM]. */
530static const yytype_int8 yydefgoto[] = 531static const yytype_int8 yydefgoto[] =
531{ 532{
532 -1, 7, 8, 9, 10, 11, 12, 13, 14, 15, 533 -1, 7, 8, 9, 10, 11, 12, 13, 14, 15,
533 34, 35, 27, 19 534 16, 36, 37, 29, 20
534}; 535};
535 536
536/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 537/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
537 STATE-NUM. */ 538 STATE-NUM. */
538#define YYPACT_NINF -14 539#define YYPACT_NINF -15
539static const yytype_int8 yypact[] = 540static const yytype_int8 yypact[] =
540{ 541{
541 1, -11, -1, -14, -6, 8, 20, 3, -14, 16, 542 1, -4, -9, -15, -1, 10, 22, 3, -15, 18,
542 -14, -2, -14, -2, -2, -2, 23, 13, -14, -14, 543 -15, -15, 11, -15, 11, 11, 11, 25, 13, -15,
543 21, 18, 9, -14, 1, -14, -14, -14, -14, -14, 544 -15, 13, 23, 20, 14, -15, 1, -15, -15, -15,
544 -14, -14, 11, 12, 6, -14, -14, 15, 25, -14, 545 -15, -15, -15, -15, 15, 16, 6, -15, 8, -15,
545 -14, 32, 7, 13, -14, 26, -2, -14, -14, -14, 546 21, 24, -15, -15, 34, 9, 13, -15, -15, 28,
546 -14, -14, -14 547 11, -15, -15, -15, -15, -15, -15
547}; 548};
548 549
549/* YYPGOTO[NTERM-NUM]. */ 550/* YYPGOTO[NTERM-NUM]. */
550static const yytype_int8 yypgoto[] = 551static const yytype_int8 yypgoto[] =
551{ 552{
552 -14, -14, 14, -14, -14, -14, -14, -14, -14, -14, 553 -15, -15, 17, -15, -15, -15, -15, -15, -15, -15,
553 -14, -7, -13, -14 554 -15, 19, -5, -14, -15
554}; 555};
555 556
556/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 557/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@@ -560,18 +561,20 @@ static const yytype_int8 yypgoto[] =
560#define YYTABLE_NINF -1 561#define YYTABLE_NINF -1
561static const yytype_uint8 yytable[] = 562static const yytype_uint8 yytable[] =
562{ 563{
563 28, 29, 30, 23, 1, 2, 3, 16, 4, 39, 564 30, 31, 32, 25, 1, 2, 3, 18, 4, 19,
564 48, 5, 20, 6, 49, 17, 26, 18, 24, 32, 565 42, 5, 52, 6, 17, 21, 53, 22, 26, 34,
565 33, 43, 44, 22, 25, 21, 31, 38, 36, 37, 566 35, 46, 47, 46, 48, 24, 27, 23, 33, 28,
566 41, 42, 45, 52, 46, 47, 50, 51, 40 567 39, 40, 41, 50, 44, 45, 56, 51, 49, 55,
568 38, 54, 0, 43
567}; 569};
568 570
569static const yytype_uint8 yycheck[] = 571static const yytype_int8 yycheck[] =
570{ 572{
571 13, 14, 15, 0, 3, 4, 5, 18, 7, 22, 573 14, 15, 16, 0, 3, 4, 5, 16, 7, 18,
572 3, 10, 18, 12, 7, 16, 18, 18, 15, 6, 574 24, 10, 3, 12, 18, 16, 7, 18, 15, 6,
573 7, 15, 16, 3, 8, 17, 3, 18, 7, 11, 575 7, 15, 16, 15, 16, 3, 8, 17, 3, 18,
574 19, 19, 17, 46, 9, 3, 43, 11, 24 576 7, 11, 18, 9, 19, 19, 50, 3, 17, 11,
577 21, 46, -1, 26
575}; 578};
576 579
577/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 580/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -579,11 +582,11 @@ static const yytype_uint8 yycheck[] =
579static const yytype_uint8 yystos[] = 582static const yytype_uint8 yystos[] =
580{ 583{
581 0, 3, 4, 5, 7, 10, 12, 21, 22, 23, 584 0, 3, 4, 5, 7, 10, 12, 21, 22, 23,
582 24, 25, 26, 27, 28, 29, 18, 16, 18, 33, 585 24, 25, 26, 27, 28, 29, 30, 18, 16, 18,
583 18, 17, 3, 0, 15, 8, 18, 32, 32, 32, 586 34, 16, 18, 17, 3, 0, 15, 8, 18, 33,
584 32, 3, 6, 7, 30, 31, 7, 11, 18, 32, 587 33, 33, 33, 3, 6, 7, 31, 32, 31, 7,
585 22, 19, 19, 15, 16, 17, 9, 3, 3, 7, 588 11, 18, 33, 22, 19, 19, 15, 16, 16, 17,
586 31, 11, 32 589 9, 3, 3, 7, 32, 11, 33
587}; 590};
588 591
589#define yyerrok (yyerrstatus = 0) 592#define yyerrok (yyerrstatus = 0)
@@ -1425,10 +1428,20 @@ yyreduce:
1425;} 1428;}
1426 break; 1429 break;
1427 1430
1428 case 12: 1431 case 13:
1429 1432
1430/* Line 1464 of yacc.c */ 1433/* Line 1464 of yacc.c */
1431#line 73 "util/parse-events.y" 1434#line 74 "util/parse-events.y"
1435 {
1436 ABORT_ON(parse_events_add_pmu(list, idx, (yyvsp[(1) - (4)].str), (yyvsp[(3) - (4)].head)));
1437 parse_events__free_terms((yyvsp[(3) - (4)].head));
1438;}
1439 break;
1440
1441 case 14:
1442
1443/* Line 1464 of yacc.c */
1444#line 81 "util/parse-events.y"
1432 { 1445 {
1433 int type = (yyvsp[(1) - (4)].num) >> 16; 1446 int type = (yyvsp[(1) - (4)].num) >> 16;
1434 int config = (yyvsp[(1) - (4)].num) & 255; 1447 int config = (yyvsp[(1) - (4)].num) & 255;
@@ -1438,10 +1451,10 @@ yyreduce:
1438;} 1451;}
1439 break; 1452 break;
1440 1453
1441 case 13: 1454 case 15:
1442 1455
1443/* Line 1464 of yacc.c */ 1456/* Line 1464 of yacc.c */
1444#line 82 "util/parse-events.y" 1457#line 90 "util/parse-events.y"
1445 { 1458 {
1446 int type = (yyvsp[(1) - (2)].num) >> 16; 1459 int type = (yyvsp[(1) - (2)].num) >> 16;
1447 int config = (yyvsp[(1) - (2)].num) & 255; 1460 int config = (yyvsp[(1) - (2)].num) & 255;
@@ -1450,82 +1463,82 @@ yyreduce:
1450;} 1463;}
1451 break; 1464 break;
1452 1465
1453 case 14: 1466 case 16:
1454 1467
1455/* Line 1464 of yacc.c */ 1468/* Line 1464 of yacc.c */
1456#line 91 "util/parse-events.y" 1469#line 99 "util/parse-events.y"
1457 { 1470 {
1458 ABORT_ON(parse_events_add_cache(list, idx, (yyvsp[(1) - (5)].str), (yyvsp[(3) - (5)].str), (yyvsp[(5) - (5)].str))); 1471 ABORT_ON(parse_events_add_cache(list, idx, (yyvsp[(1) - (5)].str), (yyvsp[(3) - (5)].str), (yyvsp[(5) - (5)].str)));
1459;} 1472;}
1460 break; 1473 break;
1461 1474
1462 case 15: 1475 case 17:
1463 1476
1464/* Line 1464 of yacc.c */ 1477/* Line 1464 of yacc.c */
1465#line 96 "util/parse-events.y" 1478#line 104 "util/parse-events.y"
1466 { 1479 {
1467 ABORT_ON(parse_events_add_cache(list, idx, (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str), NULL)); 1480 ABORT_ON(parse_events_add_cache(list, idx, (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str), NULL));
1468;} 1481;}
1469 break; 1482 break;
1470 1483
1471 case 16: 1484 case 18:
1472 1485
1473/* Line 1464 of yacc.c */ 1486/* Line 1464 of yacc.c */
1474#line 101 "util/parse-events.y" 1487#line 109 "util/parse-events.y"
1475 { 1488 {
1476 ABORT_ON(parse_events_add_cache(list, idx, (yyvsp[(1) - (1)].str), NULL, NULL)); 1489 ABORT_ON(parse_events_add_cache(list, idx, (yyvsp[(1) - (1)].str), NULL, NULL));
1477;} 1490;}
1478 break; 1491 break;
1479 1492
1480 case 17: 1493 case 19:
1481 1494
1482/* Line 1464 of yacc.c */ 1495/* Line 1464 of yacc.c */
1483#line 107 "util/parse-events.y" 1496#line 115 "util/parse-events.y"
1484 { 1497 {
1485 ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) (yyvsp[(2) - (5)].num), (yyvsp[(4) - (5)].str))); 1498 ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) (yyvsp[(2) - (5)].num), (yyvsp[(4) - (5)].str)));
1486;} 1499;}
1487 break; 1500 break;
1488 1501
1489 case 18: 1502 case 20:
1490 1503
1491/* Line 1464 of yacc.c */ 1504/* Line 1464 of yacc.c */
1492#line 112 "util/parse-events.y" 1505#line 120 "util/parse-events.y"
1493 { 1506 {
1494 ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) (yyvsp[(2) - (3)].num), NULL)); 1507 ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) (yyvsp[(2) - (3)].num), NULL));
1495;} 1508;}
1496 break; 1509 break;
1497 1510
1498 case 19: 1511 case 21:
1499 1512
1500/* Line 1464 of yacc.c */ 1513/* Line 1464 of yacc.c */
1501#line 118 "util/parse-events.y" 1514#line 126 "util/parse-events.y"
1502 { 1515 {
1503 ABORT_ON(parse_events_add_tracepoint(list, idx, (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str))); 1516 ABORT_ON(parse_events_add_tracepoint(list, idx, (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)));
1504;} 1517;}
1505 break; 1518 break;
1506 1519
1507 case 20: 1520 case 22:
1508 1521
1509/* Line 1464 of yacc.c */ 1522/* Line 1464 of yacc.c */
1510#line 124 "util/parse-events.y" 1523#line 132 "util/parse-events.y"
1511 { 1524 {
1512 ABORT_ON(parse_events_add_numeric(list, idx, (yyvsp[(1) - (3)].num), (yyvsp[(3) - (3)].num), NULL)); 1525 ABORT_ON(parse_events_add_numeric(list, idx, (yyvsp[(1) - (3)].num), (yyvsp[(3) - (3)].num), NULL));
1513;} 1526;}
1514 break; 1527 break;
1515 1528
1516 case 21: 1529 case 23:
1517 1530
1518/* Line 1464 of yacc.c */ 1531/* Line 1464 of yacc.c */
1519#line 130 "util/parse-events.y" 1532#line 138 "util/parse-events.y"
1520 { 1533 {
1521 ABORT_ON(parse_events_add_numeric(list, idx, PERF_TYPE_RAW, (yyvsp[(1) - (1)].num), NULL)); 1534 ABORT_ON(parse_events_add_numeric(list, idx, PERF_TYPE_RAW, (yyvsp[(1) - (1)].num), NULL));
1522;} 1535;}
1523 break; 1536 break;
1524 1537
1525 case 22: 1538 case 24:
1526 1539
1527/* Line 1464 of yacc.c */ 1540/* Line 1464 of yacc.c */
1528#line 136 "util/parse-events.y" 1541#line 144 "util/parse-events.y"
1529 { 1542 {
1530 struct list_head *head = (yyvsp[(1) - (3)].head); 1543 struct list_head *head = (yyvsp[(1) - (3)].head);
1531 struct parse_events__term *term = (yyvsp[(3) - (3)].term); 1544 struct parse_events__term *term = (yyvsp[(3) - (3)].term);
@@ -1536,10 +1549,10 @@ yyreduce:
1536;} 1549;}
1537 break; 1550 break;
1538 1551
1539 case 23: 1552 case 25:
1540 1553
1541/* Line 1464 of yacc.c */ 1554/* Line 1464 of yacc.c */
1542#line 146 "util/parse-events.y" 1555#line 154 "util/parse-events.y"
1543 { 1556 {
1544 struct list_head *head = malloc(sizeof(*head)); 1557 struct list_head *head = malloc(sizeof(*head));
1545 struct parse_events__term *term = (yyvsp[(1) - (1)].term); 1558 struct parse_events__term *term = (yyvsp[(1) - (1)].term);
@@ -1551,10 +1564,10 @@ yyreduce:
1551;} 1564;}
1552 break; 1565 break;
1553 1566
1554 case 24: 1567 case 26:
1555 1568
1556/* Line 1464 of yacc.c */ 1569/* Line 1464 of yacc.c */
1557#line 158 "util/parse-events.y" 1570#line 166 "util/parse-events.y"
1558 { 1571 {
1559 struct parse_events__term *term; 1572 struct parse_events__term *term;
1560 1573
@@ -1564,10 +1577,10 @@ yyreduce:
1564;} 1577;}
1565 break; 1578 break;
1566 1579
1567 case 25: 1580 case 27:
1568 1581
1569/* Line 1464 of yacc.c */ 1582/* Line 1464 of yacc.c */
1570#line 167 "util/parse-events.y" 1583#line 175 "util/parse-events.y"
1571 { 1584 {
1572 struct parse_events__term *term; 1585 struct parse_events__term *term;
1573 1586
@@ -1577,10 +1590,10 @@ yyreduce:
1577;} 1590;}
1578 break; 1591 break;
1579 1592
1580 case 26: 1593 case 28:
1581 1594
1582/* Line 1464 of yacc.c */ 1595/* Line 1464 of yacc.c */
1583#line 176 "util/parse-events.y" 1596#line 184 "util/parse-events.y"
1584 { 1597 {
1585 struct parse_events__term *term; 1598 struct parse_events__term *term;
1586 1599
@@ -1590,10 +1603,10 @@ yyreduce:
1590;} 1603;}
1591 break; 1604 break;
1592 1605
1593 case 27: 1606 case 29:
1594 1607
1595/* Line 1464 of yacc.c */ 1608/* Line 1464 of yacc.c */
1596#line 185 "util/parse-events.y" 1609#line 193 "util/parse-events.y"
1597 { 1610 {
1598 struct parse_events__term *term; 1611 struct parse_events__term *term;
1599 1612
@@ -1602,10 +1615,10 @@ yyreduce:
1602;} 1615;}
1603 break; 1616 break;
1604 1617
1605 case 28: 1618 case 30:
1606 1619
1607/* Line 1464 of yacc.c */ 1620/* Line 1464 of yacc.c */
1608#line 193 "util/parse-events.y" 1621#line 201 "util/parse-events.y"
1609 { 1622 {
1610 struct parse_events__term *term; 1623 struct parse_events__term *term;
1611 1624
@@ -1617,7 +1630,7 @@ yyreduce:
1617 1630
1618 1631
1619/* Line 1464 of yacc.c */ 1632/* Line 1464 of yacc.c */
1620#line 1621 "util/parse-events-bison.c" 1633#line 1634 "util/parse-events-bison.c"
1621 default: break; 1634 default: break;
1622 } 1635 }
1623 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 1636 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1829,7 +1842,7 @@ yyreturn:
1829 1842
1830 1843
1831/* Line 1684 of yacc.c */ 1844/* Line 1684 of yacc.c */
1832#line 204 "util/parse-events.y" 1845#line 212 "util/parse-events.y"
1833 1846
1834 1847
1835void parse_events_error(struct list_head *list __used, int *idx __used, 1848void parse_events_error(struct list_head *list __used, int *idx __used,
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 59f5cf64ef70..bec1cc6a1f38 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -12,6 +12,7 @@
12#include "header.h" 12#include "header.h"
13#include "debugfs.h" 13#include "debugfs.h"
14#include "parse-events-flex.h" 14#include "parse-events-flex.h"
15#include "pmu.h"
15 16
16#define MAX_NAME_LEN 100 17#define MAX_NAME_LEN 100
17 18
@@ -646,6 +647,30 @@ int parse_events_add_numeric(struct list_head *list, int *idx,
646 (char *) __event_name(type, config)); 647 (char *) __event_name(type, config));
647} 648}
648 649
650int parse_events_add_pmu(struct list_head *list, int *idx,
651 char *name, struct list_head *head_config)
652{
653 struct perf_event_attr attr;
654 struct perf_pmu *pmu;
655
656 pmu = perf_pmu__find(name);
657 if (!pmu)
658 return -EINVAL;
659
660 memset(&attr, 0, sizeof(attr));
661
662 /*
663 * Configure hardcoded terms first, no need to check
664 * return value when called with fail == 0 ;)
665 */
666 config_attr(&attr, head_config, 0);
667
668 if (perf_pmu__config(pmu, &attr, head_config))
669 return -EINVAL;
670
671 return add_event(list, idx, &attr, (char *) "pmu");
672}
673
649int parse_events_modifier(struct list_head *list, char *str) 674int parse_events_modifier(struct list_head *list, char *str)
650{ 675{
651 struct perf_evsel *evsel; 676 struct perf_evsel *evsel;
@@ -957,8 +982,12 @@ void print_events(const char *event_glob)
957 982
958 printf("\n"); 983 printf("\n");
959 printf(" %-50s [%s]\n", 984 printf(" %-50s [%s]\n",
960 "rNNN (see 'perf list --help' on how to encode it)", 985 "rNNN",
986 event_type_descriptors[PERF_TYPE_RAW]);
987 printf(" %-50s [%s]\n",
988 "cpu/t1=v1[,t2=v2,t3 ...]/modifier",
961 event_type_descriptors[PERF_TYPE_RAW]); 989 event_type_descriptors[PERF_TYPE_RAW]);
990 printf(" (see 'perf list --help' on how to encode it)\n");
962 printf("\n"); 991 printf("\n");
963 992
964 printf(" %-50s [%s]\n", 993 printf(" %-50s [%s]\n",
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 37a270d91d39..6d7c74b77c24 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -74,6 +74,8 @@ int parse_events_add_cache(struct list_head *list, int *idx,
74 char *type, char *op_result1, char *op_result2); 74 char *type, char *op_result1, char *op_result2);
75int parse_events_add_breakpoint(struct list_head *list, int *idx, 75int parse_events_add_breakpoint(struct list_head *list, int *idx,
76 void *ptr, char *type); 76 void *ptr, char *type);
77int parse_events_add_pmu(struct list_head *list, int *idx,
78 char *pmu , struct list_head *head_config);
77void parse_events_error(struct list_head *list, int *idx, 79void parse_events_error(struct list_head *list, int *idx,
78 char const *msg); 80 char const *msg);
79 81
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index c88c08e4e79d..3a530193f5a8 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -61,13 +61,21 @@ event_def PE_MODIFIER_EVENT
61| 61|
62event_def 62event_def
63 63
64event_def: event_legacy_symbol | 64event_def: event_pmu |
65 event_legacy_symbol |
65 event_legacy_cache sep_dc | 66 event_legacy_cache sep_dc |
66 event_legacy_mem | 67 event_legacy_mem |
67 event_legacy_tracepoint sep_dc | 68 event_legacy_tracepoint sep_dc |
68 event_legacy_numeric sep_dc | 69 event_legacy_numeric sep_dc |
69 event_legacy_raw sep_dc 70 event_legacy_raw sep_dc
70 71
72event_pmu:
73PE_NAME '/' event_config '/'
74{
75 ABORT_ON(parse_events_add_pmu(list, idx, $1, $3));
76 parse_events__free_terms($3);
77}
78
71event_legacy_symbol: 79event_legacy_symbol:
72PE_VALUE_SYM '/' event_config '/' 80PE_VALUE_SYM '/' event_config '/'
73{ 81{