diff options
| author | Ian Rogers <irogers@google.com> | 2025-07-24 09:32:50 -0700 |
|---|---|---|
| committer | Namhyung Kim <namhyung@kernel.org> | 2025-07-25 10:37:56 -0700 |
| commit | 57ddb9cbb54fbf3772063795051b88a1f7258c6c (patch) | |
| tree | 36f6a2e9b598aa305b9bb862fc623eeee16218fe /tools/perf/util/evsel.c | |
| parent | c3e5b9ec96dee864c2d6b00fbfe52e784f0d7bee (diff) | |
perf evlist: Change env variable to session
The session holds a perf_env pointer env. In UI code container_of is
used to turn the env to a session, but this assumes the session
header's env is in use. Rather than a dubious container_of, hold the
session in the evlist and derive the env from the session with
evsel__env, perf_session__env, etc.
Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250724163302.596743-11-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf/util/evsel.c')
| -rw-r--r-- | tools/perf/util/evsel.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index ae11df1e7902..3f766f240cc7 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -48,6 +48,7 @@ #include "record.h" #include "debug.h" #include "trace-event.h" +#include "session.h" #include "stat.h" #include "string2.h" #include "memswap.h" @@ -3872,11 +3873,16 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target, err, str_error_r(err, sbuf, sizeof(sbuf)), evsel__name(evsel)); } +struct perf_session *evsel__session(struct evsel *evsel) +{ + return evsel && evsel->evlist ? evsel->evlist->session : NULL; +} + struct perf_env *evsel__env(struct evsel *evsel) { - if (evsel && evsel->evlist && evsel->evlist->env) - return evsel->evlist->env; - return &perf_env; + struct perf_session *session = evsel__session(evsel); + + return session ? perf_session__env(session) : &perf_env; } static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist) |