Commit graph

6 commits

Author SHA1 Message Date
Kajol Jain
f188b2ce65 perf beauty arch_errno_names: Fix shellcheck issue about local variables
Running shellcheck on arch_errno_names.sh generates below warning:

In arch_errno_names.sh line 20:
	local arch="$1"
        ^--------^ SC3043 (warning): In POSIX sh, 'local' is undefined.

......

In arch_errno_names.sh line 61:
	local arch
        ^--------^ SC3043 (warning): In POSIX sh, 'local' is undefined.

In arch_errno_names.sh line 67:
		printf '\t\treturn errno_to_name__%s(err);\n' $(arch_string "$arch")
                                                              ^--------------------^ SC2046 (warning): Quote this to prevent word splitting.

In arch_errno_names.sh line 69:
	printf '\treturn errno_to_name__%s(err);\n' $(arch_string "$default")
                                                    ^-----------------------^ SC2046 (warning): Quote this to prevent word splitting.

Fixed the warnings by:
- Fixing shellcheck warnings for local usage, by removing
  local from the variable names
- Adding quotes to avoid word splitting

Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230709182800.53002-15-atrajeev@linux.vnet.ibm.com
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-08-03 17:01:26 -03:00
Arnaldo Carvalho de Melo
3713e2494b perf trace beauty: Fix generation of errno id->str table on ALT Linux
For some reason using:

         cat <<EoFuncBegin
  static const char *errno_to_name__$arch(int err)
  {
         switch (err) {
  EoFuncBegin

In tools/perf/trace/beauty/arch_errno_names.sh isn't working on ALT
Linux sisyphus (development version), which could be some distro
specific glitch, so just get this done in an alternative way that works
everywhere while giving notice to the people working on that distro to
try and figure our what really took place.

Cc: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-06-26 12:32:55 -03:00
Ian Rogers
f463ad7f41 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>
2021-08-02 09:56:18 -03:00
Ian Rogers
6d1f916265 perf beauty: Allow the CC used in the arch errno names script to acccept CFLAGS
Allow the CC compiler to accept a CFLAGS environment variable.  This
doesn't change the code generated but makes it easier to integrate
running the shell script in build systems like bazel.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexios Zavras <alexios.zavras@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Igor Lubashev <ilubashe@akamai.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Wei Li <liwei391@huawei.com>
Link: http://lore.kernel.org/lkml/20200306071110.130202-4-irogers@google.com
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-05-28 10:03:26 -03:00
Ian Rogers
7597ce89b3 perf trace: Fix the selection for architectures to generate the errno name tables
Make the architecture test directory agree with the code comment.

Committer notes:

This was split from a larger patch.

The code was assuming the developer always worked from tools/perf/, so make sure we
do the test -d having $toolsdir/perf/arch/$arch, to match the intent expressed in the comment,
just above that loop.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexios Zavras <alexios.zavras@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Igor Lubashev <ilubashe@akamai.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Wei Li <liwei391@huawei.com>
Link: http://lore.kernel.org/lkml/20200306071110.130202-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-05-28 10:03:26 -03:00
Hendrik Brueckner
0337cf74cc perf util: Introduce architecture specific errno/name mapping
Introduce a script that generates a mapping of errno numbers to their
names for each architecture that is supported by perf (i.e.  has a
subdirectory in tools/perf/arch/).

The errno mapping is generated as part of the trace beautifiers and can
be used by including the trace/beauty/arch_errno_names.c file.  Then,
use arch_syscalls__strerrno() to look up an errno value to obtain the
errno name (e.g. ENOENT) for a particular architecture.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: linux-s390@vger.kernel.org
LPU-Reference: 1516352177-11106-4-git-send-email-brueckner@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-8zlsjnuoep2ww39aq5z41fno@git.kernel.org
[ Make x86 be the first arch, most common, add newline to last line, fixing build on centos:5 ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-01-23 09:51:37 -03:00