Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf list: Support long jevents descriptions

Previously we were dropping the useful longer descriptions that some
events have in the event list completely. This patch makes them appear with
perf list.

Old perf list:

baclears:
baclears.all
[Counts the number of baclears]

vs new:

perf list -v:
...
baclears:
baclears.all
[The BACLEARS event counts the number of times the front end is
resteered, mainly when the Branch Prediction Unit cannot provide
a correct prediction and this is corrected by the Branch Address
Calculator at the front end. The BACLEARS.ANY event counts the
number of baclears for any type of branch]

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>
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-13-git-send-email-sukadev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Sukadev Bhattiprolu and committed by
Arnaldo Carvalho de Melo
c8d6828a 794ba54a

+34 -15
+5 -1
tools/perf/Documentation/perf-list.txt
··· 8 8 SYNOPSIS 9 9 -------- 10 10 [verse] 11 - 'perf list' [--no-desc] [hw|sw|cache|tracepoint|pmu|event_glob] 11 + 'perf list' [--no-desc] [--long-desc] [hw|sw|cache|tracepoint|pmu|event_glob] 12 12 13 13 DESCRIPTION 14 14 ----------- ··· 19 19 ------- 20 20 --no-desc:: 21 21 Don't print descriptions. 22 + 23 + -v:: 24 + --long-desc:: 25 + Print longer event descriptions. 22 26 23 27 24 28 [[EVENT_MODIFIERS]]
+11 -5
tools/perf/builtin-list.c
··· 22 22 { 23 23 int i; 24 24 bool raw_dump = false; 25 + bool long_desc_flag = false; 25 26 struct option list_options[] = { 26 27 OPT_BOOLEAN(0, "raw-dump", &raw_dump, "Dump raw events"), 27 28 OPT_BOOLEAN('d', "desc", &desc_flag, 28 29 "Print extra event descriptions. --no-desc to not print."), 30 + OPT_BOOLEAN('v', "long-desc", &long_desc_flag, 31 + "Print longer event descriptions."), 29 32 OPT_END() 30 33 }; 31 34 const char * const list_usage[] = { 32 - "perf list [--no-desc] [hw|sw|cache|tracepoint|pmu|sdt|event_glob]", 35 + "perf list [<options>] [hw|sw|cache|tracepoint|pmu|sdt|event_glob]", 33 36 NULL 34 37 }; 35 38 ··· 47 44 printf("\nList of pre-defined events (to be used in -e):\n\n"); 48 45 49 46 if (argc == 0) { 50 - print_events(NULL, raw_dump, !desc_flag); 47 + print_events(NULL, raw_dump, !desc_flag, long_desc_flag); 51 48 return 0; 52 49 } 53 50 ··· 68 65 strcmp(argv[i], "hwcache") == 0) 69 66 print_hwcache_events(NULL, raw_dump); 70 67 else if (strcmp(argv[i], "pmu") == 0) 71 - print_pmu_events(NULL, raw_dump, !desc_flag); 68 + print_pmu_events(NULL, raw_dump, !desc_flag, 69 + long_desc_flag); 72 70 else if (strcmp(argv[i], "sdt") == 0) 73 71 print_sdt_events(NULL, NULL, raw_dump); 74 72 else if ((sep = strchr(argv[i], ':')) != NULL) { 75 73 int sep_idx; 76 74 77 75 if (sep == NULL) { 78 - print_events(argv[i], raw_dump, !desc_flag); 76 + print_events(argv[i], raw_dump, !desc_flag, 77 + long_desc_flag); 79 78 continue; 80 79 } 81 80 sep_idx = sep - argv[i]; ··· 99 94 print_symbol_events(s, PERF_TYPE_SOFTWARE, 100 95 event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump); 101 96 print_hwcache_events(s, raw_dump); 102 - print_pmu_events(s, raw_dump, !desc_flag); 97 + print_pmu_events(s, raw_dump, !desc_flag, 98 + long_desc_flag); 103 99 print_tracepoint_events(NULL, s, raw_dump); 104 100 print_sdt_events(NULL, s, raw_dump); 105 101 free(s);
+3 -2
tools/perf/util/parse-events.c
··· 2263 2263 /* 2264 2264 * Print the help text for the event symbols: 2265 2265 */ 2266 - void print_events(const char *event_glob, bool name_only, bool quiet_flag) 2266 + void print_events(const char *event_glob, bool name_only, bool quiet_flag, 2267 + bool long_desc) 2267 2268 { 2268 2269 print_symbol_events(event_glob, PERF_TYPE_HARDWARE, 2269 2270 event_symbols_hw, PERF_COUNT_HW_MAX, name_only); ··· 2274 2273 2275 2274 print_hwcache_events(event_glob, name_only); 2276 2275 2277 - print_pmu_events(event_glob, name_only, quiet_flag); 2276 + print_pmu_events(event_glob, name_only, quiet_flag, long_desc); 2278 2277 2279 2278 if (event_glob != NULL) 2280 2279 return;
+2 -1
tools/perf/util/parse-events.h
··· 172 172 void parse_events_evlist_error(struct parse_events_evlist *data, 173 173 int idx, const char *str); 174 174 175 - void print_events(const char *event_glob, bool name_only, bool quiet); 175 + void print_events(const char *event_glob, bool name_only, bool quiet, 176 + bool long_desc); 176 177 177 178 struct event_symbol { 178 179 const char *symbol;
+10 -5
tools/perf/util/pmu.c
··· 223 223 } 224 224 225 225 static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, 226 - char *desc, char *val) 226 + char *desc, char *val, char *long_desc) 227 227 { 228 228 struct perf_pmu_alias *alias; 229 229 int ret; ··· 257 257 } 258 258 259 259 alias->desc = desc ? strdup(desc) : NULL; 260 + alias->long_desc = long_desc ? strdup(long_desc) : 261 + desc ? strdup(desc) : NULL; 260 262 261 263 list_add_tail(&alias->list, list); 262 264 ··· 276 274 277 275 buf[ret] = 0; 278 276 279 - return __perf_pmu__new_alias(list, dir, name, NULL, buf); 277 + return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL); 280 278 } 281 279 282 280 static inline bool pmu_alias_info_file(char *name) ··· 534 532 535 533 /* need type casts to override 'const' */ 536 534 __perf_pmu__new_alias(head, NULL, (char *)pe->name, 537 - (char *)pe->desc, (char *)pe->event); 535 + (char *)pe->desc, (char *)pe->event, 536 + (char *)pe->long_desc); 538 537 } 539 538 540 539 out: ··· 1093 1090 } 1094 1091 } 1095 1092 1096 - void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag) 1093 + void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag, 1094 + bool long_desc) 1097 1095 { 1098 1096 struct perf_pmu *pmu; 1099 1097 struct perf_pmu_alias *alias; ··· 1142 1138 if (!aliases[j].name) 1143 1139 goto out_enomem; 1144 1140 1145 - aliases[j].desc = alias->desc; 1141 + aliases[j].desc = long_desc ? alias->long_desc : 1142 + alias->desc; 1146 1143 j++; 1147 1144 } 1148 1145 if (pmu->selectable &&
+3 -1
tools/perf/util/pmu.h
··· 41 41 struct perf_pmu_alias { 42 42 char *name; 43 43 char *desc; 44 + char *long_desc; 44 45 struct list_head terms; /* HEAD struct parse_events_term -> list */ 45 46 struct list_head list; /* ELEM */ 46 47 char unit[UNIT_MAX_LEN+1]; ··· 73 72 74 73 struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu); 75 74 76 - void print_pmu_events(const char *event_glob, bool name_only, bool quiet); 75 + void print_pmu_events(const char *event_glob, bool name_only, bool quiet, 76 + bool long_desc); 77 77 bool pmu_have_event(const char *pname, const char *name); 78 78 79 79 int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,