aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-12-19 07:04:24 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-01-24 14:40:13 -0500
commit34ba5122bf198c9cdfcbecc9b23eaa414244a3f6 (patch)
tree7793918dad08b64157ae66d605a3e5bd2b3abb1f /tools/perf
parent09ecbb07a5c9fa31dc72ee8fb1c3fbd1145448dd (diff)
perf machine: Simplify accessing the host machine
It is always there, no sense in calling a function named "perf_session__find_host_machine". Also no sense in checking if that function return is NULL, so ditch needless error handling. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> 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-a6a3zx3afbrxo8p2zqm5mxo8@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-kmem.c7
-rw-r--r--tools/perf/builtin-record.c7
-rw-r--r--tools/perf/builtin-top.c4
-rw-r--r--tools/perf/util/session.c2
-rw-r--r--tools/perf/util/session.h6
5 files changed, 5 insertions, 21 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 0b4b796167be..9fddca749ca2 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -340,7 +340,7 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
340 int n_lines, int is_caller) 340 int n_lines, int is_caller)
341{ 341{
342 struct rb_node *next; 342 struct rb_node *next;
343 struct machine *machine; 343 struct machine *machine = &session->machines.host;
344 344
345 printf("%.102s\n", graph_dotted_line); 345 printf("%.102s\n", graph_dotted_line);
346 printf(" %-34s |", is_caller ? "Callsite": "Alloc Ptr"); 346 printf(" %-34s |", is_caller ? "Callsite": "Alloc Ptr");
@@ -349,11 +349,6 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
349 349
350 next = rb_first(root); 350 next = rb_first(root);
351 351
352 machine = perf_session__find_host_machine(session);
353 if (!machine) {
354 pr_err("__print_result: couldn't find kernel information\n");
355 return;
356 }
357 while (next && n_lines--) { 352 while (next && n_lines--) {
358 struct alloc_stat *data = rb_entry(next, struct alloc_stat, 353 struct alloc_stat *data = rb_entry(next, struct alloc_stat,
359 node); 354 node);
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index a0b2427b509d..2ac690cad411 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -512,12 +512,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
512 512
513 rec->post_processing_offset = lseek(output, 0, SEEK_CUR); 513 rec->post_processing_offset = lseek(output, 0, SEEK_CUR);
514 514
515 machine = perf_session__find_host_machine(session); 515 machine = &session->machines.host;
516 if (!machine) {
517 pr_err("Couldn't find native kernel information.\n");
518 err = -1;
519 goto out_delete_session;
520 }
521 516
522 if (opts->pipe_output) { 517 if (opts->pipe_output) {
523 err = perf_event__synthesize_attrs(tool, session, 518 err = perf_event__synthesize_attrs(tool, session,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index e0ecebdde3fe..bc788126397b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -847,13 +847,13 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
847 ++top->us_samples; 847 ++top->us_samples;
848 if (top->hide_user_symbols) 848 if (top->hide_user_symbols)
849 continue; 849 continue;
850 machine = perf_session__find_host_machine(session); 850 machine = &session->machines.host;
851 break; 851 break;
852 case PERF_RECORD_MISC_KERNEL: 852 case PERF_RECORD_MISC_KERNEL:
853 ++top->kernel_samples; 853 ++top->kernel_samples;
854 if (top->hide_kernel_symbols) 854 if (top->hide_kernel_symbols)
855 continue; 855 continue;
856 machine = perf_session__find_host_machine(session); 856 machine = &session->machines.host;
857 break; 857 break;
858 case PERF_RECORD_MISC_GUEST_KERNEL: 858 case PERF_RECORD_MISC_GUEST_KERNEL:
859 ++top->guest_kernel_samples; 859 ++top->guest_kernel_samples;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 046b057c8f7f..bd85280bb6e8 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -821,7 +821,7 @@ static struct machine *
821 return perf_session__findnew_machine(session, pid); 821 return perf_session__findnew_machine(session, pid);
822 } 822 }
823 823
824 return perf_session__find_host_machine(session); 824 return &session->machines.host;
825} 825}
826 826
827static int perf_session_deliver_event(struct perf_session *session, 827static int perf_session_deliver_event(struct perf_session *session,
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index de4e68716626..b5c0847edfa9 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -75,12 +75,6 @@ void perf_session__set_id_hdr_size(struct perf_session *session);
75void perf_session__remove_thread(struct perf_session *self, struct thread *th); 75void perf_session__remove_thread(struct perf_session *self, struct thread *th);
76 76
77static inline 77static inline
78struct machine *perf_session__find_host_machine(struct perf_session *self)
79{
80 return &self->machines.host;
81}
82
83static inline
84struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid) 78struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid)
85{ 79{
86 return machines__find(&self->machines, pid); 80 return machines__find(&self->machines, pid);