* [PATCH 0/2] Cache the arch specific stderrno routine
@ 2023-12-01 20:30 Arnaldo Carvalho de Melo
2023-12-01 20:30 ` [PATCH 1/2] perf env: Introduce perf_env__arch_strerrno() Arnaldo Carvalho de Melo
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-12-01 20:30 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, Kate Carcia, linux-kernel,
linux-perf-users, Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Hi,
Please take a look,
- Arnaldo
Arnaldo Carvalho de Melo (2):
perf env: Introduce perf_env__arch_strerrno()
perf env: Cache the arch specific strerrno function in perf_env__arch_strerrno()
tools/perf/builtin-trace.c | 6 ++----
tools/perf/trace/beauty/arch_errno_names.sh | 6 +++---
tools/perf/trace/beauty/beauty.h | 2 --
tools/perf/util/env.c | 9 +++++++++
tools/perf/util/env.h | 6 ++++++
5 files changed, 20 insertions(+), 9 deletions(-)
--
2.41.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] perf env: Introduce perf_env__arch_strerrno()
2023-12-01 20:30 [PATCH 0/2] Cache the arch specific stderrno routine Arnaldo Carvalho de Melo
@ 2023-12-01 20:30 ` Arnaldo Carvalho de Melo
2023-12-01 20:30 ` [PATCH 2/2] perf env: Cache the arch specific strerrno function in perf_env__arch_strerrno() Arnaldo Carvalho de Melo
2023-12-04 19:10 ` [PATCH 0/2] Cache the arch specific stderrno routine Ian Rogers
2 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-12-01 20:30 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, Kate Carcia, linux-kernel,
linux-perf-users, Arnaldo Carvalho de Melo, David Laight
From: Arnaldo Carvalho de Melo <acme@redhat.com>
That will cache the arch specific function translating error numbers to
strings.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Laight <David.Laight@ACULAB.COM>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-trace.c | 6 ++----
tools/perf/util/env.c | 7 +++++++
tools/perf/util/env.h | 1 +
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index e541d0e2777ab935..109b8e64fe69ae32 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2470,9 +2470,8 @@ static int trace__fprintf_callchain(struct trace *trace, struct perf_sample *sam
static const char *errno_to_name(struct evsel *evsel, int err)
{
struct perf_env *env = evsel__env(evsel);
- const char *arch_name = perf_env__arch(env);
- return arch_syscalls__strerrno(arch_name, err);
+ return perf_env__arch_strerrno(env, err);
}
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,
printed += fprintf(fp, " %9.3f %9.2f%%\n", max, pct);
if (trace->errno_summary && stats->nr_failures) {
- const char *arch_name = perf_env__arch(trace->host->env);
int e;
for (e = 0; e < stats->max_errno; ++e) {
if (stats->errnos[e] != 0)
- fprintf(fp, "\t\t\t\t%s: %d\n", arch_syscalls__strerrno(arch_name, e + 1), stats->errnos[e]);
+ fprintf(fp, "\t\t\t\t%s: %d\n", perf_env__arch_strerrno(trace->host->env, e + 1), stats->errnos[e]);
}
}
}
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index cbc18b22ace5231e..fdd62ea00173ccf5 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -12,6 +12,7 @@
#include <string.h>
#include "pmus.h"
#include "strbuf.h"
+#include "trace/beauty/beauty.h"
struct perf_env perf_env;
@@ -453,6 +454,12 @@ const char *perf_env__arch(struct perf_env *env)
return normalize_arch(arch_name);
}
+const char *perf_env__arch_strerrno(struct perf_env *env, int err)
+{
+ const char *arch_name = perf_env__arch(env);
+ return arch_syscalls__strerrno(arch_name, err);
+}
+
const char *perf_env__cpuid(struct perf_env *env)
{
int status;
diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h
index 94596ff124d54188..79f371879f45bafc 100644
--- a/tools/perf/util/env.h
+++ b/tools/perf/util/env.h
@@ -164,6 +164,7 @@ int perf_env__read_cpu_topology_map(struct perf_env *env);
void cpu_cache_level__free(struct cpu_cache_level *cache);
const char *perf_env__arch(struct perf_env *env);
+const char *perf_env__arch_strerrno(struct perf_env *env, int err);
const char *perf_env__cpuid(struct perf_env *env);
const char *perf_env__raw_arch(struct perf_env *env);
int perf_env__nr_cpus_avail(struct perf_env *env);
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] perf env: Cache the arch specific strerrno function in perf_env__arch_strerrno()
2023-12-01 20:30 [PATCH 0/2] Cache the arch specific stderrno routine Arnaldo Carvalho de Melo
2023-12-01 20:30 ` [PATCH 1/2] perf env: Introduce perf_env__arch_strerrno() Arnaldo Carvalho de Melo
@ 2023-12-01 20:30 ` Arnaldo Carvalho de Melo
2023-12-04 19:10 ` [PATCH 0/2] Cache the arch specific stderrno routine Ian Rogers
2 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-12-01 20:30 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
Adrian Hunter, Clark Williams, Kate Carcia, linux-kernel,
linux-perf-users, Arnaldo Carvalho de Melo, David Laight
From: Arnaldo Carvalho de Melo <acme@redhat.com>
So that we don't have to go thru the series of strcmp(arch) calls for
each id -> string translation.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Laight <David.Laight@ACULAB.COM>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/trace/beauty/arch_errno_names.sh | 6 +++---
tools/perf/trace/beauty/beauty.h | 2 --
tools/perf/util/env.c | 6 ++++--
tools/perf/util/env.h | 5 +++++
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/tools/perf/trace/beauty/arch_errno_names.sh b/tools/perf/trace/beauty/arch_errno_names.sh
index b6e0767b4b34e46a..7df4bf5b55a3cc2a 100755
--- a/tools/perf/trace/beauty/arch_errno_names.sh
+++ b/tools/perf/trace/beauty/arch_errno_names.sh
@@ -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'
}
diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h
index 788e8f6bd90eb753..9feb794f5c6e15f4 100644
--- a/tools/perf/trace/beauty/beauty.h
+++ b/tools/perf/trace/beauty/beauty.h
@@ -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 */
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index fdd62ea00173ccf5..2845b9f4694591be 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -456,8 +456,10 @@ const char *perf_env__arch(struct perf_env *env)
const char *perf_env__arch_strerrno(struct perf_env *env, int err)
{
- 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";
}
const char *perf_env__cpuid(struct perf_env *env)
diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h
index 79f371879f45bafc..bf7e3c4c211f971e 100644
--- a/tools/perf/util/env.h
+++ b/tools/perf/util/env.h
@@ -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 {
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Cache the arch specific stderrno routine
2023-12-01 20:30 [PATCH 0/2] Cache the arch specific stderrno routine Arnaldo Carvalho de Melo
2023-12-01 20:30 ` [PATCH 1/2] perf env: Introduce perf_env__arch_strerrno() Arnaldo Carvalho de Melo
2023-12-01 20:30 ` [PATCH 2/2] perf env: Cache the arch specific strerrno function in perf_env__arch_strerrno() Arnaldo Carvalho de Melo
@ 2023-12-04 19:10 ` Ian Rogers
2023-12-04 19:43 ` Arnaldo Carvalho de Melo
2 siblings, 1 reply; 5+ messages in thread
From: Ian Rogers @ 2023-12-04 19:10 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Namhyung Kim, Ingo Molnar, Thomas Gleixner, Jiri Olsa,
Adrian Hunter, Clark Williams, Kate Carcia, linux-kernel,
linux-perf-users, Arnaldo Carvalho de Melo
On Fri, Dec 1, 2023 at 12:30 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> Hi,
>
> Please take a look,
>
> - Arnaldo
>
> Arnaldo Carvalho de Melo (2):
> perf env: Introduce perf_env__arch_strerrno()
> perf env: Cache the arch specific strerrno function in perf_env__arch_strerrno()
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> tools/perf/builtin-trace.c | 6 ++----
> tools/perf/trace/beauty/arch_errno_names.sh | 6 +++---
> tools/perf/trace/beauty/beauty.h | 2 --
> tools/perf/util/env.c | 9 +++++++++
> tools/perf/util/env.h | 6 ++++++
> 5 files changed, 20 insertions(+), 9 deletions(-)
>
> --
> 2.41.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Cache the arch specific stderrno routine
2023-12-04 19:10 ` [PATCH 0/2] Cache the arch specific stderrno routine Ian Rogers
@ 2023-12-04 19:43 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-12-04 19:43 UTC (permalink / raw)
To: Ian Rogers
Cc: Namhyung Kim, Ingo Molnar, Thomas Gleixner, Jiri Olsa,
Adrian Hunter, Clark Williams, Kate Carcia, linux-kernel,
linux-perf-users, Arnaldo Carvalho de Melo
Em Mon, Dec 04, 2023 at 11:10:54AM -0800, Ian Rogers escreveu:
> On Fri, Dec 1, 2023 at 12:30 PM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > Arnaldo Carvalho de Melo (2):
> > perf env: Introduce perf_env__arch_strerrno()
> > perf env: Cache the arch specific strerrno function in perf_env__arch_strerrno()
> Reviewed-by: Ian Rogers <irogers@google.com>
Thanks, stamped the patches with that,
- Arnaldo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-12-04 19:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-01 20:30 [PATCH 0/2] Cache the arch specific stderrno routine Arnaldo Carvalho de Melo
2023-12-01 20:30 ` [PATCH 1/2] perf env: Introduce perf_env__arch_strerrno() Arnaldo Carvalho de Melo
2023-12-01 20:30 ` [PATCH 2/2] perf env: Cache the arch specific strerrno function in perf_env__arch_strerrno() Arnaldo Carvalho de Melo
2023-12-04 19:10 ` [PATCH 0/2] Cache the arch specific stderrno routine Ian Rogers
2023-12-04 19:43 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).