Commit 57ddb9cb authored by Ian Rogers's avatar Ian Rogers Committed by Namhyung Kim
Browse files

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: default avatarIan Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250724163302.596743-11-irogers@google.com


Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent c3e5b9ec
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1274,6 +1274,8 @@ static int process_attr(const struct perf_tool *tool __maybe_unused,
			union perf_event *event,
			struct evlist **pevlist)
{
	struct perf_session *session;
	struct perf_env *env;
	u64 sample_type;
	int err;

@@ -1286,7 +1288,9 @@ static int process_attr(const struct perf_tool *tool __maybe_unused,
	 * on events sample_type.
	 */
	sample_type = evlist__combined_sample_type(*pevlist);
	callchain_param_setup(sample_type, perf_env__arch((*pevlist)->env));
	session = (*pevlist)->session;
	env = perf_session__env(session);
	callchain_param_setup(sample_type, perf_env__arch(env));
	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -2534,7 +2534,7 @@ static int process_attr(const struct perf_tool *tool, union perf_event *event,
	 * on events sample_type.
	 */
	sample_type = evlist__combined_sample_type(evlist);
	callchain_param_setup(sample_type, perf_env__arch((*pevlist)->env));
	callchain_param_setup(sample_type, perf_env__arch(perf_session__env(scr->session)));

	/* Enable fields for callchain entries */
	if (symbol_conf.use_callchain &&
+1 −1
Original line number Diff line number Diff line
@@ -1654,7 +1654,6 @@ int cmd_top(int argc, const char **argv)
			"Couldn't read the cpuid for this machine: %s\n",
			str_error_r(errno, errbuf, sizeof(errbuf)));
	}
	top.evlist->env = &perf_env;

	argc = parse_options(argc, argv, options, top_usage, 0);
	if (argc)
@@ -1830,6 +1829,7 @@ int cmd_top(int argc, const char **argv)
		perf_top__update_print_entries(&top);
		signal(SIGWINCH, winch_sig);
	}
	top.session->env = &perf_env;

	top.session = perf_session__new(NULL, NULL);
	if (IS_ERR(top.session)) {
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ static int session_write_header(char *path)

	session->evlist = evlist__new_default();
	TEST_ASSERT_VAL("can't get evlist", session->evlist);
	session->evlist->session = session;

	perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
	perf_header__set_feat(&session->header, HEADER_NRCPUS);
+2 −2
Original line number Diff line number Diff line
@@ -71,8 +71,8 @@ int ui_browser__help_window(struct ui_browser *browser, const char *text);
bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text);
int ui_browser__input_window(const char *title, const char *text, char *input,
			     const char *exit_msg, int delay_sec);
struct perf_env;
int tui__header_window(struct perf_env *env);
struct perf_session;
int tui__header_window(struct perf_session *session);

void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence);
unsigned int ui_browser__argv_refresh(struct ui_browser *browser);
Loading