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,
zhangshaokun@hisilicon.com, Jonathan.Cameron@huawei.com,
Robert.Richter@cavium.com, gklkml16@gmail.com
Subject: [PATCH v8 1/4] perf utils: passing pmu as a parameter to function get_cpuid_str
Date: Thu, 12 Oct 2017 19:41:13 +0530 [thread overview]
Message-ID: <20171012141116.32475-2-ganapatrao.kulkarni@cavium.com> (raw)
In-Reply-To: <20171012141116.32475-1-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.
also optimise arguments to function pmu_add_cpu_aliases.
Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
---
| 2 +-
| 2 +-
| 3 ++-
tools/perf/util/pmu.c | 13 +++++++------
4 files changed, 11 insertions(+), 9 deletions(-)
--git a/tools/perf/arch/powerpc/util/header.c b/tools/perf/arch/powerpc/util/header.c
index 9aaa6f5..2953681 100644
--- a/tools/perf/arch/powerpc/util/header.c
+++ b/tools/perf/arch/powerpc/util/header.c
@@ -34,7 +34,7 @@ get_cpuid(char *buffer, size_t sz)
}
char *
-get_cpuid_str(void)
+get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
{
char *bufp;
--git a/tools/perf/arch/x86/util/header.c b/tools/perf/arch/x86/util/header.c
index a74a48d..d52bc27 100644
--- a/tools/perf/arch/x86/util/header.c
+++ b/tools/perf/arch/x86/util/header.c
@@ -65,7 +65,7 @@ get_cpuid(char *buffer, size_t sz)
}
char *
-get_cpuid_str(void)
+get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
{
char *buf = malloc(128);
--git a/tools/perf/util/header.h b/tools/perf/util/header.h
index f7a16ee..3de4be9 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 */
@@ -165,5 +166,5 @@ int write_padded(struct feat_fd *fd, const void *bf,
*/
int get_cpuid(char *buffer, size_t sz);
-char *get_cpuid_str(void);
+char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused);
#endif /* __PERF_HEADER_H */
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index ac16a9d..18edf86 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -511,7 +511,7 @@ 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 __maybe_unused)
{
return NULL;
}
@@ -521,19 +521,20 @@ 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, struct perf_pmu *pmu)
{
int i;
struct pmu_events_map *map;
struct pmu_event *pe;
char *cpuid;
static bool printed;
+ const char *name = pmu->name;
cpuid = getenv("PERF_CPUID");
if (cpuid)
cpuid = strdup(cpuid);
if (!cpuid)
- cpuid = get_cpuid_str();
+ cpuid = get_cpuid_str(pmu);
if (!cpuid)
return;
@@ -610,19 +611,19 @@ 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->name = strdup(name);
+ pmu->type = type;
+ pmu_add_cpu_aliases(&aliases, pmu);
INIT_LIST_HEAD(&pmu->format);
INIT_LIST_HEAD(&pmu->aliases);
list_splice(&format, &pmu->format);
list_splice(&aliases, &pmu->aliases);
- pmu->name = strdup(name);
- pmu->type = type;
list_add_tail(&pmu->list, &pmus);
pmu->default_config = perf_pmu__get_default_config(pmu);
--
2.9.4
next prev parent reply other threads:[~2017-10-12 14:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-12 14:11 [PATCH v8 0/4] Add support for ThunderX2 pmu events using json files Ganapatrao Kulkarni
2017-10-12 14:11 ` Ganapatrao Kulkarni [this message]
2017-10-12 14:11 ` [PATCH v8 2/4] perf tools arm64: Add support for get_cpuid_str function Ganapatrao Kulkarni
2017-10-12 14:11 ` [PATCH v8 3/4] perf utils: Add helper function is_pmu_core to detect PMU CORE devices Ganapatrao Kulkarni
2017-10-12 14:11 ` [PATCH v8 4/4] perf vendor events arm64: Add ThunderX2 implementation defined pmu core events Ganapatrao Kulkarni
2017-10-12 15:24 ` [PATCH v8 0/4] Add support for ThunderX2 pmu events using json files Will Deacon
2017-10-12 17:24 ` Ganapatrao Kulkarni
2017-10-13 9:11 ` Will Deacon
2017-10-13 13:04 ` Arnaldo Carvalho de Melo
2017-10-13 19:33 ` Arnaldo Carvalho de Melo
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=20171012141116.32475-2-ganapatrao.kulkarni@cavium.com \
--to=ganapatrao.kulkarni@cavium.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Robert.Richter@cavium.com \
--cc=Will.Deacon@arm.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=catalin.marinas@arm.com \
--cc=gklkml16@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 \
--cc=zhangshaokun@hisilicon.com \
/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).