diff options
author | Andi Kleen <ak@linux.intel.com> | 2016-09-15 18:24:50 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-10-03 20:35:47 -0400 |
commit | dd5f10368a5f27ec926395056d959513ca4578cc (patch) | |
tree | 287e6c15e16eb473dc3764e4434544542d6e1bfc /tools/perf | |
parent | c8d6828a6510c9363180ebf662b51d032e0eb85a (diff) |
perf list jevents: Add support for event list topics
Add support to group the output of perf list by the Topic field in the
JSON file.
Example output:
% perf list
...
Cache:
l1d.replacement
[L1D data line replacements]
l1d_pend_miss.pending
[L1D miss oustandings duration in cycles]
l1d_pend_miss.pending_cycles
[Cycles with L1D load Misses outstanding]
l2_l1d_wb_rqsts.all
[Not rejected writebacks from L1D to L2 cache lines in any state]
l2_l1d_wb_rqsts.hit_e
[Not rejected writebacks from L1D to L2 cache lines in E state]
l2_l1d_wb_rqsts.hit_m
[Not rejected writebacks from L1D to L2 cache lines in M state]
...
Pipeline:
arith.fpu_div
[Divide operations executed]
arith.fpu_div_active
[Cycles when divider is busy executing divide operations]
baclears.any
[Counts the total number when the front end is resteered, mainly
when the BPU cannot provide a correct prediction and this is
corrected by other branch handling mechanisms at the front end]
br_inst_exec.all_branches
[Speculative and retired branches]
br_inst_exec.all_conditional
[Speculative and retired macro-conditional branches]
br_inst_exec.all_direct_jmp
[Speculative and retired macro-unconditional branches excluding
calls and indirects]
br_inst_exec.all_direct_near_call
[Speculative and retired direct near calls]
br_inst_exec.all_indirect_jump_non_call_ret
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/1473978296-20712-14-git-send-email-sukadev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/pmu.c | 37 | ||||
-rw-r--r-- | tools/perf/util/pmu.h | 1 |
2 files changed, 28 insertions, 10 deletions
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 8ff382cb161d..b1474dcadfa2 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
@@ -223,7 +223,8 @@ static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias, | |||
223 | } | 223 | } |
224 | 224 | ||
225 | static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, | 225 | static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, |
226 | char *desc, char *val, char *long_desc) | 226 | char *desc, char *val, char *long_desc, |
227 | char *topic) | ||
227 | { | 228 | { |
228 | struct perf_pmu_alias *alias; | 229 | struct perf_pmu_alias *alias; |
229 | int ret; | 230 | int ret; |
@@ -259,6 +260,7 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, | |||
259 | alias->desc = desc ? strdup(desc) : NULL; | 260 | alias->desc = desc ? strdup(desc) : NULL; |
260 | alias->long_desc = long_desc ? strdup(long_desc) : | 261 | alias->long_desc = long_desc ? strdup(long_desc) : |
261 | desc ? strdup(desc) : NULL; | 262 | desc ? strdup(desc) : NULL; |
263 | alias->topic = topic ? strdup(topic) : NULL; | ||
262 | 264 | ||
263 | list_add_tail(&alias->list, list); | 265 | list_add_tail(&alias->list, list); |
264 | 266 | ||
@@ -276,7 +278,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI | |||
276 | 278 | ||
277 | buf[ret] = 0; | 279 | buf[ret] = 0; |
278 | 280 | ||
279 | return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL); | 281 | return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL); |
280 | } | 282 | } |
281 | 283 | ||
282 | static inline bool pmu_alias_info_file(char *name) | 284 | static inline bool pmu_alias_info_file(char *name) |
@@ -535,7 +537,7 @@ static void pmu_add_cpu_aliases(struct list_head *head) | |||
535 | /* need type casts to override 'const' */ | 537 | /* need type casts to override 'const' */ |
536 | __perf_pmu__new_alias(head, NULL, (char *)pe->name, | 538 | __perf_pmu__new_alias(head, NULL, (char *)pe->name, |
537 | (char *)pe->desc, (char *)pe->event, | 539 | (char *)pe->desc, (char *)pe->event, |
538 | (char *)pe->long_desc); | 540 | (char *)pe->long_desc, (char *)pe->topic); |
539 | } | 541 | } |
540 | 542 | ||
541 | out: | 543 | out: |
@@ -1055,19 +1057,26 @@ static char *format_alias_or(char *buf, int len, struct perf_pmu *pmu, | |||
1055 | return buf; | 1057 | return buf; |
1056 | } | 1058 | } |
1057 | 1059 | ||
1058 | struct pair { | 1060 | struct sevent { |
1059 | char *name; | 1061 | char *name; |
1060 | char *desc; | 1062 | char *desc; |
1063 | char *topic; | ||
1061 | }; | 1064 | }; |
1062 | 1065 | ||
1063 | static int cmp_pair(const void *a, const void *b) | 1066 | static int cmp_sevent(const void *a, const void *b) |
1064 | { | 1067 | { |
1065 | const struct pair *as = a; | 1068 | const struct sevent *as = a; |
1066 | const struct pair *bs = b; | 1069 | const struct sevent *bs = b; |
1067 | 1070 | ||
1068 | /* Put extra events last */ | 1071 | /* Put extra events last */ |
1069 | if (!!as->desc != !!bs->desc) | 1072 | if (!!as->desc != !!bs->desc) |
1070 | return !!as->desc - !!bs->desc; | 1073 | return !!as->desc - !!bs->desc; |
1074 | if (as->topic && bs->topic) { | ||
1075 | int n = strcmp(as->topic, bs->topic); | ||
1076 | |||
1077 | if (n) | ||
1078 | return n; | ||
1079 | } | ||
1071 | return strcmp(as->name, bs->name); | 1080 | return strcmp(as->name, bs->name); |
1072 | } | 1081 | } |
1073 | 1082 | ||
@@ -1101,9 +1110,10 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag, | |||
1101 | char buf[1024]; | 1110 | char buf[1024]; |
1102 | int printed = 0; | 1111 | int printed = 0; |
1103 | int len, j; | 1112 | int len, j; |
1104 | struct pair *aliases; | 1113 | struct sevent *aliases; |
1105 | int numdesc = 0; | 1114 | int numdesc = 0; |
1106 | int columns = pager_get_columns(); | 1115 | int columns = pager_get_columns(); |
1116 | char *topic = NULL; | ||
1107 | 1117 | ||
1108 | pmu = NULL; | 1118 | pmu = NULL; |
1109 | len = 0; | 1119 | len = 0; |
@@ -1113,7 +1123,7 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag, | |||
1113 | if (pmu->selectable) | 1123 | if (pmu->selectable) |
1114 | len++; | 1124 | len++; |
1115 | } | 1125 | } |
1116 | aliases = zalloc(sizeof(struct pair) * len); | 1126 | aliases = zalloc(sizeof(struct sevent) * len); |
1117 | if (!aliases) | 1127 | if (!aliases) |
1118 | goto out_enomem; | 1128 | goto out_enomem; |
1119 | pmu = NULL; | 1129 | pmu = NULL; |
@@ -1144,6 +1154,7 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag, | |||
1144 | 1154 | ||
1145 | aliases[j].desc = long_desc ? alias->long_desc : | 1155 | aliases[j].desc = long_desc ? alias->long_desc : |
1146 | alias->desc; | 1156 | alias->desc; |
1157 | aliases[j].topic = alias->topic; | ||
1147 | j++; | 1158 | j++; |
1148 | } | 1159 | } |
1149 | if (pmu->selectable && | 1160 | if (pmu->selectable && |
@@ -1156,7 +1167,7 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag, | |||
1156 | } | 1167 | } |
1157 | } | 1168 | } |
1158 | len = j; | 1169 | len = j; |
1159 | qsort(aliases, len, sizeof(struct pair), cmp_pair); | 1170 | qsort(aliases, len, sizeof(struct sevent), cmp_sevent); |
1160 | for (j = 0; j < len; j++) { | 1171 | for (j = 0; j < len; j++) { |
1161 | if (name_only) { | 1172 | if (name_only) { |
1162 | printf("%s ", aliases[j].name); | 1173 | printf("%s ", aliases[j].name); |
@@ -1165,6 +1176,12 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag, | |||
1165 | if (aliases[j].desc && !quiet_flag) { | 1176 | if (aliases[j].desc && !quiet_flag) { |
1166 | if (numdesc++ == 0) | 1177 | if (numdesc++ == 0) |
1167 | printf("\n"); | 1178 | printf("\n"); |
1179 | if (aliases[j].topic && (!topic || | ||
1180 | strcmp(topic, aliases[j].topic))) { | ||
1181 | printf("%s%s:\n", topic ? "\n" : "", | ||
1182 | aliases[j].topic); | ||
1183 | topic = aliases[j].topic; | ||
1184 | } | ||
1168 | printf(" %-50s\n", aliases[j].name); | 1185 | printf(" %-50s\n", aliases[j].name); |
1169 | printf("%*s", 8, "["); | 1186 | printf("%*s", 8, "["); |
1170 | wordwrap(aliases[j].desc, 8, columns, 0); | 1187 | wordwrap(aliases[j].desc, 8, columns, 0); |
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 2fb8aa0fb47f..25712034c815 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h | |||
@@ -42,6 +42,7 @@ struct perf_pmu_alias { | |||
42 | char *name; | 42 | char *name; |
43 | char *desc; | 43 | char *desc; |
44 | char *long_desc; | 44 | char *long_desc; |
45 | char *topic; | ||
45 | struct list_head terms; /* HEAD struct parse_events_term -> list */ | 46 | struct list_head terms; /* HEAD struct parse_events_term -> list */ |
46 | struct list_head list; /* ELEM */ | 47 | struct list_head list; /* ELEM */ |
47 | char unit[UNIT_MAX_LEN+1]; | 48 | char unit[UNIT_MAX_LEN+1]; |