diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-13 16:50:24 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-14 10:57:13 -0500 |
commit | d8f66248d6f25f7c935cc5307c43bf394db07272 (patch) | |
tree | f30b5512dd08e6a8713fa9fde158c75d57ce1d6b /tools/perf/builtin-top.c | |
parent | 2cd9046cc53dd2625e2cf5854d6cbb1ba61de914 (diff) |
perf session: Pass the perf_session to the event handling operations
They will need it to get the right threads list, etc.
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-1-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.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index e0a374d0e43a..b13f42625549 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -965,14 +965,14 @@ static void event__process_sample(const event_t *self, int counter) | |||
965 | } | 965 | } |
966 | } | 966 | } |
967 | 967 | ||
968 | static int event__process(event_t *event) | 968 | static int event__process(event_t *event, struct perf_session *session) |
969 | { | 969 | { |
970 | switch (event->header.type) { | 970 | switch (event->header.type) { |
971 | case PERF_RECORD_COMM: | 971 | case PERF_RECORD_COMM: |
972 | event__process_comm(event); | 972 | event__process_comm(event, session); |
973 | break; | 973 | break; |
974 | case PERF_RECORD_MMAP: | 974 | case PERF_RECORD_MMAP: |
975 | event__process_mmap(event); | 975 | event__process_mmap(event, session); |
976 | break; | 976 | break; |
977 | default: | 977 | default: |
978 | break; | 978 | break; |
@@ -999,7 +999,8 @@ static unsigned int mmap_read_head(struct mmap_data *md) | |||
999 | return head; | 999 | return head; |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | static void mmap_read_counter(struct mmap_data *md) | 1002 | static void perf_session__mmap_read_counter(struct perf_session *self, |
1003 | struct mmap_data *md) | ||
1003 | { | 1004 | { |
1004 | unsigned int head = mmap_read_head(md); | 1005 | unsigned int head = mmap_read_head(md); |
1005 | unsigned int old = md->prev; | 1006 | unsigned int old = md->prev; |
@@ -1054,7 +1055,7 @@ static void mmap_read_counter(struct mmap_data *md) | |||
1054 | if (event->header.type == PERF_RECORD_SAMPLE) | 1055 | if (event->header.type == PERF_RECORD_SAMPLE) |
1055 | event__process_sample(event, md->counter); | 1056 | event__process_sample(event, md->counter); |
1056 | else | 1057 | else |
1057 | event__process(event); | 1058 | event__process(event, self); |
1058 | old += size; | 1059 | old += size; |
1059 | } | 1060 | } |
1060 | 1061 | ||
@@ -1064,13 +1065,13 @@ static void mmap_read_counter(struct mmap_data *md) | |||
1064 | static struct pollfd event_array[MAX_NR_CPUS * MAX_COUNTERS]; | 1065 | static struct pollfd event_array[MAX_NR_CPUS * MAX_COUNTERS]; |
1065 | static struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS]; | 1066 | static struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS]; |
1066 | 1067 | ||
1067 | static void mmap_read(void) | 1068 | static void perf_session__mmap_read(struct perf_session *self) |
1068 | { | 1069 | { |
1069 | int i, counter; | 1070 | int i, counter; |
1070 | 1071 | ||
1071 | for (i = 0; i < nr_cpus; i++) { | 1072 | for (i = 0; i < nr_cpus; i++) { |
1072 | for (counter = 0; counter < nr_counters; counter++) | 1073 | for (counter = 0; counter < nr_counters; counter++) |
1073 | mmap_read_counter(&mmap_array[i][counter]); | 1074 | perf_session__mmap_read_counter(self, &mmap_array[i][counter]); |
1074 | } | 1075 | } |
1075 | } | 1076 | } |
1076 | 1077 | ||
@@ -1155,11 +1156,16 @@ static int __cmd_top(void) | |||
1155 | pthread_t thread; | 1156 | pthread_t thread; |
1156 | int i, counter; | 1157 | int i, counter; |
1157 | int ret; | 1158 | int ret; |
1159 | /* | ||
1160 | * XXX perf_session__new should allow passing a O_MMAP, so that all this | ||
1161 | * mmap reading, etc is encapsulated in it. | ||
1162 | */ | ||
1163 | struct perf_session *session = NULL; | ||
1158 | 1164 | ||
1159 | if (target_pid != -1) | 1165 | if (target_pid != -1) |
1160 | event__synthesize_thread(target_pid, event__process); | 1166 | event__synthesize_thread(target_pid, event__process, session); |
1161 | else | 1167 | else |
1162 | event__synthesize_threads(event__process); | 1168 | event__synthesize_threads(event__process, session); |
1163 | 1169 | ||
1164 | for (i = 0; i < nr_cpus; i++) { | 1170 | for (i = 0; i < nr_cpus; i++) { |
1165 | group_fd = -1; | 1171 | group_fd = -1; |
@@ -1170,7 +1176,7 @@ static int __cmd_top(void) | |||
1170 | /* Wait for a minimal set of events before starting the snapshot */ | 1176 | /* Wait for a minimal set of events before starting the snapshot */ |
1171 | poll(event_array, nr_poll, 100); | 1177 | poll(event_array, nr_poll, 100); |
1172 | 1178 | ||
1173 | mmap_read(); | 1179 | perf_session__mmap_read(session); |
1174 | 1180 | ||
1175 | if (pthread_create(&thread, NULL, display_thread, NULL)) { | 1181 | if (pthread_create(&thread, NULL, display_thread, NULL)) { |
1176 | printf("Could not create display thread.\n"); | 1182 | printf("Could not create display thread.\n"); |
@@ -1190,7 +1196,7 @@ static int __cmd_top(void) | |||
1190 | while (1) { | 1196 | while (1) { |
1191 | int hits = samples; | 1197 | int hits = samples; |
1192 | 1198 | ||
1193 | mmap_read(); | 1199 | perf_session__mmap_read(session); |
1194 | 1200 | ||
1195 | if (hits == samples) | 1201 | if (hits == samples) |
1196 | ret = poll(event_array, nr_poll, 100); | 1202 | ret = poll(event_array, nr_poll, 100); |