Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>

authored by

Ganapatrao Kulkarni and committed by
Arnaldo Carvalho de Melo
54e32dc0 1dc4ddf1

+18 -17
+1 -1
tools/perf/arch/powerpc/util/header.c
··· 35 35 } 36 36 37 37 char * 38 - get_cpuid_str(void) 38 + get_cpuid_str(struct perf_pmu *pmu __maybe_unused) 39 39 { 40 40 char *bufp; 41 41
+1 -1
tools/perf/arch/x86/util/header.c
··· 66 66 } 67 67 68 68 char * 69 - get_cpuid_str(void) 69 + get_cpuid_str(struct perf_pmu *pmu __maybe_unused) 70 70 { 71 71 char *buf = malloc(128); 72 72
+2 -1
tools/perf/util/header.h
··· 9 9 #include <linux/types.h> 10 10 #include "event.h" 11 11 #include "env.h" 12 + #include "pmu.h" 12 13 13 14 enum { 14 15 HEADER_RESERVED = 0, /* always cleared */ ··· 172 171 */ 173 172 int get_cpuid(char *buffer, size_t sz); 174 173 175 - char *get_cpuid_str(void); 174 + char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused); 176 175 #endif /* __PERF_HEADER_H */
+2 -2
tools/perf/util/metricgroup.c
··· 274 274 void metricgroup__print(bool metrics, bool metricgroups, char *filter, 275 275 bool raw) 276 276 { 277 - struct pmu_events_map *map = perf_pmu__find_map(); 277 + struct pmu_events_map *map = perf_pmu__find_map(NULL); 278 278 struct pmu_event *pe; 279 279 int i; 280 280 struct rblist groups; ··· 372 372 static int metricgroup__add_metric(const char *metric, struct strbuf *events, 373 373 struct list_head *group_list) 374 374 { 375 - struct pmu_events_map *map = perf_pmu__find_map(); 375 + struct pmu_events_map *map = perf_pmu__find_map(NULL); 376 376 struct pmu_event *pe; 377 377 int ret = -EINVAL; 378 378 int i, j;
+11 -11
tools/perf/util/pmu.c
··· 542 542 * Each architecture should provide a more precise id string that 543 543 * can be use to match the architecture's "mapfile". 544 544 */ 545 - char * __weak get_cpuid_str(void) 545 + char * __weak get_cpuid_str(struct perf_pmu *pmu __maybe_unused) 546 546 { 547 547 return NULL; 548 548 } 549 549 550 - static char *perf_pmu__getcpuid(void) 550 + static char *perf_pmu__getcpuid(struct perf_pmu *pmu) 551 551 { 552 552 char *cpuid; 553 553 static bool printed; ··· 556 556 if (cpuid) 557 557 cpuid = strdup(cpuid); 558 558 if (!cpuid) 559 - cpuid = get_cpuid_str(); 559 + cpuid = get_cpuid_str(pmu); 560 560 if (!cpuid) 561 561 return NULL; 562 562 ··· 567 567 return cpuid; 568 568 } 569 569 570 - struct pmu_events_map *perf_pmu__find_map(void) 570 + struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) 571 571 { 572 572 struct pmu_events_map *map; 573 - char *cpuid = perf_pmu__getcpuid(); 573 + char *cpuid = perf_pmu__getcpuid(pmu); 574 574 int i; 575 575 576 576 i = 0; ··· 593 593 * to the current running CPU. Then, add all PMU events from that table 594 594 * as aliases. 595 595 */ 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) 597 597 { 598 598 int i; 599 599 struct pmu_events_map *map; 600 600 struct pmu_event *pe; 601 + const char *name = pmu->name; 601 602 602 - map = perf_pmu__find_map(); 603 + map = perf_pmu__find_map(pmu); 603 604 if (!map) 604 605 return; 605 606 ··· 662 661 if (pmu_aliases(name, &aliases)) 663 662 return NULL; 664 663 665 - pmu_add_cpu_aliases(&aliases, name); 666 664 pmu = zalloc(sizeof(*pmu)); 667 665 if (!pmu) 668 666 return NULL; 669 667 670 668 pmu->cpus = pmu_cpumask(name); 671 - 669 + pmu->name = strdup(name); 670 + pmu->type = type; 672 671 pmu->is_uncore = pmu_is_uncore(name); 672 + pmu_add_cpu_aliases(&aliases, pmu); 673 673 674 674 INIT_LIST_HEAD(&pmu->format); 675 675 INIT_LIST_HEAD(&pmu->aliases); 676 676 list_splice(&format, &pmu->format); 677 677 list_splice(&aliases, &pmu->aliases); 678 - pmu->name = strdup(name); 679 - pmu->type = type; 680 678 list_add_tail(&pmu->list, &pmus); 681 679 682 680 pmu->default_config = perf_pmu__get_default_config(pmu);
+1 -1
tools/perf/util/pmu.h
··· 92 92 93 93 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu); 94 94 95 - struct pmu_events_map *perf_pmu__find_map(void); 95 + struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu); 96 96 97 97 #endif /* __PMU_H */