perf tools: Resolve machine earlier and pass it to perf_event_ops
Reducing the exposure of perf_session further, so that we can use the
classes in cases where no perf.data file is created.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-stua66dcscsezzrcdugvbmvd@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 4642d38..0af598a 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -79,7 +79,7 @@
static int process_synthesized_event(struct perf_event_ops *ops,
union perf_event *event,
struct perf_sample *sample __used,
- struct perf_session *self __used)
+ struct machine *machine __used)
{
struct perf_record *rec = container_of(ops, struct perf_record, ops);
write_output(rec, event, event->header.size);
@@ -320,8 +320,6 @@
{
int err;
struct perf_event_ops *ops = data;
- struct perf_record *rec = container_of(ops, struct perf_record, ops);
- struct perf_session *psession = rec->session;
if (machine__is_host(machine))
return;
@@ -335,7 +333,7 @@
*in module instead of in guest kernel.
*/
err = perf_event__synthesize_modules(ops, process_synthesized_event,
- psession, machine);
+ machine);
if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference"
" relocation symbol.\n", machine->pid);
@@ -345,11 +343,10 @@
* have no _text sometimes.
*/
err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
- psession, machine, "_text");
+ machine, "_text");
if (err < 0)
err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
- psession, machine,
- "_stext");
+ machine, "_stext");
if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference"
" relocation symbol.\n", machine->pid);
@@ -497,6 +494,12 @@
rec->post_processing_offset = lseek(output, 0, SEEK_CUR);
+ machine = perf_session__find_host_machine(session);
+ if (!machine) {
+ pr_err("Couldn't find native kernel information.\n");
+ return -1;
+ }
+
if (opts->pipe_output) {
err = perf_event__synthesize_attrs(ops, session,
process_synthesized_event);
@@ -506,7 +509,7 @@
}
err = perf_event__synthesize_event_types(ops, process_synthesized_event,
- session);
+ machine);
if (err < 0) {
pr_err("Couldn't synthesize event_types.\n");
return err;
@@ -522,8 +525,7 @@
* propagate errors that now are calling die()
*/
err = perf_event__synthesize_tracing_data(ops, output, evsel_list,
- process_synthesized_event,
- session);
+ process_synthesized_event);
if (err <= 0) {
pr_err("Couldn't record tracing data.\n");
return err;
@@ -532,24 +534,18 @@
}
}
- machine = perf_session__find_host_machine(session);
- if (!machine) {
- pr_err("Couldn't find native kernel information.\n");
- return -1;
- }
-
err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
- session, machine, "_text");
+ machine, "_text");
if (err < 0)
err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
- session, machine, "_stext");
+ machine, "_stext");
if (err < 0)
pr_err("Couldn't record kernel reference relocation symbol\n"
"Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
"Check /proc/kallsyms permission or run as root.\n");
err = perf_event__synthesize_modules(ops, process_synthesized_event,
- session, machine);
+ machine);
if (err < 0)
pr_err("Couldn't record kernel module information.\n"
"Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
@@ -562,10 +558,10 @@
if (!opts->system_wide)
perf_event__synthesize_thread_map(ops, evsel_list->threads,
process_synthesized_event,
- session);
+ machine);
else
perf_event__synthesize_threads(ops, process_synthesized_event,
- session);
+ machine);
if (rec->realtime_prio) {
struct sched_param param;