aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-events.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r--tools/perf/util/parse-events.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 41982c373fa..928918b796b 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -86,22 +86,24 @@ static const char *sw_event_names[PERF_COUNT_SW_MAX] = {
86 86
87#define MAX_ALIASES 8 87#define MAX_ALIASES 8
88 88
89static const char *hw_cache[][MAX_ALIASES] = { 89static const char *hw_cache[PERF_COUNT_HW_CACHE_MAX][MAX_ALIASES] = {
90 { "L1-dcache", "l1-d", "l1d", "L1-data", }, 90 { "L1-dcache", "l1-d", "l1d", "L1-data", },
91 { "L1-icache", "l1-i", "l1i", "L1-instruction", }, 91 { "L1-icache", "l1-i", "l1i", "L1-instruction", },
92 { "LLC", "L2" }, 92 { "LLC", "L2", },
93 { "dTLB", "d-tlb", "Data-TLB", }, 93 { "dTLB", "d-tlb", "Data-TLB", },
94 { "iTLB", "i-tlb", "Instruction-TLB", }, 94 { "iTLB", "i-tlb", "Instruction-TLB", },
95 { "branch", "branches", "bpu", "btb", "bpc", }, 95 { "branch", "branches", "bpu", "btb", "bpc", },
96 { "node", },
96}; 97};
97 98
98static const char *hw_cache_op[][MAX_ALIASES] = { 99static const char *hw_cache_op[PERF_COUNT_HW_CACHE_OP_MAX][MAX_ALIASES] = {
99 { "load", "loads", "read", }, 100 { "load", "loads", "read", },
100 { "store", "stores", "write", }, 101 { "store", "stores", "write", },
101 { "prefetch", "prefetches", "speculative-read", "speculative-load", }, 102 { "prefetch", "prefetches", "speculative-read", "speculative-load", },
102}; 103};
103 104
104static const char *hw_cache_result[][MAX_ALIASES] = { 105static const char *hw_cache_result[PERF_COUNT_HW_CACHE_RESULT_MAX]
106 [MAX_ALIASES] = {
105 { "refs", "Reference", "ops", "access", }, 107 { "refs", "Reference", "ops", "access", },
106 { "misses", "miss", }, 108 { "misses", "miss", },
107}; 109};
@@ -124,6 +126,7 @@ static unsigned long hw_cache_stat[C(MAX)] = {
124 [C(DTLB)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH), 126 [C(DTLB)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
125 [C(ITLB)] = (CACHE_READ), 127 [C(ITLB)] = (CACHE_READ),
126 [C(BPU)] = (CACHE_READ), 128 [C(BPU)] = (CACHE_READ),
129 [C(NODE)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
127}; 130};
128 131
129#define for_each_subsystem(sys_dir, sys_dirent, sys_next) \ 132#define for_each_subsystem(sys_dir, sys_dirent, sys_next) \
@@ -393,7 +396,7 @@ parse_generic_hw_event(const char **str, struct perf_event_attr *attr)
393 PERF_COUNT_HW_CACHE_OP_MAX); 396 PERF_COUNT_HW_CACHE_OP_MAX);
394 if (cache_op >= 0) { 397 if (cache_op >= 0) {
395 if (!is_cache_op_valid(cache_type, cache_op)) 398 if (!is_cache_op_valid(cache_type, cache_op))
396 return 0; 399 return EVT_FAILED;
397 continue; 400 continue;
398 } 401 }
399 } 402 }
@@ -475,7 +478,7 @@ parse_single_tracepoint_event(char *sys_name,
475/* sys + ':' + event + ':' + flags*/ 478/* sys + ':' + event + ':' + flags*/
476#define MAX_EVOPT_LEN (MAX_EVENT_LENGTH * 2 + 2 + 128) 479#define MAX_EVOPT_LEN (MAX_EVENT_LENGTH * 2 + 2 + 128)
477static enum event_result 480static enum event_result
478parse_multiple_tracepoint_event(const struct option *opt, char *sys_name, 481parse_multiple_tracepoint_event(struct perf_evlist *evlist, char *sys_name,
479 const char *evt_exp, char *flags) 482 const char *evt_exp, char *flags)
480{ 483{
481 char evt_path[MAXPATHLEN]; 484 char evt_path[MAXPATHLEN];
@@ -509,7 +512,7 @@ parse_multiple_tracepoint_event(const struct option *opt, char *sys_name,
509 if (len < 0) 512 if (len < 0)
510 return EVT_FAILED; 513 return EVT_FAILED;
511 514
512 if (parse_events(opt, event_opt, 0)) 515 if (parse_events(evlist, event_opt, 0))
513 return EVT_FAILED; 516 return EVT_FAILED;
514 } 517 }
515 518
@@ -517,7 +520,7 @@ parse_multiple_tracepoint_event(const struct option *opt, char *sys_name,
517} 520}
518 521
519static enum event_result 522static enum event_result
520parse_tracepoint_event(const struct option *opt, const char **strp, 523parse_tracepoint_event(struct perf_evlist *evlist, const char **strp,
521 struct perf_event_attr *attr) 524 struct perf_event_attr *attr)
522{ 525{
523 const char *evt_name; 526 const char *evt_name;
@@ -557,8 +560,8 @@ parse_tracepoint_event(const struct option *opt, const char **strp,
557 return EVT_FAILED; 560 return EVT_FAILED;
558 if (strpbrk(evt_name, "*?")) { 561 if (strpbrk(evt_name, "*?")) {
559 *strp += strlen(sys_name) + evt_length + 1; /* 1 == the ':' */ 562 *strp += strlen(sys_name) + evt_length + 1; /* 1 == the ':' */
560 return parse_multiple_tracepoint_event(opt, sys_name, evt_name, 563 return parse_multiple_tracepoint_event(evlist, sys_name,
561 flags); 564 evt_name, flags);
562 } else { 565 } else {
563 return parse_single_tracepoint_event(sys_name, evt_name, 566 return parse_single_tracepoint_event(sys_name, evt_name,
564 evt_length, attr, strp); 567 evt_length, attr, strp);
@@ -694,7 +697,11 @@ parse_raw_event(const char **strp, struct perf_event_attr *attr)
694 return EVT_FAILED; 697 return EVT_FAILED;
695 n = hex2u64(str + 1, &config); 698 n = hex2u64(str + 1, &config);
696 if (n > 0) { 699 if (n > 0) {
697 *strp = str + n + 1; 700 const char *end = str + n + 1;
701 if (*end != '\0' && *end != ',' && *end != ':')
702 return EVT_FAILED;
703
704 *strp = end;
698 attr->type = PERF_TYPE_RAW; 705 attr->type = PERF_TYPE_RAW;
699 attr->config = config; 706 attr->config = config;
700 return EVT_HANDLED; 707 return EVT_HANDLED;
@@ -778,12 +785,12 @@ parse_event_modifier(const char **strp, struct perf_event_attr *attr)
778 * Symbolic names are (almost) exactly matched. 785 * Symbolic names are (almost) exactly matched.
779 */ 786 */
780static enum event_result 787static enum event_result
781parse_event_symbols(const struct option *opt, const char **str, 788parse_event_symbols(struct perf_evlist *evlist, const char **str,
782 struct perf_event_attr *attr) 789 struct perf_event_attr *attr)
783{ 790{
784 enum event_result ret; 791 enum event_result ret;
785 792
786 ret = parse_tracepoint_event(opt, str, attr); 793 ret = parse_tracepoint_event(evlist, str, attr);
787 if (ret != EVT_FAILED) 794 if (ret != EVT_FAILED)
788 goto modifier; 795 goto modifier;
789 796
@@ -822,9 +829,8 @@ modifier:
822 return ret; 829 return ret;
823} 830}
824 831
825int parse_events(const struct option *opt, const char *str, int unset __used) 832int parse_events(struct perf_evlist *evlist , const char *str, int unset __used)
826{ 833{
827 struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
828 struct perf_event_attr attr; 834 struct perf_event_attr attr;
829 enum event_result ret; 835 enum event_result ret;
830 const char *ostr; 836 const char *ostr;
@@ -832,7 +838,7 @@ int parse_events(const struct option *opt, const char *str, int unset __used)
832 for (;;) { 838 for (;;) {
833 ostr = str; 839 ostr = str;
834 memset(&attr, 0, sizeof(attr)); 840 memset(&attr, 0, sizeof(attr));
835 ret = parse_event_symbols(opt, &str, &attr); 841 ret = parse_event_symbols(evlist, &str, &attr);
836 if (ret == EVT_FAILED) 842 if (ret == EVT_FAILED)
837 return -1; 843 return -1;
838 844
@@ -863,6 +869,13 @@ int parse_events(const struct option *opt, const char *str, int unset __used)
863 return 0; 869 return 0;
864} 870}
865 871
872int parse_events_option(const struct option *opt, const char *str,
873 int unset __used)
874{
875 struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
876 return parse_events(evlist, str, unset);
877}
878
866int parse_filter(const struct option *opt, const char *str, 879int parse_filter(const struct option *opt, const char *str,
867 int unset __used) 880 int unset __used)
868{ 881{
@@ -1088,6 +1101,4 @@ void print_events(const char *event_glob)
1088 printf("\n"); 1101 printf("\n");
1089 1102
1090 print_tracepoint_events(NULL, NULL); 1103 print_tracepoint_events(NULL, NULL);
1091
1092 exit(129);
1093} 1104}