]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
perf pmu: Pass pmu as a parameter to get_cpuid_str()
authorGanapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
Wed, 7 Feb 2018 00:07:00 +0000 (01:07 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 14 Mar 2018 10:42:23 +0000 (11:42 +0100)
BugLink: https://bugs.launchpad.net/bugs/1747523
The 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>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Jayachandran C <jnair@caviumnetworks.com>
Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Robert Richter <robert.richter@cavium.com>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
Link: http://lkml.kernel.org/r/20171016183222.25750-2-ganapatrao.kulkarni@cavium.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
(backported from commit 54e32dc0f89ec7fcb87df6c45b096e57f050f22b)
[ dannf: Drop changes tools/perf/util/metricgroup.c, which didn't exist yet ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
tools/perf/arch/powerpc/util/header.c
tools/perf/arch/x86/util/header.c
tools/perf/util/header.h
tools/perf/util/pmu.c
tools/perf/util/pmu.h

index 9aaa6f5a93479f107c83123febfe8f8a8a59b63e..2953681394e981d0ccc4d95a319e50d7be93339b 100644 (file)
@@ -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;
 
index a74a48db26f5e59186636ce74c803a3c6b476dbc..d52bc2755e21378bda1ae932eb3a740d909dd5c5 100644 (file)
@@ -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);
 
index d30109b421eef0efb6820e8c8cc036a53dbb7ff3..05e57584b9f3b80a22d488e5717d8e3052d670b7 100644 (file)
@@ -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 write_padded(int fd, const void *bf, size_t count, size_t count_aligned);
  */
 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 */
index 0cd082c1450dc692065916b292bab148f04427b3..6dbec11b4effe4e25acf7a0433a92872bf4f6db0 100644 (file)
@@ -535,12 +535,12 @@ static bool pmu_is_uncore(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;
 }
 
-static char *perf_pmu__getcpuid(void)
+static char *perf_pmu__getcpuid(struct perf_pmu *pmu)
 {
        char *cpuid;
        static bool printed;
@@ -549,7 +549,7 @@ static char *perf_pmu__getcpuid(void)
        if (cpuid)
                cpuid = strdup(cpuid);
        if (!cpuid)
-               cpuid = get_cpuid_str();
+               cpuid = get_cpuid_str(pmu);
        if (!cpuid)
                return NULL;
 
@@ -560,10 +560,10 @@ static char *perf_pmu__getcpuid(void)
        return cpuid;
 }
 
-struct pmu_events_map *perf_pmu__find_map(void)
+struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
 {
        struct pmu_events_map *map;
-       char *cpuid = perf_pmu__getcpuid();
+       char *cpuid = perf_pmu__getcpuid(pmu);
        int i;
 
        i = 0;
@@ -586,13 +586,14 @@ struct pmu_events_map *perf_pmu__find_map(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;
+       const char *name = pmu->name;
 
-       map = perf_pmu__find_map();
+       map = perf_pmu__find_map(pmu);
        if (!map)
                return;
 
@@ -651,21 +652,20 @@ 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->is_uncore = pmu_is_uncore(name);
+       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);
index 7ca675598b43a1d5cda8686969c426edf2db1ce4..abc472828f635a1b5847e1d6779b1e223353aa02 100644 (file)
@@ -91,6 +91,6 @@ int perf_pmu__test(void);
 
 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
 
-struct pmu_events_map *perf_pmu__find_map(void);
+struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu);
 
 #endif /* __PMU_H */