linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf beauty: Reuse the generic switch.
@ 2021-05-13  6:04 Ian Rogers
  2021-05-27 15:52 ` Ian Rogers
  2021-07-27 15:08 ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 4+ messages in thread
From: Ian Rogers @ 2021-05-13  6:04 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-perf-users, linux-kernel
  Cc: Ian Rogers

Previously the code would see if, for example,
tools/perf/arch/arm/include/uapi/asm/errno.h exists and if not generate
a "generic" switch statement using the asm-generic/errno.h. This creates
multiple identical "generic" switch statements before the default
generic switch statement for an unknown architecture. By simplifying the
archlist to be only for architectures that are not "generic" the amount
of generated code can be reduced from 14 down to 6 functions.

Remove the special case of x86, instead reverse the architecture names
so that it comes first.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/trace/beauty/arch_errno_names.sh | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tools/perf/trace/beauty/arch_errno_names.sh b/tools/perf/trace/beauty/arch_errno_names.sh
index 9f9ea45cddc4..2c5f72fa8108 100755
--- a/tools/perf/trace/beauty/arch_errno_names.sh
+++ b/tools/perf/trace/beauty/arch_errno_names.sh
@@ -87,14 +87,13 @@ cat <<EoHEADER
 
 EoHEADER
 
-# Create list of architectures and ignore those that do not appear
-# in tools/perf/arch
+# Create list of architectures that have a specific errno.h.
 archlist=""
-for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | grep -v x86 | sort); do
-	test -d $toolsdir/perf/arch/$arch && archlist="$archlist $arch"
+for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | sort -r); do
+	test -f $toolsdir/arch/$arch/include/uapi/asm/errno.h && archlist="$archlist $arch"
 done
 
-for arch in x86 $archlist generic; do
+for arch in generic $archlist; do
 	process_arch "$arch"
 done
-create_arch_errno_table_func "x86 $archlist" "generic"
+create_arch_errno_table_func "$archlist" "generic"
-- 
2.31.1.751.gd2f1c929bd-goog


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

* Re: [PATCH] perf beauty: Reuse the generic switch.
  2021-05-13  6:04 [PATCH] perf beauty: Reuse the generic switch Ian Rogers
@ 2021-05-27 15:52 ` Ian Rogers
  2021-07-26 21:53   ` Ian Rogers
  2021-07-27 15:08 ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Rogers @ 2021-05-27 15:52 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-perf-users, LKML, Riccardo Mancini

On Wed, May 12, 2021 at 11:04 PM Ian Rogers <irogers@google.com> wrote:
>
> Previously the code would see if, for example,
> tools/perf/arch/arm/include/uapi/asm/errno.h exists and if not generate
> a "generic" switch statement using the asm-generic/errno.h. This creates
> multiple identical "generic" switch statements before the default
> generic switch statement for an unknown architecture. By simplifying the
> archlist to be only for architectures that are not "generic" the amount
> of generated code can be reduced from 14 down to 6 functions.
>
> Remove the special case of x86, instead reverse the architecture names
> so that it comes first.
>
> Signed-off-by: Ian Rogers <irogers@google.com>

Ping.

Thanks!
Ian

> ---
>  tools/perf/trace/beauty/arch_errno_names.sh | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/trace/beauty/arch_errno_names.sh b/tools/perf/trace/beauty/arch_errno_names.sh
> index 9f9ea45cddc4..2c5f72fa8108 100755
> --- a/tools/perf/trace/beauty/arch_errno_names.sh
> +++ b/tools/perf/trace/beauty/arch_errno_names.sh
> @@ -87,14 +87,13 @@ cat <<EoHEADER
>
>  EoHEADER
>
> -# Create list of architectures and ignore those that do not appear
> -# in tools/perf/arch
> +# Create list of architectures that have a specific errno.h.
>  archlist=""
> -for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | grep -v x86 | sort); do
> -       test -d $toolsdir/perf/arch/$arch && archlist="$archlist $arch"
> +for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | sort -r); do
> +       test -f $toolsdir/arch/$arch/include/uapi/asm/errno.h && archlist="$archlist $arch"
>  done
>
> -for arch in x86 $archlist generic; do
> +for arch in generic $archlist; do
>         process_arch "$arch"
>  done
> -create_arch_errno_table_func "x86 $archlist" "generic"
> +create_arch_errno_table_func "$archlist" "generic"
> --
> 2.31.1.751.gd2f1c929bd-goog
>

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

* Re: [PATCH] perf beauty: Reuse the generic switch.
  2021-05-27 15:52 ` Ian Rogers
