perf auxtrace: Pass perf_env from session through to mmap read

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>
This commit is contained in:
Ian Rogers
2025-07-25 10:37:58 -07:00
committed by Namhyung Kim
parent e481066388
commit 69ac7472d2
3 changed files with 17 additions and 10 deletions
+6 -2
View 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)
+7 -6
View 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);
}
/**
+4 -2
View 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);