aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-record.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-11-28 04:56:39 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-11-28 07:39:12 -0500
commit743eb868657bdb1b26c7b24077ca21c67c82c777 (patch)
tree4803b557725213043ccd5d3f83d2eec796a49f69 /tools/perf/builtin-record.c
parentd20deb64e0490ee9442b5181bc08a62d2cadcb90 (diff)
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)
79static int process_synthesized_event(struct perf_event_ops *ops, 79static int process_synthesized_event(struct perf_event_ops *ops,
80 union perf_event *event, 80 union perf_event *event,
81 struct perf_sample *sample __used, 81 struct perf_sample *sample __used,
82 struct perf_session *self __used) 82 struct machine *machine __used)
83{ 83{
84 struct perf_record *rec = container_of(ops, struct perf_record, ops); 84 struct perf_record *rec = container_of(ops, struct perf_record, ops);
85 write_output(rec, event, event->header.size); 85 write_output(rec, event, event->header.size);
@@ -320,8 +320,6 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
320{ 320{
321 int err; 321 int err;
322 struct perf_event_ops *ops = data; 322 struct perf_event_ops *ops = data;
323 struct perf_record *rec = container_of(ops, struct perf_record, ops);
324 struct perf_session *psession = rec->session;
325 323
326 if (machine__is_host(machine)) 324 if (machine__is_host(machine))
327 return; 325 return;
@@ -335,7 +333,7 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
335 *in module instead of in guest kernel. 333 *in module instead of in guest kernel.
336 */ 334 */
337 err = perf_event__synthesize_modules(ops, process_synthesized_event, 335 err = perf_event__synthesize_modules(ops, process_synthesized_event,
338 psession, machine); 336 machine);
339 if (err < 0) 337 if (err < 0)
340 pr_err("Couldn't record guest kernel [%d]'s reference" 338 pr_err("Couldn't record guest kernel [%d]'s reference"
341 " relocation symbol.\n", machine->pid); 339 " relocation symbol.\n", machine->pid);
@@ -345,11 +343,10 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
345 * have no _text sometimes. 343 * have no _text sometimes.
346 */ 344 */
347 err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, 345 err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
348 psession, machine, "_text"); 346 machine, "_text");
349 if (err < 0) 347 if (err < 0)
350 err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, 348 err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
351 psession, machine, 349 machine, "_stext");
352 "_stext");
353 if (err < 0) 350 if (err < 0)
354 pr_err("Couldn't record guest kernel [%d]'s reference" 351 pr_err("Couldn't record guest kernel [%d]'s reference"
355 " relocation symbol.\n", machine->pid); 352 " relocation symbol.\n", machine->pid);
@@ -497,6 +494,12 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
497 494
498 rec->post_processing_offset = lseek(output, 0, SEEK_CUR); 495 rec->post_processing_offset = lseek(output, 0, SEEK_CUR);
499 496
497 machine = perf_session__find_host_machine(session);
498 if (!machine) {
499 pr_err("Couldn't find native kernel information.\n");
500 return -1;
501 }
502
500 if (opts->pipe_output) { 503 if (opts->pipe_output) {
501 err = perf_event__synthesize_attrs(ops, session, 504 err = perf_event__synthesize_attrs(ops, session,
502 process_synthesized_event); 505 process_synthesized_event);
@@ -506,7 +509,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
506 } 509 }
507 510
508 err = perf_event__synthesize_event_types(ops, process_synthesized_event, 511 err = perf_event__synthesize_event_types(ops, process_synthesized_event,
509 session); 512 machine);
510 if (err < 0) { 513 if (err < 0) {
511 pr_err("Couldn't synthesize event_types.\n"); 514 pr_err("Couldn't synthesize event_types.\n");
512 return err; 515 return err;
@@ -522,8 +525,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
522 * propagate errors that now are calling die() 525 * propagate errors that now are calling die()
523 */ 526 */
524 err = perf_event__synthesize_tracing_data(ops, output, evsel_list, 527 err = perf_event__synthesize_tracing_data(ops, output, evsel_list,
525 process_synthesized_event, 528 process_synthesized_event);
526 session);
527 if (err <= 0) { 529 if (err <= 0) {
528 pr_err("Couldn't record tracing data.\n"); 530 pr_err("Couldn't record tracing data.\n");
529 return err; 531 return err;
@@ -532,24 +534,18 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
532 } 534 }
533 } 535 }
534 536
535 machine = perf_session__find_host_machine(session);
536 if (!machine) {
537 pr_err("Couldn't find native kernel information.\n");
538 return -1;
539 }
540
541 err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, 537 err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
542 session, machine, "_text"); 538 machine, "_text");
543 if (err < 0) 539 if (err < 0)
544 err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, 540 err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
545 session, machine, "_stext"); 541 machine, "_stext");
546 if (err < 0) 542 if (err < 0)
547 pr_err("Couldn't record kernel reference relocation symbol\n" 543 pr_err("Couldn't record kernel reference relocation symbol\n"
548 "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" 544 "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
549 "Check /proc/kallsyms permission or run as root.\n"); 545 "Check /proc/kallsyms permission or run as root.\n");
550 546
551 err = perf_event__synthesize_modules(ops, process_synthesized_event, 547 err = perf_event__synthesize_modules(ops, process_synthesized_event,
552 session, machine); 548 machine);
553 if (err < 0) 549 if (err < 0)
554 pr_err("Couldn't record kernel module information.\n" 550 pr_err("Couldn't record kernel module information.\n"
555 "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" 551 "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)
562 if (!opts->system_wide) 558 if (!opts->system_wide)
563 perf_event__synthesize_thread_map(ops, evsel_list->threads, 559 perf_event__synthesize_thread_map(ops, evsel_list->threads,
564 process_synthesized_event, 560 process_synthesized_event,
565 session); 561 machine);
566 else 562 else
567 perf_event__synthesize_threads(ops, process_synthesized_event, 563 perf_event__synthesize_threads(ops, process_synthesized_event,
568 session); 564 machine);
569 565
570 if (rec->realtime_prio) { 566 if (rec->realtime_prio) {
571 struct sched_param param; 567 struct sched_param param;