mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
perf session: Add host_env argument to perf_session__new
When creating a perf_session the host perf_env may or may not want to be used. For example, `perf top` uses a host perf_env while `perf inject` does not. Add a host_env argument to perf_session__new so that sessions requiring a host perf_env can pass it in. Currently if none is specified the global perf_env variable is used, but this will change in later patches. Signed-off-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/r/20250724163302.596743-14-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
@@ -2539,7 +2539,8 @@ int cmd_inject(int argc, const char **argv)
|
||||
inject.tool.bpf_metadata = perf_event__repipe_op2_synth;
|
||||
inject.tool.dont_split_sample_group = true;
|
||||
inject.session = __perf_session__new(&data, &inject.tool,
|
||||
/*trace_event_repipe=*/inject.output.is_pipe);
|
||||
/*trace_event_repipe=*/inject.output.is_pipe,
|
||||
/*host_env=*/NULL);
|
||||
|
||||
if (IS_ERR(inject.session)) {
|
||||
ret = PTR_ERR(inject.session);
|
||||
|
||||
@@ -138,7 +138,8 @@ static int ordered_events__deliver_event(struct ordered_events *oe,
|
||||
|
||||
struct perf_session *__perf_session__new(struct perf_data *data,
|
||||
struct perf_tool *tool,
|
||||
bool trace_event_repipe)
|
||||
bool trace_event_repipe,
|
||||
struct perf_env *host_env)
|
||||
{
|
||||
int ret = -ENOMEM;
|
||||
struct perf_session *session = zalloc(sizeof(*session));
|
||||
@@ -191,7 +192,7 @@ struct perf_session *__perf_session__new(struct perf_data *data,
|
||||
symbol_conf.kallsyms_name = perf_data__kallsyms_name(data);
|
||||
}
|
||||
} else {
|
||||
session->machines.host.env = &perf_env;
|
||||
session->machines.host.env = host_env ?: &perf_env;
|
||||
}
|
||||
if (session->evlist)
|
||||
session->evlist->session = session;
|
||||
|
||||
@@ -107,12 +107,13 @@ struct perf_tool;
|
||||
|
||||
struct perf_session *__perf_session__new(struct perf_data *data,
|
||||
struct perf_tool *tool,
|
||||
bool trace_event_repipe);
|
||||
bool trace_event_repipe,
|
||||
struct perf_env *host_env);
|
||||
|
||||
static inline struct perf_session *perf_session__new(struct perf_data *data,
|
||||
struct perf_tool *tool)
|
||||
{
|
||||
return __perf_session__new(data, tool, /*trace_event_repipe=*/false);
|
||||
return __perf_session__new(data, tool, /*trace_event_repipe=*/false, /*host_env=*/NULL);
|
||||
}
|
||||
|
||||
void perf_session__delete(struct perf_session *session);
|
||||
|
||||
Reference in New Issue
Block a user