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

perf pmu: Let pmu's with no events show up on perf list

perf list only lists PMUs with events. Add a flag to cause a PMU to be
also listed separately.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1414061124-26830-3-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
42634bc7 ed307758

+12 -2
+11 -2
tools/perf/util/pmu.c
··· 747 747 748 748 pmu = NULL; 749 749 len = 0; 750 - while ((pmu = perf_pmu__scan(pmu)) != NULL) 750 + while ((pmu = perf_pmu__scan(pmu)) != NULL) { 751 751 list_for_each_entry(alias, &pmu->aliases, list) 752 752 len++; 753 + if (pmu->selectable) 754 + len++; 755 + } 753 756 aliases = malloc(sizeof(char *) * len); 754 757 if (!aliases) 755 758 return; 756 759 pmu = NULL; 757 760 j = 0; 758 - while ((pmu = perf_pmu__scan(pmu)) != NULL) 761 + while ((pmu = perf_pmu__scan(pmu)) != NULL) { 759 762 list_for_each_entry(alias, &pmu->aliases, list) { 760 763 char *name = format_alias(buf, sizeof(buf), pmu, alias); 761 764 bool is_cpu = !strcmp(pmu->name, "cpu"); ··· 775 772 aliases[j] = strdup(aliases[j]); 776 773 j++; 777 774 } 775 + if (pmu->selectable) { 776 + scnprintf(buf, sizeof(buf), "%s//", pmu->name); 777 + aliases[j] = strdup(buf); 778 + j++; 779 + } 780 + } 778 781 len = j; 779 782 qsort(aliases, len, sizeof(char *), cmp_string); 780 783 for (j = 0; j < len; j++) {
+1
tools/perf/util/pmu.h
··· 18 18 struct perf_pmu { 19 19 char *name; 20 20 __u32 type; 21 + bool selectable; 21 22 struct perf_event_attr *default_config; 22 23 struct cpu_map *cpus; 23 24 struct list_head format; /* HEAD struct perf_pmu_format -> list */