@ 2021-07-26 21:53   ` Ian Rogers
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Rogers @ 2021-07-26 21:53 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-perf-users, LKML, Riccardo Mancini

On Thu, May 27, 2021 at 8:52 AM Ian Rogers <irogers@google.com> wrote:
>
> On Wed, May 12, 2021 at 11:04 PM Ian Rogers <irogers@google.com> wrote:
> >
> > Previously the code would see if, for example,
> > tools/perf/arch/arm/include/uapi/asm/errno.h exists and if not generate
> > a "generic" switch statement using the asm-generic/errno.h. This creates
> > multiple identical "generic" switch statements before the default
> > generic switch statement for an unknown architecture. By simplifying the
> > archlist to be only for architectures that are not "generic" the amount
> > of generated code can be reduced from 14 down to 6 functions.
> >
> > Remove the special case of x86, instead reverse the architecture names
> > so that it comes first.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
>
> Ping.
>
> Thanks!
> Ian

Ping,

Thanks!
Ian

> > ---
> >  tools/perf/trace/beauty/arch_errno_names.sh | 11 +++++------
> >  1 file changed, 5 insertions(+), 6 deletions(-)
> >
> > diff --git a/tools/perf/trace/beauty/arch_errno_names.sh b/tools/perf/trace/beauty/arch_errno_names.sh
> > index 9f9ea45cddc4..2c5f72fa8108 100755
> > --- a/tools/perf/trace/beauty/arch_errno_names.sh
> > +++ b/tools/perf/trace/beauty/arch_errno_names.sh
> > @@ -87,14 +87,13 @@ cat <<EoHEADER
> >
> >  EoHEADER
> >
> > -# Create list of architectures and ignore those that do not appear
> > -# in tools/perf/arch
> > +# Create list of architectures that have a specific errno.h.
> >  archlist=""
> > -for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | grep -v x86 | sort); do
> > -       test -d $toolsdir/perf/arch/$arch && archlist="$archlist $arch"
> > +for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | sort -r); do
> > +       test -f $toolsdir/arch/$arch/include/uapi/asm/errno.h && archlist="$archlist $arch"
> >  done
> >
> > -for arch in x86 $archlist generic; do
> > +for arch in generic $archlist; do
> >         process_arch "$arch"
> >  done
> > -create_arch_errno_table_func "x86 $archlist" "generic"
> > +create_arch_errno_table_func "$archlist" "generic"
> > --
> > 2.31.1.751.gd2f1c929bd-goog
> >

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

* Re: [PATCH] perf beauty: Reuse the generic switch.
  2021-05-13  6:04 [PATCH] perf beauty: Reuse the generic switch Ian Rogers
  2021-05-27 15:52 ` Ian Rogers
@ 2021-07-27 15:08 ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-07-27 15:08 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, linux-perf-users, linux-kernel

Em Wed, May 12, 2021 at 11:04:41PM -0700, Ian Rogers escreveu:
> Previously the code would see if, for example,
> tools/perf/arch/arm/include/uapi/asm/errno.h exists and if not generate

If tools/arch/arm/include/uapi/asm/errno.h exists, drop that 'perf/'
after 'tools/':

