Skip to content

Commit cec0d65

Browse files
captain5050acmel
authored andcommitted
perf header: Refactor get_cpuid to take a CPU for ARM
ARM BIG.little has no notion of a constant CPUID for both core types. To reflect this reality, change the get_cpuid function to also pass in a possibly unused logical cpu. If the dummy value (-1) is passed in then ARM can, as currently happens, select the first logical CPU's "CPUID". The changes to ARM getcpuid happen in a follow up change. Reviewed-by: James Clark <james.clark@linaro.org> Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Xu Yang <xu.yang_2@nxp.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexandre Ghiti <alexghiti@rivosinc.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Ben Zong-You Xie <ben717@andestech.com> Cc: Benjamin Gray <bgray@linux.ibm.com> Cc: Bibo Mao <maobibo@loongson.cn> Cc: Clément Le Goffic <clement.legoffic@foss.st.com> Cc: Dima Kogan <dima@secretsauce.net> Cc: Dr. David Alan Gilbert <linux@treblig.org> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linux.dev> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Will Deacon <will@kernel.org> Cc: Yicong Yang <yangyicong@hisilicon.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-riscv@lists.infradead.org Link: https://lore.kernel.org/r/20241107162035.52206-4-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent c6fafe3 commit cec0d65

File tree

11 files changed

+19
-14
lines changed

11 files changed

+19
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static int _get_cpuid(char *buf, size_t sz, struct perf_cpu_map *cpus)
5050
return ret;
5151
}
5252

53-
int get_cpuid(char *buf, size_t sz)
53+
int get_cpuid(char *buf, size_t sz, struct perf_cpu cpu __maybe_unused)
5454
{
5555
struct perf_cpu_map *cpus = perf_cpu_map__new_online_cpus();
5656
int ret;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static char *_get_cpuid(void)
7070
return cpuid;
7171
}
7272

73-
int get_cpuid(char *buffer, size_t sz)
73+
int get_cpuid(char *buffer, size_t sz, struct perf_cpu cpu __maybe_unused)
7474
{
7575
int ret = 0;
7676
char *cpuid = _get_cpuid();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static bool is_compat_mode(void)
2424
}
2525

2626
int
27-
get_cpuid(char *buffer, size_t sz)
27+
get_cpuid(char *buffer, size_t sz, struct perf_cpu cpu __maybe_unused)
2828
{
2929
unsigned long pvr;
3030
int nb;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static char *_get_cpuid(void)
8181
return cpuid;
8282
}
8383

84-
int get_cpuid(char *buffer, size_t sz)
84+
int get_cpuid(char *buffer, size_t sz, struct perf_cpu cpu __maybe_unused)
8585
{
8686
char *cpuid = _get_cpuid();
8787
int ret = 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define SYSINFO "/proc/sysinfo"
2828
#define SRVLVL "/proc/service_levels"
2929

30-
int get_cpuid(char *buffer, size_t sz)
30+
int get_cpuid(char *buffer, size_t sz, struct perf_cpu cpu __maybe_unused)
3131
{
3232
char *cp, *line = NULL, *line2;
3333
char type[8], model[33], version[8], manufacturer[32], authorization[8];

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ struct auxtrace_record *auxtrace_record__init(struct evlist *evlist,
5555
int *err)
5656
{
5757
char buffer[64];
58+
struct perf_cpu cpu = perf_cpu_map__min(evlist->core.all_cpus);
5859
int ret;
5960

6061
*err = 0;
6162

62-
ret = get_cpuid(buffer, sizeof(buffer));
63+
ret = get_cpuid(buffer, sizeof(buffer), cpu);
6364
if (ret) {
6465
*err = ret;
6566
return NULL;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ __get_cpuid(char *buffer, size_t sz, const char *fmt)
5858
}
5959

6060
int
61-
get_cpuid(char *buffer, size_t sz)
61+
get_cpuid(char *buffer, size_t sz, struct perf_cpu cpu __maybe_unused)
6262
{
6363
return __get_cpuid(buffer, sz, "%s,%u,%u,%u$");
6464
}

tools/perf/builtin-kvm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,9 @@ static int cpu_isa_config(struct perf_kvm_stat *kvm)
12261226
int err;
12271227

12281228
if (kvm->live) {
1229-
err = get_cpuid(buf, sizeof(buf));
1229+
struct perf_cpu cpu = {-1};
1230+
1231+
err = get_cpuid(buf, sizeof(buf), cpu);
12301232
if (err != 0) {
12311233
pr_err("Failed to look up CPU type: %s\n",
12321234
str_error_r(err, buf, sizeof(buf)));

tools/perf/util/env.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ int perf_env__read_pmu_mappings(struct perf_env *env)
373373
int perf_env__read_cpuid(struct perf_env *env)
374374
{
375375
char cpuid[128];
376-
int err = get_cpuid(cpuid, sizeof(cpuid));
376+
struct perf_cpu cpu = {-1};
377+
int err = get_cpuid(cpuid, sizeof(cpuid), cpu);
377378

378379
if (err)
379380
return err;

tools/perf/util/header.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -856,18 +856,19 @@ int __weak strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
856856
* default get_cpuid(): nothing gets recorded
857857
* actual implementation must be in arch/$(SRCARCH)/util/header.c
858858
*/
859-
int __weak get_cpuid(char *buffer __maybe_unused, size_t sz __maybe_unused)
859+
int __weak get_cpuid(char *buffer __maybe_unused, size_t sz __maybe_unused,
860+
struct perf_cpu cpu __maybe_unused)
860861
{
861862
return ENOSYS; /* Not implemented */
862863
}
863864

864-
static int write_cpuid(struct feat_fd *ff,
865-
struct evlist *evlist __maybe_unused)
865+
static int write_cpuid(struct feat_fd *ff, struct evlist *evlist)
866866
{
867+
struct perf_cpu cpu = perf_cpu_map__min(evlist->core.all_cpus);
867868
char buffer[64];
868869
int ret;
869870

870-
ret = get_cpuid(buffer, sizeof(buffer));
871+
ret = get_cpuid(buffer, sizeof(buffer), cpu);
871872
if (ret)
872873
return -1;
873874

0 commit comments

Comments
 (0)