Skip to content

Commit f6a66ff

Browse files
athira-rajeevnamhyung
authored andcommitted
tools/perf/arch/powerpc: Fix the CPU ID const char* value by adding 0x prefix
Simple expression parser test fails in powerpc as below: 4: Simple expression parser test child forked, pid 170385 Using CPUID 004e2102 division by zero syntax error syntax error FAILED tests/expr.c:65 parse test failed test child finished with -1 Simple expression parser: FAILED! This is observed after commit: 'commit 9d5da30 ("perf jevents: Add a new expression builtin strcmp_cpuid_str()")' With this commit, a new expression builtin strcmp_cpuid_str got added. This function takes an 'ID' type value, which is a string. So expression parse for strcmp_cpuid_str expects const char * as cpuid value type. In case of powerpc, CPU IDs are numbers. Hence it doesn't get interpreted correctly by bison parser. Example in case of power9, cpuid string returns as: 004e2102 cpuid of string type is expected in two cases: 1. char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused); Testcase "tests/expr.c" uses "perf_pmu__getcpuid" which calls get_cpuid_str to get the cpuid string. 2. cpuid field in :struct pmu_events_map struct pmu_events_map { const char *arch; const char *cpuid; Here cpuid field is used in "perf_pmu__find_events_table" function as "strcmp_cpuid_str(map->cpuid, cpuid)". The value for cpuid field is picked from mapfile.csv. Fix the mapfile.csv and get_cpuid_str function to prefix cpuid with 0x so that it gets correctly interpreted by the bison parser Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Tested-by: Disha Goel<disgoel@linux.ibm.com> Cc: kjain@linux.ibm.com Cc: maddy@linux.ibm.com Cc: disgoel@linux.vnet.ibm.com Cc: linuxppc-dev@lists.ozlabs.org Link: https://lore.kernel.org/r/20231009050052.64935-1-atrajeev@linux.vnet.ibm.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 78efa7b commit f6a66ff

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
3434
{
3535
char *bufp;
3636

37-
if (asprintf(&bufp, "%.8lx", mfspr(SPRN_PVR)) < 0)
37+
if (asprintf(&bufp, "0x%.8lx", mfspr(SPRN_PVR)) < 0)
3838
bufp = NULL;
3939

4040
return bufp;

tools/perf/pmu-events/arch/powerpc/mapfile.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
#
1414

1515
# Power8 entries
16-
004[bcd][[:xdigit:]]{4},1,power8,core
17-
004e[[:xdigit:]]{4},1,power9,core
18-
0080[[:xdigit:]]{4},1,power10,core
16+
0x004[bcd][[:xdigit:]]{4},1,power8,core
17+
0x004e[[:xdigit:]]{4},1,power9,core
18+
0x0080[[:xdigit:]]{4},1,power10,core

0 commit comments

Comments
 (0)