mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 15:41:52 +02:00
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>
This commit is contained in:
parent
54373b5d53
commit
4acef67646
|
|
@ -57,13 +57,13 @@ create_arch_errno_table_func()
|
|||
archlist="$1"
|
||||
default="$2"
|
||||
|
||||
printf 'const char *arch_syscalls__strerrno(const char *arch, int err)\n'
|
||||
printf 'arch_syscalls__strerrno_t *arch_syscalls__strerrno_function(const char *arch)\n'
|
||||
printf '{\n'
|
||||
for arch in $archlist; do
|
||||
printf '\tif (!strcmp(arch, "%s"))\n' $(arch_string "$arch")
|
||||
printf '\t\treturn errno_to_name__%s(err);\n' $(arch_string "$arch")
|
||||
printf '\t\treturn errno_to_name__%s;\n' $(arch_string "$arch")
|
||||
done
|
||||
printf '\treturn errno_to_name__%s(err);\n' $(arch_string "$default")
|
||||
printf '\treturn errno_to_name__%s;\n' $(arch_string "$default")
|
||||
printf '}\n'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -251,6 +251,4 @@ size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool sh
|
|||
void syscall_arg__set_ret_scnprintf(struct syscall_arg *arg,
|
||||
size_t (*ret_scnprintf)(char *bf, size_t size, struct syscall_arg *arg));
|
||||
|
||||
const char *arch_syscalls__strerrno(const char *arch, int err);
|
||||
|
||||
#endif /* _PERF_TRACE_BEAUTY_H */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ struct pmu_caps {
|
|||
char *pmu_name;
|
||||
};
|
||||
|
||||
typedef const char *(arch_syscalls__strerrno_t)(int err);
|
||||
|
||||
arch_syscalls__strerrno_t *arch_syscalls__strerrno_function(const char *arch);
|
||||
|
||||
struct perf_env {
|
||||
char *hostname;
|
||||
char *os_release;
|
||||
|
|
@ -135,6 +139,7 @@ struct perf_env {
|
|||
*/
|
||||
bool enabled;
|
||||
} clock;
|
||||
arch_syscalls__strerrno_t *arch_strerrno;
|
||||
};
|
||||
|
||||
enum perf_compress_type {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user