Skip to content

Commit 54e32dc

Browse files
Ganapatrao Kulkarniacmel
authored andcommitted
perf pmu: Pass pmu as a parameter to get_cpuid_str()
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 <[email protected]> Acked-by: Will Deacon <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Jayachandran C <[email protected]> Cc: Jonathan Cameron <[email protected]> Cc: [email protected] Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Robert Richter <[email protected]> Cc: Shaokun Zhang <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 1dc4ddf commit 54e32dc

File tree

6 files changed

+18
-17
lines changed

6 files changed

+18
-17
lines changed

tools/perf/arch/powerpc/util/header.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ get_cpuid(char *buffer, size_t sz)
3535
}
3636

3737
char *
38-
get_cpuid_str(void)
38+
get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
3939
{
4040
char *bufp;
4141

tools/perf/arch/x86/util/header.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ get_cpuid(char *buffer, size_t sz)
6666
}
6767

6868
char *
69-
get_cpuid_str(void)
69+
get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
7070
{
7171
char *buf = malloc(128);
7272

tools/perf/util/header.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/types.h>
1010
#include "event.h"
1111
#include "env.h"
12+
#include "pmu.h"
1213

1314
enum {
1415
HEADER_RESERVED = 0, /* always cleared */
@@ -171,5 +172,5 @@ int write_padded(struct feat_fd *fd, const void *bf,
171172
*/
172173
int get_cpuid(char *buffer, size_t sz);
173174

174-
char *get_cpuid_str(void);
175+
char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused);
175176
#endif /* __PERF_HEADER_H */

tools/perf/util/metricgroup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static void metricgroup__print_strlist(struct strlist *metrics, bool raw)
274274
void metricgroup__print(bool metrics, bool metricgroups, char *filter,
275275
bool raw)
276276
{
277-
struct pmu_events_map *map = perf_pmu__find_map();
277+
struct pmu_events_map *map = perf_pmu__find_map(NULL);
278278
struct pmu_event *pe;
279279
int i;
280280
struct rblist groups;
@@ -372,7 +372,7 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter,
372372
static int metricgroup__add_metric(const char *metric, struct strbuf *events,
373373
struct list_head *group_list)
374374
{
375-
struct pmu_events_map *map = perf_pmu__find_map();
375+
struct pmu_events_map *map = perf_pmu__find_map(NULL);
376376
struct pmu_event *pe;
377377
int ret = -EINVAL;
378378
int i, j;

tools/perf/util/pmu.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,12 @@ static bool pmu_is_uncore(const char *name)
542542
* Each architecture should provide a more precise id string that
543543
* can be use to match the architecture's "mapfile".
544544
*/
545-
char * __weak get_cpuid_str(void)
545+
char * __weak get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
546546
{
547547
return NULL;
548548
}
549549

550-
static char *perf_pmu__getcpuid(void)
550+
static char *perf_pmu__getcpuid(struct perf_pmu *pmu)
551551
{
552552
char *cpuid;
553553
static bool printed;
@@ -556,7 +556,7 @@ static char *perf_pmu__getcpuid(void)
556556
if (cpuid)
557557
cpuid = strdup(cpuid);
558558
if (!cpuid)
559-
cpuid = get_cpuid_str();
559+
cpuid = get_cpuid_str(pmu);
560560
if (!cpuid)
561561
return NULL;
562562

@@ -567,10 +567,10 @@ static char *perf_pmu__getcpuid(void)
567567
return cpuid;
568568
}
569569

570-
struct pmu_events_map *perf_pmu__find_map(void)
570+
struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
571571
{
572572
struct pmu_events_map *map;
573-
char *cpuid = perf_pmu__getcpuid();
573+
char *cpuid = perf_pmu__getcpuid(pmu);
574574
int i;
575575

576576
i = 0;
@@ -593,13 +593,14 @@ struct pmu_events_map *perf_pmu__find_map(void)
593593
* to the current running CPU. Then, add all PMU events from that table
594594
* as aliases.
595595
*/
596-
static void pmu_add_cpu_aliases(struct list_head *head, const char *name)
596+
static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
597597
{
598598
int i;
599599
struct pmu_events_map *map;
600600
struct pmu_event *pe;
601+
const char *name = pmu->name;
601602

602-
map = perf_pmu__find_map();
603+
map = perf_pmu__find_map(pmu);
603604
if (!map)
604605
return;
605606

@@ -661,21 +662,20 @@ static struct perf_pmu *pmu_lookup(const char *name)
661662
if (pmu_aliases(name, &aliases))
662663
return NULL;
663664

664-
pmu_add_cpu_aliases(&aliases, name);
665665
pmu = zalloc(sizeof(*pmu));
666666
if (!pmu)
667667
return NULL;
668668

669669
pmu->cpus = pmu_cpumask(name);
670-
670+
pmu->name = strdup(name);
671+
pmu->type = type;
671672
pmu->is_uncore = pmu_is_uncore(name);
673+
pmu_add_cpu_aliases(&aliases, pmu);
672674

673675
INIT_LIST_HEAD(&pmu->format);
674676
INIT_LIST_HEAD(&pmu->aliases);
675677
list_splice(&format, &pmu->format);
676678
list_splice(&aliases, &pmu->aliases);
677-
pmu->name = strdup(name);
678-
pmu->type = type;
679679
list_add_tail(&pmu->list, &pmus);
680680

681681
pmu->default_config = perf_pmu__get_default_config(pmu);

tools/perf/util/pmu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ int perf_pmu__test(void);
9292

9393
struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
9494

95-
struct pmu_events_map *perf_pmu__find_map(void);
95+
struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu);
9696

9797
#endif /* __PMU_H */

0 commit comments

Comments
 (0)