Skip to content

Commit 740f7ba

Browse files
captain5050namhyung
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 5a15635 commit 740f7ba

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

tools/perf/builtin-inject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2539,7 +2539,8 @@ int cmd_inject(int argc, const char **argv)
25392539
inject.tool.bpf_metadata = perf_event__repipe_op2_synth;
25402540
inject.tool.dont_split_sample_group = true;
25412541
inject.session = __perf_session__new(&data, &inject.tool,
2542-
/*trace_event_repipe=*/inject.output.is_pipe);
2542+
/*trace_event_repipe=*/inject.output.is_pipe,
2543+
/*host_env=*/NULL);
25432544

25442545
if (IS_ERR(inject.session)) {
25452546
ret = PTR_ERR(inject.session);

tools/perf/util/session.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ static int ordered_events__deliver_event(struct ordered_events *oe,
138138

139139
struct perf_session *__perf_session__new(struct perf_data *data,
140140
struct perf_tool *tool,
141-
bool trace_event_repipe)
141+
bool trace_event_repipe,
142+
struct perf_env *host_env)
142143
{
143144
int ret = -ENOMEM;
144145
struct perf_session *session = zalloc(sizeof(*session));
@@ -191,7 +192,7 @@ struct perf_session *__perf_session__new(struct perf_data *data,
191192
symbol_conf.kallsyms_name = perf_data__kallsyms_name(data);
192193
}
193194
} else {
194-
session->machines.host.env = &perf_env;
195+
session->machines.host.env = host_env ?: &perf_env;
195196
}
196197
if (session->evlist)
197198
session->evlist->session = session;

tools/perf/util/session.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,13 @@ struct perf_tool;
107107

108108
struct perf_session *__perf_session__new(struct perf_data *data,
109109
struct perf_tool *tool,
110-
bool trace_event_repipe);
110+
bool trace_event_repipe,
111+
struct perf_env *host_env);
111112

112113
static inline struct perf_session *perf_session__new(struct perf_data *data,
113114
struct perf_tool *tool)
114115
{
115-
return __perf_session__new(data, tool, /*trace_event_repipe=*/false);
116+
return __perf_session__new(data, tool, /*trace_event_repipe=*/false, /*host_env=*/NULL);
116117
}
117118

118119
void perf_session__delete(struct perf_session *session);

0 commit comments

Comments
 (0)