summaryrefslogtreecommitdiff
path: root/tools/perf/util/env.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2023-12-01 17:07:34 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-12-04 16:42:15 -0300
commit4acef67646f35e14d202d5f534c0fd68d7691b22 (patch)
tree4b09ea92e08af3fa77d852bfd8d4621e805eb7f0 /tools/perf/util/env.c
parent54373b5d53c1f6aa6164ee5bea4761abb16b351c (diff)
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>
Diffstat (limited to 'tools/perf/util/env.c')
-rw-r--r--tools/perf/util/env.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index a632f33646bb..c68b7a004f29 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -458,8 +458,10 @@ const char *perf_env__arch(struct perf_env *env)
const char *perf_env__arch_strerrno(struct perf_env *env __maybe_unused, int err __maybe_unused)
{
#if defined(HAVE_SYSCALL_TABLE_SUPPORT) && defined(HAVE_LIBTRACEEVENT)
- const char *arch_name = perf_env__arch(env);
- return arch_syscalls__strerrno(arch_name, err);
+ if (env->arch_strerrno == NULL)
+ env->arch_strerrno = arch_syscalls__strerrno_function(perf_env__arch(env));
+
+ return env->arch_strerrno ? env->arch_strerrno(err) : "no arch specific strerrno function";
#else
return "!(HAVE_SYSCALL_TABLE_SUPPORT && HAVE_LIBTRACEEVENT)";
#endif