diff options
author | Cody P Schafer <cody@linux.vnet.ibm.com> | 2015-01-07 20:13:51 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-01-21 11:24:33 -0500 |
commit | aaea36174991ff39c7a18044660db86527100c55 (patch) | |
tree | 67e1793344a86907a1eb4e9fd56af9a693ff20e3 /tools | |
parent | 688d4dfcdd624192cbf03c08402e444d1d11f294 (diff) |
perf tools: Extend format_alias() to include event parameters
This causes `perf list pmu` to show parameters for parameterized events
like:
pmu/event_name,param1=?,param2=?/ [Kernel PMU event]
An example:
hv_24x7/HPM_TLBIE__PHYS_CORE,core=?/ [Kernel PMU event]
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Cody P Schafer <dev@codyps.com>
Cc: Haren Myneni <hbabu@us.ibm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/1420679633-28856-3-git-send-email-sukadev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/pmu.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index bfbecf7abd38..48411674da0f 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
@@ -819,10 +819,36 @@ void perf_pmu__set_format(unsigned long *bits, long from, long to) | |||
819 | set_bit(b, bits); | 819 | set_bit(b, bits); |
820 | } | 820 | } |
821 | 821 | ||
822 | static int sub_non_neg(int a, int b) | ||
823 | { | ||
824 | if (b > a) | ||
825 | return 0; | ||
826 | return a - b; | ||
827 | } | ||
828 | |||
822 | static char *format_alias(char *buf, int len, struct perf_pmu *pmu, | 829 | static char *format_alias(char *buf, int len, struct perf_pmu *pmu, |
823 | struct perf_pmu_alias *alias) | 830 | struct perf_pmu_alias *alias) |
824 | { | 831 | { |
825 | snprintf(buf, len, "%s/%s/", pmu->name, alias->name); | 832 | struct parse_events_term *term; |
833 | int used = snprintf(buf, len, "%s/%s", pmu->name, alias->name); | ||
834 | |||
835 | list_for_each_entry(term, &alias->terms, list) { | ||
836 | if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) | ||
837 | used += snprintf(buf + used, sub_non_neg(len, used), | ||
838 | ",%s=%s", term->config, | ||
839 | term->val.str); | ||
840 | } | ||
841 | |||
842 | if (sub_non_neg(len, used) > 0) { | ||
843 | buf[used] = '/'; | ||
844 | used++; | ||
845 | } | ||
846 | if (sub_non_neg(len, used) > 0) { | ||
847 | buf[used] = '\0'; | ||
848 | used++; | ||
849 | } else | ||
850 | buf[len - 1] = '\0'; | ||
851 | |||
826 | return buf; | 852 | return buf; |
827 | } | 853 | } |
828 | 854 | ||