⬢[acme@toolbox perf]$ ls -la tools/arch/*/include/uapi/asm/errno.h
-rw-r--r--. 1 acme acme 5434 Jul 15 16:17 tools/arch/alpha/include/uapi/asm/errno.h
-rw-r--r--. 1 acme acme 5792 Jul 15 16:17 tools/arch/mips/include/uapi/asm/errno.h
-rw-r--r--. 1 acme acme 5764 Jul 15 16:17 tools/arch/parisc/include/uapi/asm/errno.h
-rw-r--r--. 1 acme acme  278 Jul 15 16:17 tools/arch/powerpc/include/uapi/asm/errno.h
-rw-r--r--. 1 acme acme 5539 Jul 15 16:17 tools/arch/sparc/include/uapi/asm/errno.h
-rw-r--r--. 1 acme acme   31 Jul 15 16:17 tools/arch/x86/include/uapi/asm/errno.h
⬢[acme@toolbox perf]$

I added the steps needed to translate your description to verify
everything and added as committer notes.

Thanks, applied as:

commit b22cc9a6701143fb1fee397e0c2088ee0473340a
Author: Ian Rogers <irogers@google.com>
Date:   Wed May 12 23:04:41 2021 -0700

    perf beauty: Reuse the generic arch errno switch
    
    Previously the code would see if, for example,
    tools/perf/arch/arm/include/uapi/asm/errno.h exists and if not generate
    a "generic" switch statement using the asm-generic/errno.h.
    
    This creates multiple identical "generic" switch statements before the
    default generic switch statement for an unknown architecture.
    
    By simplifying the archlist to be only for architectures that are not
    "generic" the amount of generated code can be reduced from 14 down to 6
    functions.
    
    Remove the special case of x86, instead reverse the architecture names
    so that it comes first.
    
    Committer testing:
    
      $ tools/perf/trace/beauty/arch_errno_names.sh gcc tools > before
    
    Apply this patch and:
    
      $ tools/perf/trace/beauty/arch_errno_names.sh gcc tools > after
    
    14 arches down to 6, that are the ones with an explicit errno.h file:
    
      $ ls -1 tools/arch/*/include/uapi/asm/errno.h
      tools/arch/alpha/include/uapi/asm/errno.h
      tools/arch/mips/include/uapi/asm/errno.h
      tools/arch/parisc/include/uapi/asm/errno.h
      tools/arch/powerpc/include/uapi/asm/errno.h
      tools/arch/sparc/include/uapi/asm/errno.h
      tools/arch/x86/include/uapi/asm/errno.h
      $
    
      $ diff -u4 before after
      @@ -2099,32 +987,16 @@
       const char *arch_syscalls__strerrno(const char *arch, int err)
       {
            if (!strcmp(arch, "x86"))
                    return errno_to_name__x86(err);
      -     if (!strcmp(arch, "alpha"))
      -             return errno_to_name__alpha(err);
      -     if (!strcmp(arch, "arc"))
      -             return errno_to_name__arc(err);
      -     if (!strcmp(arch, "arm"))
      -             return errno_to_name__arm(err);
      -     if (!strcmp(arch, "arm64"))
      -             return errno_to_name__arm64(err);
      -     if (!strcmp(arch, "csky"))
      -             return errno_to_name__csky(err);
      -     if (!strcmp(arch, "mips"))
      -             return errno_to_name__mips(err);
      -     if (!strcmp(arch, "parisc"))
      -             return errno_to_name__parisc(err);
      -     if (!strcmp(arch, "powerpc"))
      -             return errno_to_name__powerpc(err);
      -     if (!strcmp(arch, "riscv"))
      -             return errno_to_name__riscv(err);
      -     if (!strcmp(arch, "s390"))
      -             return errno_to_name__s390(err);
      -     if (!strcmp(arch, "sh"))
      -             return errno_to_name__sh(err);
            if (!strcmp(arch, "sparc"))
                    return errno_to_name__sparc(err);
      -     if (!strcmp(arch, "xtensa"))
      -             return errno_to_name__xtensa(err);
      +     if (!strcmp(arch, "powerpc"))
      +             return errno_to_name__powerpc(err);
      +     if (!strcmp(arch, "parisc"))
      +             return errno_to_name__parisc(err);
      +     if (!strcmp(arch, "mips"))
      +             return errno_to_name__mips(err);
      +     if (!strcmp(arch, "alpha"))
      +             return errno_to_name__alpha(err);
            return errno_to_name__generic(err);
       }
    
    The rest of the patch is the removal of the errno_to_name__generic()
    unneeded clones.
    
    Signed-off-by: Ian Rogers <irogers@google.com>
    Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: http://lore.kernel.org/lkml/20210513060441.408507-1-irogers@google.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

diff --git a/tools/perf/trace/beauty/arch_errno_names.sh b/tools/perf/trace/beauty/arch_errno_names.sh
index 9f9ea45cddc4384c..2c5f72fa81087956 100755
--- a/tools/perf/trace/beauty/arch_errno_names.sh
+++ b/tools/perf/trace/beauty/arch_errno_names.sh
@@ -87,14 +87,13 @@ cat <<EoHEADER
 
 EoHEADER
 
-# Create list of architectures and ignore those that do not appear
-# in tools/perf/arch
+# Create list of architectures that have a specific errno.h.
 archlist=""
-for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | grep -v x86 | sort); do
-	test -d $toolsdir/perf/arch/$arch && archlist="$archlist $arch"
+for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | sort -r); do
+	test -f $toolsdir/arch/$arch/include/uapi/asm/errno.h && archlist="$archlist $arch"
 done
 
-for arch in x86 $archlist generic; do
+for arch in generic $archlist; do
 	process_arch "$arch"
 done
-create_arch_errno_table_func "x86 $archlist" "generic"
+create_arch_errno_table_func "$archlist" "generic"

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

end of thread, other threads:[~2021-07-27 15:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13  6:04 [PATCH] perf beauty: Reuse the generic switch Ian Rogers
2021-05-27 15:52 ` Ian Rogers
2021-07-26 21:53   ` Ian Rogers
2021-07-27 15:08 ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox