From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 2B02C1A0A62 for ; Thu, 18 Sep 2014 04:52:22 +1000 (EST) Received: from /spool/local by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 17 Sep 2014 12:52:21 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id EFE971FF003B for ; Wed, 17 Sep 2014 12:52:17 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s8HGmDIJ7274774 for ; Wed, 17 Sep 2014 18:48:13 +0200 Received: from d03av03.boulder.ibm.com (localhost [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s8HIqHar006019 for ; Wed, 17 Sep 2014 12:52:19 -0600 From: Sukadev Bhattiprolu To: Arnaldo Carvalho de Melo , ak@linux.intel.com, Jiri Olsa , peterz@infradead.org, eranian@google.com, Paul Mackerras Subject: [PATCH v3 02/10] tools/perf: extend format_alias() to include event parameters Date: Wed, 17 Sep 2014 11:51:55 -0700 Message-Id: <1410979923-7722-3-git-send-email-sukadev@linux.vnet.ibm.com> In-Reply-To: <1410979923-7722-1-git-send-email-sukadev@linux.vnet.ibm.com> References: <1410979923-7722-1-git-send-email-sukadev@linux.vnet.ibm.com> Cc: Michael Ellerman , linux-kernel@vger.kernel.org, dev@codyps.com, linuxppc-dev@lists.ozlabs.org, Anshuman Khandual List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cody P Schafer This causes `perf list pmu` to show parameters for parameterized events like follows: pmu/event_name,param1=?,param2=?/ [Kernel PMU event] An example: hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=?/ [Kernel PMU event] Changelog[v6] [Jir Olsa] If the parameter for an event in sysfs is 'param=val', have perf-list show the event as 'param=?' rather than 'val=?'. CC: Haren Myneni CC: Cody P Schafer Signed-off-by: Cody P Schafer Signed-off-by: Sukadev Bhattiprolu --- tools/perf/util/pmu.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 8c7c4a1..0756917 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -748,10 +748,33 @@ void perf_pmu__set_format(unsigned long *bits, long from, long to) set_bit(b, bits); } +static int sub_non_neg(int a, int b) +{ + if (b > a) + return 0; + return a - b; +} + static char *format_alias(char *buf, int len, struct perf_pmu *pmu, struct perf_pmu_alias *alias) { - snprintf(buf, len, "%s/%s/", pmu->name, alias->name); + struct parse_events_term *term; + int used = snprintf(buf, len, "%s/%s", pmu->name, alias->name); + + list_for_each_entry(term, &alias->terms, list) + if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) + used += snprintf(buf + used, sub_non_neg(len, used), + ",%s=?", term->config); + + if (sub_non_neg(len, used) > 0) { + buf[used] = '/'; + used++; + } + if (sub_non_neg(len, used) > 0) { + buf[used] = '\0'; + used++; + } else + buf[len - 1] = '\0'; return buf; } @@ -802,6 +825,7 @@ void print_pmu_events(const char *event_glob, bool name_only) if (is_cpu && !name_only) aliases[j] = format_alias_or(buf, sizeof(buf), pmu, alias); + aliases[j] = strdup(aliases[j]); j++; } -- 1.7.9.5