Skip to content

Commit 7947ad1

Browse files
captain5050namhyung
authored andcommitted
perf lock: Provide a host_env for session new
When "perf lock con" is run in a live mode, with no data file, a host environment must be provided. Testing missed this as a failing assert was creating the 1 line of expected stderr output. $ sudo perf lock con -ab true perf: util/session.c:195: __perf_session__new: Assertion `host_env != NULL' failed. Aborted Fixes: 525a599 ("perf env: Remove global perf_env") Signed-off-by: Ian Rogers <[email protected]> Signed-off-by: Namhyung Kim <[email protected]>
1 parent a5edf35 commit 7947ad1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/perf/builtin-lock.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,7 @@ static int __cmd_contention(int argc, const char **argv)
20092009
.owner = show_lock_owner,
20102010
.cgroups = RB_ROOT,
20112011
};
2012+
struct perf_env host_env;
20122013

20132014
lockhash_table = calloc(LOCKHASH_SIZE, sizeof(*lockhash_table));
20142015
if (!lockhash_table)
@@ -2024,7 +2025,10 @@ static int __cmd_contention(int argc, const char **argv)
20242025
eops.mmap = perf_event__process_mmap;
20252026
eops.tracing_data = perf_event__process_tracing_data;
20262027

2027-
session = perf_session__new(use_bpf ? NULL : &data, &eops);
2028+
perf_env__init(&host_env);
2029+
session = __perf_session__new(use_bpf ? NULL : &data, &eops,
2030+
/*trace_event_repipe=*/false, &host_env);
2031+
20282032
if (IS_ERR(session)) {
20292033
pr_err("Initializing perf session failed\n");
20302034
err = PTR_ERR(session);
@@ -2142,6 +2146,7 @@ static int __cmd_contention(int argc, const char **argv)
21422146
evlist__delete(con.evlist);
21432147
lock_contention_finish(&con);
21442148
perf_session__delete(session);
2149+
perf_env__exit(&host_env);
21452150
zfree(&lockhash_table);
21462151
return err;
21472152
}

0 commit comments

Comments
 (0)