Skip to contentSkip to conversation

tools/perf: Fix perf test 7 Simple expression parser on s390

PATCH Applied Thomas Richter 3 participants 4 messages Nov 24, 2021 – Jan 14, 2022 perf events

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/perf: Fix perf test 7 Simple expression parser on s390

Commit fdf1e29b6118 ("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
 #
Cc: Ian Rogers <[email protected]>
Fixes: fdf1e29b6118 ("perf expr: Add metric literals for topology.")
---
 tools/perf/util/cputopo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/cputopo.c +2 -1
index 51b429c86f98..aad7a9e6e31b 100644
@@ -165,7 +165,8 @@ static bool has_die_topology(void)
 	if (uname(&uts) < 0)
 		return false;
 
-	if (strncmp(uts.machine, "x86_64", 6))
+	if (strncmp(uts.machine, "x86_64", 6) &&
+	    strncmp(uts.machine, "s390x", 5))
 		return false;
 
 	scnprintf(filename, MAXPATHLEN, DIE_CPUS_FMT,
Signature · 1 line
2.31.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 43 lines · Thomas Richter

Commit fdf1e29b6118 ("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
 #
Cc: Ian Rogers <[email protected]>
Fixes: fdf1e29b6118 ("perf expr: Add metric literals for topology.")
Quoted 1 line

Thanks!
Ian

Quoted 21 lines
---
 tools/perf/util/cputopo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/cputopo.c +2 -2
index 51b429c86f98..aad7a9e6e31b 100644
@@ -165,7 +165,8 @@ static bool has_die_topology(void)
        if (uname(&uts) < 0)
                return false;
 
-       if (strncmp(uts.machine, "x86_64", 6))
+       if (strncmp(uts.machine, "x86_64", 6) &&
+           strncmp(uts.machine, "s390x", 5))
                return false;
 
        scnprintf(filename, MAXPATHLEN, DIE_CPUS_FMT,
--

2.31.1

maintainer Applied
#2 lore raw

Em Wed, Nov 24, 2021 at 07:41:40AM -0800, Ian Rogers escreveu:

Quoted 15 lines · Thomas Richter
Quoted 13 lines

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
 #
Cc: Ian Rogers <[email protected]>
Fixes: fdf1e29b6118 ("perf expr: Add metric literals for topology.")
Quoted 3 lines
Quoted 1 line

Thanks, applied.

- Arnaldo

maintainer Applied
#3 lore raw
In reply to Ian Rogers

Em Wed, Nov 24, 2021 at 07:41:40AM -0800, Ian Rogers escreveu:

Quoted 24 lines · Thomas Richter
Quoted 23 lines

Commit fdf1e29b6118 ("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;
           ....
        }
Quoted 7 lines
Quoted 7 lines

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.

Thanks, applied.

- Arnaldo

Quoted 40 lines
Quoted 12 lines

Output after:

 # ./perf test -Fv 7
  7: Simple expression parser                                        :
  --- start ---
  division by zero
  syntax error
  ---- end ----
  Simple expression parser: Ok
 #
Cc: Ian Rogers <[email protected]>
Fixes: fdf1e29b6118 ("perf expr: Add metric literals for topology.")
Quoted 1 line

Thanks!
Ian

Quoted 21 lines
---
 tools/perf/util/cputopo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/cputopo.c +2 -2
index 51b429c86f98..aad7a9e6e31b 100644
@@ -165,7 +165,8 @@ static bool has_die_topology(void)
        if (uname(&uts) < 0)
                return false;
 
-       if (strncmp(uts.machine, "x86_64", 6))
+       if (strncmp(uts.machine, "x86_64", 6) &&
+           strncmp(uts.machine, "s390x", 5))
                return false;
 
        scnprintf(filename, MAXPATHLEN, DIE_CPUS_FMT,
--

2.31.1

Signature · 1 line
- Arnaldo