Skip to content

Commit 54373b5

Browse files
committed
perf env: Introduce perf_env__arch_strerrno()
That will cache the arch specific function translating error numbers to strings. Reviewed-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: David Laight <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 556bed5 commit 54373b5

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

tools/perf/builtin-trace.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -2470,9 +2470,8 @@ static int trace__fprintf_callchain(struct trace *trace, struct perf_sample *sam
24702470
static const char *errno_to_name(struct evsel *evsel, int err)
24712471
{
24722472
struct perf_env *env = evsel__env(evsel);
2473-
const char *arch_name = perf_env__arch(env);
24742473

2475-
return arch_syscalls__strerrno(arch_name, err);
2474+
return perf_env__arch_strerrno(env, err);
24762475
}
24772476

24782477
static int trace__sys_exit(struct trace *trace, struct evsel *evsel,
@@ -4264,12 +4263,11 @@ static size_t thread__dump_stats(struct thread_trace *ttrace,
42644263
printed += fprintf(fp, " %9.3f %9.2f%%\n", max, pct);
42654264

42664265
if (trace->errno_summary && stats->nr_failures) {
4267-
const char *arch_name = perf_env__arch(trace->host->env);
42684266
int e;
42694267

42704268
for (e = 0; e < stats->max_errno; ++e) {
42714269
if (stats->errnos[e] != 0)
4272-
fprintf(fp, "\t\t\t\t%s: %d\n", arch_syscalls__strerrno(arch_name, e + 1), stats->errnos[e]);
4270+
fprintf(fp, "\t\t\t\t%s: %d\n", perf_env__arch_strerrno(trace->host->env, e + 1), stats->errnos[e]);
42734271
}
42744272
}
42754273
}

tools/perf/util/env.c

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "debug.h"
44
#include "env.h"
55
#include "util/header.h"
6+
#include "linux/compiler.h"
67
#include <linux/ctype.h>
78
#include <linux/zalloc.h>
89
#include "cgroup.h"
@@ -12,6 +13,7 @@
1213
#include <string.h>
1314
#include "pmus.h"
1415
#include "strbuf.h"
16+
#include "trace/beauty/beauty.h"
1517

1618
struct perf_env perf_env;
1719

@@ -453,6 +455,16 @@ const char *perf_env__arch(struct perf_env *env)
453455
return normalize_arch(arch_name);
454456
}
455457

458+
const char *perf_env__arch_strerrno(struct perf_env *env __maybe_unused, int err __maybe_unused)
459+
{
460+
#if defined(HAVE_SYSCALL_TABLE_SUPPORT) && defined(HAVE_LIBTRACEEVENT)
461+
const char *arch_name = perf_env__arch(env);
462+
return arch_syscalls__strerrno(arch_name, err);
463+
#else
464+
return "!(HAVE_SYSCALL_TABLE_SUPPORT && HAVE_LIBTRACEEVENT)";
465+
#endif
466+
}
467+
456468
const char *perf_env__cpuid(struct perf_env *env)
457469
{
458470
int status;

tools/perf/util/env.h

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ int perf_env__read_cpu_topology_map(struct perf_env *env);
164164
void cpu_cache_level__free(struct cpu_cache_level *cache);
165165

166166
const char *perf_env__arch(struct perf_env *env);
167+
const char *perf_env__arch_strerrno(struct perf_env *env, int err);
167168
const char *perf_env__cpuid(struct perf_env *env);
168169
const char *perf_env__raw_arch(struct perf_env *env);
169170
int perf_env__nr_cpus_avail(struct perf_env *env);

0 commit comments

Comments
 (0)