Commit 7947ad15 authored by Ian Rogers's avatar Ian Rogers Committed by Namhyung Kim
Browse files

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: 525a599b ("perf env: Remove global perf_env")
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent a5edf355
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -2009,6 +2009,7 @@ static int __cmd_contention(int argc, const char **argv)
		.owner = show_lock_owner,
		.cgroups = RB_ROOT,
	};
	struct perf_env host_env;

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

	session = perf_session__new(use_bpf ? NULL : &data, &eops);
	perf_env__init(&host_env);
	session = __perf_session__new(use_bpf ? NULL : &data, &eops,
				/*trace_event_repipe=*/false, &host_env);

	if (IS_ERR(session)) {
		pr_err("Initializing perf session failed\n");
		err = PTR_ERR(session);
@@ -2142,6 +2146,7 @@ static int __cmd_contention(int argc, const char **argv)
	evlist__delete(con.evlist);
	lock_contention_finish(&con);
	perf_session__delete(session);
	perf_env__exit(&host_env);
	zfree(&lockhash_table);
	return err;
}