linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/perf: Fix perf test 7 Simple expression parser on s390
@ 2021-11-24  9:03 Thomas Richter
  2021-11-24 15:41 ` Ian Rogers
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Richter @ 2021-11-24  9:03 UTC (permalink / raw)
  To: linux-kernel, linux-perf-users, acme, irogers
  Cc: svens, gor, sumanthk, hca, 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 <irogers@google.com>
Fixes: fdf1e29b6118 ("perf expr: Add metric literals for topology.")

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
---
 tools/perf/util/cputopo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/cputopo.c b/tools/perf/util/cputopo.c
index 51b429c86f98..aad7a9e6e31b 100644
--- a/tools/perf/util/cputopo.c
+++ b/tools/perf/util/cputopo.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/perf: Fix perf test 7 Simple expression parser on s390
  2021-11-24  9:03 [PATCH] tools/perf: Fix perf test 7 Simple expression parser on s390 Thomas Richter
@ 2021-11-24 15:41 ` Ian Rogers
  2021-11-25  1:06   ` Arnaldo Carvalho de Melo
  2022-01-14 14:51   ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 4+ messages in thread
From: Ian Rogers @ 2021-11-24 15:41 UTC (permalink / raw)
  To: Thomas Richter
  Cc: linux-kernel, linux-perf-users, acme, svens, gor, sumanthk, hca

On Wed, Nov 24, 2021 at 1:04 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
>
> 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 <irogers@google.com>
> Fixes: fdf1e29b6118 ("perf expr: Add metric literals for topology.")
>
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks!
Ian

> ---
>  tools/perf/util/cputopo.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/cputopo.c b/tools/perf/util/cputopo.c
> index 51b429c86f98..aad7a9e6e31b 100644
> --- a/tools/perf/util/cputopo.c
> +++ b/tools/perf/util/cputopo.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/perf: Fix perf test 7 Simple expression parser on s390
  2021-11-24 15:41 ` Ian Rogers
@ 2021-11-25  1:06   ` Arnaldo Carvalho de Melo
  2022-01-14 14:51   ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-11-25  1:06 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Thomas Richter, linux-kernel, linux-perf-users, svens, gor,
	sumanthk, hca

Em Wed, Nov 24, 2021 at 07:41:40AM -0800, Ian Rogers escreveu:
> On Wed, Nov 24, 2021 at 1:04 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
> > 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 <irogers@google.com>
> > Fixes: fdf1e29b6118 ("perf expr: Add metric literals for topology.")

> > Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>

> Reviewed-by: Ian Rogers <irogers@google.com>

Thanks, applied.

- Arnaldo


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/perf: Fix perf test 7 Simple expression parser on s390
  2021-11-24 15:41 ` Ian Rogers
  2021-11-25  1:06   ` Arnaldo Carvalho de Melo
@ 2022-01-14 14:51   ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-01-14 14:51 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Thomas Richter, linux-kernel, linux-perf-users, svens, gor,
	sumanthk, hca

Em Wed, Nov 24, 2021 at 07:41:40AM -0800, Ian Rogers escreveu:
> On Wed, Nov 24, 2021 at 1:04 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
> >
> > 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.

Thanks, applied.

- Arnaldo


> > Output after:
> >  # ./perf test -Fv 7
> >   7: Simple expression parser                                        :
> >   --- start ---
> >   division by zero
> >   syntax error
> >   ---- end ----
> >   Simple expression parser: Ok
> >  #
> > Cc: Ian Rogers <irogers@google.com>
> > Fixes: fdf1e29b6118 ("perf expr: Add metric literals for topology.")
> >
> > Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> 
> Reviewed-by: Ian Rogers <irogers@google.com>
> 
> Thanks!
> Ian
> 
> > ---
> >  tools/perf/util/cputopo.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/cputopo.c b/tools/perf/util/cputopo.c
> > index 51b429c86f98..aad7a9e6e31b 100644
> > --- a/tools/perf/util/cputopo.c
> > +++ b/tools/perf/util/cputopo.c
> > @@ -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
> >

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-14 14:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24  9:03 [PATCH] tools/perf: Fix perf test 7 Simple expression parser on s390 Thomas Richter
2021-11-24 15:41 ` Ian Rogers
2021-11-25  1:06   ` Arnaldo Carvalho de Melo
2022-01-14 14:51   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).