Skip to content

Commit 525a599

Browse files
captain5050namhyung
authored andcommitted
perf env: Remove global perf_env
The global perf_env was used for the host, but if a perf_env wasn't easy to come by it was used in a lot of places where potentially recorded and host data could be confused. Remove the global variable as now the majority of accesses retrieve the perf_env for the host from the session. Signed-off-by: Ian Rogers <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 003a86b commit 525a599

File tree

6 files changed

+4
-10
lines changed

6 files changed

+4
-10
lines changed

tools/perf/perf.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
346346
use_pager = 1;
347347
commit_pager_choice();
348348

349-
perf_env__init(&perf_env);
350-
perf_env__set_cmdline(&perf_env, argc, argv);
351349
status = p->fn(argc, argv);
352350
perf_config__exit();
353351
exit_browser(status);
354-
perf_env__exit(&perf_env);
355352

356353
if (status)
357354
return status & 0xff;

tools/perf/util/bpf-event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_session *session,
549549
* for perf-record and perf-report use header.env;
550550
* otherwise, use global perf_env.
551551
*/
552-
env = session->data ? perf_session__env(session) : &perf_env;
552+
env = perf_session__env(session);
553553

554554
arrays = 1UL << PERF_BPIL_JITED_KSYMS;
555555
arrays |= 1UL << PERF_BPIL_JITED_FUNC_LENS;

tools/perf/util/env.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#include "strbuf.h"
2020
#include "trace/beauty/beauty.h"
2121

22-
struct perf_env perf_env;
23-
2422
#ifdef HAVE_LIBBPF_SUPPORT
2523
#include "bpf-event.h"
2624
#include "bpf-utils.h"

tools/perf/util/env.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ enum perf_compress_type {
150150
struct bpf_prog_info_node;
151151
struct btf_node;
152152

153-
extern struct perf_env perf_env;
154-
155153
int perf_env__read_core_pmu_caps(struct perf_env *env);
156154
void perf_env__exit(struct perf_env *env);
157155

tools/perf/util/evsel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3882,7 +3882,7 @@ struct perf_env *evsel__env(struct evsel *evsel)
38823882
{
38833883
struct perf_session *session = evsel__session(evsel);
38843884

3885-
return session ? perf_session__env(session) : &perf_env;
3885+
return session ? perf_session__env(session) : NULL;
38863886
}
38873887

38883888
static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist)

tools/perf/util/session.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ struct perf_session *__perf_session__new(struct perf_data *data,
192192
symbol_conf.kallsyms_name = perf_data__kallsyms_name(data);
193193
}
194194
} else {
195-
session->machines.host.env = host_env ?: &perf_env;
195+
assert(host_env != NULL);
196+
session->machines.host.env = host_env;
196197
}
197198
if (session->evlist)
198199
session->evlist->session = session;

0 commit comments

Comments
 (0)