History log of /linux-master/tools/perf/trace/beauty/arch_errno_names.sh
Revision Date Author Comments
# 4acef676 01-Dec-2023 Arnaldo Carvalho de Melo <acme@redhat.com>

perf env: Cache the arch specific strerrno function in perf_env__arch_strerrno()

So that we don't have to go thru the series of strcmp(arch) calls for
each id -> string translation.

Reviewed-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Laight <David.Laight@ACULAB.COM>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/20231201203046.486596-3-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# 556bed5c 30-Nov-2023 Arnaldo Carvalho de Melo <acme@redhat.com>

perf beauty: Don't use 'find ... -printf' as it isn't available in busybox

Namhyung reported:

I'm seeing a build error on my Alpine linux image which uses busybox +
musl libc:

In file included from trace/beauty/arch_errno_names.c:1,
from builtin-trace.c:899:
/build/trace/beauty/generated/arch_errno_name_array.c: In function 'arch_syscalls__strerrno':
/build/trace/beauty/generated/arch_errno_name_array.c:142:49: error: unused parameter 'arch' [-Werror=unused-parameter]
142 | const char *arch_syscalls__strerrno(const char *arch, int err)

It looks like busybox find command doesn't have -printf option

find: unrecognized: -printf
, Yesterday 9:16 PM
,
BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary.

Usage: find [-HL] [PATH]... [OPTIONS] [ACTIONS]

Search for files and perform actions on them.
First failed action stops processing of current file.
Defaults: PATH is current directory, action is '-print'

So just remove it and pipe find's entry to a basename loop to produce
the same result.

Then use an alternative loop that relies on the shell to avoid needless
forks and execs.

The discussion about it generated the impetus to stop doing strcmps to
find the right table at each errno to string translation but instead do
this just once and then use a function pointer to the right arch
specific table.

Suggested-by: David Laight <David.Laight@ACULAB.COM>
Reported-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# f188b2ce 09-Jul-2023 Kajol Jain <kjain@linux.ibm.com>

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>


# 3713e249 20-Jun-2022 Arnaldo Carvalho de Melo <acme@redhat.com>

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>


# f463ad7f 13-May-2021 Ian Rogers <irogers@google.com>

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>


# 6d1f9162 06-Mar-2020 Ian Rogers <irogers@google.com>

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>


# 7597ce89 06-Mar-2020 Ian Rogers <irogers@google.com>

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>


# 0337cf74 19-Jan-2018 Hendrik Brueckner <brueckner@linux.vnet.ibm.com>

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>