Skip to content

Commit a6e6274

Browse files
Thomas Richteracmel
authored andcommitted
perf cputopo: Fix CPU topology reading on s/390
Commit fdf1e29 ("perf expr: Add metric literals for topology.") fails on s390: # ./perf test -Fv 7 ... # FAILED tests/expr.c:173 #num_dies >= #num_packages ---- end ---- Simple expression parser: FAILED! # Investigating this issue leads to these functions: build_cpu_topology() +--> has_die_topology(void) { struct utsname uts; if (uname(&uts) < 0) return false; if (strncmp(uts.machine, "x86_64", 6)) return false; .... } which always returns false on s390. The caller build_cpu_topology() checks has_die_topology() return value. On false the the struct cpu_topology::die_cpu_list is not contructed and has zero entries. This leads to the failing comparison: #num_dies >= #num_packages. s390 of course has a positive number of packages. Fix this by adding s390 architecture to support CPU die list. Output after: # ./perf test -Fv 7 7: Simple expression parser : --- start --- division by zero syntax error ---- end ---- Simple expression parser: Ok # Fixes: fdf1e29 ("perf expr: Add metric literals for topology.") Reviewed-by: Ian Rogers <[email protected]> Signed-off-by: Thomas Richter <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Sumanth Korikkar <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Vasily Gorbik <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent e000ea0 commit a6e6274

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/perf/util/cputopo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ static bool has_die_topology(void)
165165
if (uname(&uts) < 0)
166166
return false;
167167

168-
if (strncmp(uts.machine, "x86_64", 6))
168+
if (strncmp(uts.machine, "x86_64", 6) &&
169+
strncmp(uts.machine, "s390x", 5))
169170
return false;
170171

171172
scnprintf(filename, MAXPATHLEN, DIE_CPUS_FMT,

0 commit comments

Comments
 (0)