]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
perf auxtrace: Pass perf_env from session through to mmap read
authorIan Rogers <irogers@google.com>
Thu, 24 Jul 2025 16:32:57 +0000 (09:32 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 25 Jul 2025 17:37:58 +0000 (10:37 -0700)
 auxtrace_mmap__read and auxtrace_mmap__read_snapshot end up calling
 `evsel__env(NULL)` which returns the global perf_env variable for the
 host. Their only call is in perf record. Rather than use the global
 variable pass through the perf_env for `perf record`.

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

index 8a829ddff6f21623cd05ebbfaafdc3361365905f..7ea3a11aca70ee63076257a37a39664d1a521935 100644 (file)
@@ -775,7 +775,9 @@ static int record__auxtrace_mmap_read(struct record *rec,
 {
        int ret;
 
-       ret = auxtrace_mmap__read(map, rec->itr, &rec->tool,
+       ret = auxtrace_mmap__read(map, rec->itr,
+                                 perf_session__env(rec->session),
+                                 &rec->tool,
                                  record__process_auxtrace);
        if (ret < 0)
                return ret;
@@ -791,7 +793,9 @@ static int record__auxtrace_mmap_read_snapshot(struct record *rec,
 {
        int ret;
 
-       ret = auxtrace_mmap__read_snapshot(map, rec->itr, &rec->tool,
+       ret = auxtrace_mmap__read_snapshot(map, rec->itr,
+                                          perf_session__env(rec->session),
+                                          &rec->tool,
                                           record__process_auxtrace,
                                           rec->opts.auxtrace_snapshot_size);
        if (ret < 0)
index 03211c2623de3bbc48e6e2256987f4b9ae280326..ebd32f1b8f1295290afaf9abf7d9c772e0669f38 100644 (file)
@@ -1890,7 +1890,7 @@ int __weak compat_auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, u64 tail)
 }
 
 static int __auxtrace_mmap__read(struct mmap *map,
-                                struct auxtrace_record *itr,
+                                struct auxtrace_record *itr, struct perf_env *env,
                                 const struct perf_tool *tool, process_auxtrace_t fn,
                                 bool snapshot, size_t snapshot_size)
 {
@@ -1900,7 +1900,7 @@ static int __auxtrace_mmap__read(struct mmap *map,
        size_t size, head_off, old_off, len1, len2, padding;
        union perf_event ev;
        void *data1, *data2;
-       int kernel_is_64_bit = perf_env__kernel_is_64_bit(evsel__env(NULL));
+       int kernel_is_64_bit = perf_env__kernel_is_64_bit(env);
 
        head = auxtrace_mmap__read_head(mm, kernel_is_64_bit);
 
@@ -2002,17 +2002,18 @@ static int __auxtrace_mmap__read(struct mmap *map,
 }
 
 int auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr,
-                       const struct perf_tool *tool, process_auxtrace_t fn)
+                       struct perf_env *env, const struct perf_tool *tool,
+                       process_auxtrace_t fn)
 {
-       return __auxtrace_mmap__read(map, itr, tool, fn, false, 0);
+       return __auxtrace_mmap__read(map, itr, env, tool, fn, false, 0);
 }
 
 int auxtrace_mmap__read_snapshot(struct mmap *map,
-                                struct auxtrace_record *itr,
+                                struct auxtrace_record *itr, struct perf_env *env,
                                 const struct perf_tool *tool, process_auxtrace_t fn,
                                 size_t snapshot_size)
 {
-       return __auxtrace_mmap__read(map, itr, tool, fn, true, snapshot_size);
+       return __auxtrace_mmap__read(map, itr, env, tool, fn, true, snapshot_size);
 }
 
 /**
index b0db84d27b255dc2f1aff446012598b045bbd5d3..f001cbb68f8e70972530de1b29db7b121d0e3518 100644 (file)
@@ -23,6 +23,7 @@ union perf_event;
 struct perf_session;
 struct evlist;
 struct evsel;
+struct perf_env;
 struct perf_tool;
 struct mmap;
 struct perf_sample;
@@ -512,10 +513,11 @@ typedef int (*process_auxtrace_t)(const struct perf_tool *tool,
                                  size_t len1, void *data2, size_t len2);
 
 int auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr,
-                       const struct perf_tool *tool, process_auxtrace_t fn);
+                       struct perf_env *env, const struct perf_tool *tool,
+                       process_auxtrace_t fn);
 
 int auxtrace_mmap__read_snapshot(struct mmap *map,
-                                struct auxtrace_record *itr,
+                                struct auxtrace_record *itr, struct perf_env *env,
                                 const struct perf_tool *tool, process_auxtrace_t fn,
                                 size_t snapshot_size);