]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
perf trace: Avoid global perf_env with evsel__env
authorIan Rogers <irogers@google.com>
Thu, 24 Jul 2025 16:32:58 +0000 (09:32 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 25 Jul 2025 17:37:58 +0000 (10:37 -0700)
There is no session in perf trace unless in replay mode, so in host
mode no session can be associated with the evlist. If the evsel__env
call fails resort to the host_env that's part of the trace. Remove
errno_to_name as it becomes a called once 1-line function once the
argument is turned into a perf_env, just call perf_env__arch_strerrno
directly.

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250724163302.596743-19-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/builtin-trace.c

index 5b53571de4000b1345eb99f84cc3cc9cb49e55d1..fe737b3ac6e67d3bf29315b91a64e889c2fb7ed8 100644 (file)
@@ -2898,13 +2898,6 @@ static int trace__fprintf_callchain(struct trace *trace, struct perf_sample *sam
        return sample__fprintf_callchain(sample, 38, print_opts, get_tls_callchain_cursor(), symbol_conf.bt_stop_list, trace->output);
 }
 
-static const char *errno_to_name(struct evsel *evsel, int err)
-{
-       struct perf_env *env = evsel__env(evsel);
-
-       return perf_env__arch_strerrno(env, err);
-}
-
 static int trace__sys_exit(struct trace *trace, struct evsel *evsel,
                           union perf_event *event __maybe_unused,
                           struct perf_sample *sample)
@@ -2990,8 +2983,9 @@ signed_print:
        } else if (ret < 0) {
 errno_print: {
                char bf[STRERR_BUFSIZE];
-               const char *emsg = str_error_r(-ret, bf, sizeof(bf)),
-                          *e = errno_to_name(evsel, -ret);
+               struct perf_env *env = evsel__env(evsel) ?: &trace->host_env;
+               const char *emsg = str_error_r(-ret, bf, sizeof(bf));
+               const char *e = perf_env__arch_strerrno(env, err);
 
                fprintf(trace->output, "-1 %s (%s)", e, emsg);
        }