summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-record.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-11-28 13:56:39 +0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-11-28 16:39:12 +0400
commit743eb868657bdb1b26c7b24077ca21c67c82c777 (patch)
tree4803b557725213043ccd5d3f83d2eec796a49f69 /tools/perf/builtin-record.c
parentd20deb64e0490ee9442b5181bc08a62d2cadcb90 (diff)
downloadlinux-743eb868657bdb1b26c7b24077ca21c67c82c777.tar.xz
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>
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r--tools/perf/builtin-record.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 4642d38b8d19..0af598a1059f 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -79,7 +79,7 @@ static void write_output(struct perf_record *rec, void *buf, size_t size)
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 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
{
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 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
*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 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
* 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 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
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 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
}
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 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
* 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 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
}
}
- 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 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
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;