aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-12-13 16:50:28 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-14 10:57:16 -0500
commitb3165f414416a717f72a376720564012af5a2e01 (patch)
treeb066e4ae00b7d4bdb7386f4054e6e3ace0b976c3 /tools/perf/builtin-top.c
parentec913369733923dbfd6bdff5953a918107059701 (diff)
perf session: Move the global threads list to perf_session
So that we can process two perf.data files. We still need to add a O_MMAP mode for perf_session so that we can do all the mmap stuff in it. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1260741029-4430-5-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index b13f42625549..0f7a4da2924c 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -20,8 +20,9 @@
20 20
21#include "perf.h" 21#include "perf.h"
22 22
23#include "util/symbol.h"
24#include "util/color.h" 23#include "util/color.h"
24#include "util/session.h"
25#include "util/symbol.h"
25#include "util/thread.h" 26#include "util/thread.h"
26#include "util/util.h" 27#include "util/util.h"
27#include <linux/rbtree.h> 28#include <linux/rbtree.h>
@@ -926,7 +927,8 @@ static int symbol_filter(struct map *map, struct symbol *sym)
926 return 0; 927 return 0;
927} 928}
928 929
929static void event__process_sample(const event_t *self, int counter) 930static void event__process_sample(const event_t *self,
931 struct perf_session *session, int counter)
930{ 932{
931 u64 ip = self->ip.ip; 933 u64 ip = self->ip.ip;
932 struct sym_entry *syme; 934 struct sym_entry *syme;
@@ -946,7 +948,7 @@ static void event__process_sample(const event_t *self, int counter)
946 return; 948 return;
947 } 949 }
948 950
949 if (event__preprocess_sample(self, &al, symbol_filter) < 0 || 951 if (event__preprocess_sample(self, session, &al, symbol_filter) < 0 ||
950 al.sym == NULL) 952 al.sym == NULL)
951 return; 953 return;
952 954
@@ -1053,7 +1055,7 @@ static void perf_session__mmap_read_counter(struct perf_session *self,
1053 } 1055 }
1054 1056
1055 if (event->header.type == PERF_RECORD_SAMPLE) 1057 if (event->header.type == PERF_RECORD_SAMPLE)
1056 event__process_sample(event, md->counter); 1058 event__process_sample(event, self, md->counter);
1057 else 1059 else
1058 event__process(event, self); 1060 event__process(event, self);
1059 old += size; 1061 old += size;
@@ -1157,10 +1159,13 @@ static int __cmd_top(void)
1157 int i, counter; 1159 int i, counter;
1158 int ret; 1160 int ret;
1159 /* 1161 /*
1160 * XXX perf_session__new should allow passing a O_MMAP, so that all this 1162 * FIXME: perf_session__new should allow passing a O_MMAP, so that all this
1161 * mmap reading, etc is encapsulated in it. 1163 * mmap reading, etc is encapsulated in it. Use O_WRONLY for now.
1162 */ 1164 */
1163 struct perf_session *session = NULL; 1165 struct perf_session *session = perf_session__new(NULL, O_WRONLY, false);
1166
1167 if (session == NULL)
1168 return -ENOMEM;
1164 1169
1165 if (target_pid != -1) 1170 if (target_pid != -1)
1166 event__synthesize_thread(target_pid, event__process, session); 1171 event__synthesize_thread(target_pid, event__process, session);