linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: Will.Deacon@arm.com, catalin.marinas@arm.com,
	mark.rutland@arm.com, acme@kernel.org,
	alexander.shishkin@linux.intel.com, peterz@infradead.org,
	mingo@redhat.com, jnair@caviumnetworks.com, gpkulkarni@gmail.com
Subject: [PATCH v2 1/4] perf utils: passing pmu as a parameter to function get_cpuid_str
Date: Fri, 28 Apr 2017 10:23:44 +0530	[thread overview]
Message-ID: <1493355227-31492-2-git-send-email-ganapatrao.kulkarni@cavium.com> (raw)
In-Reply-To: <1493355227-31492-1-git-send-email-ganapatrao.kulkarni@cavium.com>

cpuid string will not be same on all CPUs on heterogeneous
platforms like ARM's big.LITTLE, adding provision(using pmu->cpus)
to find cpuid string from associated CPUs of PMU CORE device.

Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
---
 tools/perf/arch/powerpc/util/header.c |  3 ++-
 tools/perf/arch/x86/util/header.c     |  4 +++-
 tools/perf/util/header.h              |  3 ++-
 tools/perf/util/pmu.c                 | 10 ++++++----
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/tools/perf/arch/powerpc/util/header.c b/tools/perf/arch/powerpc/util/header.c
index 9aaa6f5..9a70cc1 100644
--- a/tools/perf/arch/powerpc/util/header.c
+++ b/tools/perf/arch/powerpc/util/header.c
@@ -34,10 +34,11 @@
 }
 
 char *
-get_cpuid_str(void)
+get_cpuid_str(struct perf_pmu *pmu)
 {
 	char *bufp;
 
+	do { if (pmu) {} } while (0);
 	if (asprintf(&bufp, "%.8lx", mfspr(SPRN_PVR)) < 0)
 		bufp = NULL;
 
diff --git a/tools/perf/arch/x86/util/header.c b/tools/perf/arch/x86/util/header.c
index a74a48d..1e240ca 100644
--- a/tools/perf/arch/x86/util/header.c
+++ b/tools/perf/arch/x86/util/header.c
@@ -65,10 +65,12 @@
 }
 
 char *
-get_cpuid_str(void)
+get_cpuid_str(struct perf_pmu *pmu)
 {
 	char *buf = malloc(128);
 
+	do { if (pmu) {} } while (0);
+
 	if (__get_cpuid(buf, 128, "%s-%u-%X$") < 0) {
 		free(buf);
 		return NULL;
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index d30109b..6bb14a4 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -8,6 +8,7 @@
 #include <linux/types.h>
 #include "event.h"
 #include "env.h"
+#include "pmu.h"
 
 enum {
 	HEADER_RESERVED		= 0,	/* always cleared */
@@ -151,5 +152,5 @@ int perf_event__process_build_id(struct perf_tool *tool,
  */
 int get_cpuid(char *buffer, size_t sz);
 
-char *get_cpuid_str(void);
+char *get_cpuid_str(struct perf_pmu *pmu);
 #endif /* __PERF_HEADER_H */
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 12f84dd..c754805 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -504,8 +504,9 @@ static struct cpu_map *pmu_cpumask(const char *name)
  * Each architecture should provide a more precise id string that
  * can be use to match the architecture's "mapfile".
  */
-char * __weak get_cpuid_str(void)
+char * __weak get_cpuid_str(struct perf_pmu *pmu)
 {
+	do { if (pmu) {} } while (0);
 	return NULL;
 }
 
@@ -514,7 +515,8 @@ char * __weak get_cpuid_str(void)
  * to the current running CPU. Then, add all PMU events from that table
  * as aliases.
  */
-static void pmu_add_cpu_aliases(struct list_head *head, const char *name)
+static void pmu_add_cpu_aliases(struct list_head *head, const char *name,
+		struct perf_pmu *pmu)
 {
 	int i;
 	struct pmu_events_map *map;
@@ -526,7 +528,7 @@ static void pmu_add_cpu_aliases(struct list_head *head, const char *name)
 	if (cpuid)
 		cpuid = strdup(cpuid);
 	if (!cpuid)
-		cpuid = get_cpuid_str();
+		cpuid = get_cpuid_str(pmu);
 	if (!cpuid)
 		return;
 
@@ -601,12 +603,12 @@ static struct perf_pmu *pmu_lookup(const char *name)
 	if (pmu_aliases(name, &aliases))
 		return NULL;
 
-	pmu_add_cpu_aliases(&aliases, name);
 	pmu = zalloc(sizeof(*pmu));
 	if (!pmu)
 		return NULL;
 
 	pmu->cpus = pmu_cpumask(name);
+	pmu_add_cpu_aliases(&aliases, name, pmu);
 
 	INIT_LIST_HEAD(&pmu->format);
 	INIT_LIST_HEAD(&pmu->aliases);
-- 
1.8.1.4

  reply	other threads:[~2017-04-28  4:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28  4:53 [PATCH v2 0/4] Add support for ThunderX2 pmu events using json files Ganapatrao Kulkarni
2017-04-28  4:53 ` Ganapatrao Kulkarni [this message]
2017-04-28  9:08   ` [PATCH v2 1/4] perf utils: passing pmu as a parameter to function get_cpuid_str Jayachandran C
2017-04-28  9:19     ` Ganapatrao Kulkarni
2017-04-28  4:53 ` [PATCH v2 2/4] perf tools arm64: Add support for get_cpuid_str function Ganapatrao Kulkarni
2017-04-28  4:53 ` [PATCH v2 3/4] perf utils: Add helper function is_pmu_core to detect PMU CORE devices Ganapatrao Kulkarni
2017-04-28  4:53 ` [PATCH v2 4/4] perf vendor events arm64: Add implementation defined pmu core events of ThunderX2 Ganapatrao Kulkarni
2017-04-28 17:20   ` Will Deacon
2017-05-02  8:27     ` Ganapatrao Kulkarni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1493355227-31492-2-git-send-email-ganapatrao.kulkarni@cavium.com \
    --to=ganapatrao.kulkarni@cavium.com \
    --cc=Will.Deacon@arm.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=catalin.marinas@arm.com \
    --cc=gpkulkarni@gmail.com \
    --cc=jnair@caviumnetworks.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).