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 | |
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')
-rw-r--r-- | tools/perf/builtin-annotate.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-kmem.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 11 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 9 | ||||
-rw-r--r-- | tools/perf/builtin-sched.c | 6 | ||||
-rw-r--r-- | tools/perf/builtin-timechart.c | 13 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 28 | ||||
-rw-r--r-- | tools/perf/builtin-trace.c | 23 | ||||
-rw-r--r-- | tools/perf/util/data_map.c | 27 | ||||
-rw-r--r-- | tools/perf/util/data_map.h | 5 | ||||
-rw-r--r-- | tools/perf/util/event.c | 37 | ||||
-rw-r--r-- | tools/perf/util/event.h | 19 |
12 files changed, 103 insertions, 79 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 21a78d30d53d..2e418b9fc1c4 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -132,7 +132,7 @@ static int hist_entry__add(struct addr_location *al, u64 count) | |||
132 | return 0; | 132 | return 0; |
133 | } | 133 | } |
134 | 134 | ||
135 | static int process_sample_event(event_t *event) | 135 | static int process_sample_event(event_t *event, struct perf_session *session __used) |
136 | { | 136 | { |
137 | struct addr_location al; | 137 | struct addr_location al; |
138 | 138 | ||
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 2071d2485913..101b2682b4df 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
@@ -312,7 +312,7 @@ process_raw_event(event_t *raw_event __used, void *data, | |||
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | static int process_sample_event(event_t *event) | 315 | static int process_sample_event(event_t *event, struct perf_session *session __used) |
316 | { | 316 | { |
317 | struct sample_data data; | 317 | struct sample_data data; |
318 | struct thread *thread; | 318 | struct thread *thread; |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 4decbd14eaed..b7e15a1b1ec2 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -123,7 +123,8 @@ static void write_event(event_t *buf, size_t size) | |||
123 | write_output(buf, size); | 123 | write_output(buf, size); |
124 | } | 124 | } |
125 | 125 | ||
126 | static int process_synthesized_event(event_t *event) | 126 | static int process_synthesized_event(event_t *event, |
127 | struct perf_session *self __used) | ||
127 | { | 128 | { |
128 | write_event(event, event->header.size); | 129 | write_event(event, event->header.size); |
129 | return 0; | 130 | return 0; |
@@ -488,9 +489,10 @@ static int __cmd_record(int argc, const char **argv) | |||
488 | } | 489 | } |
489 | 490 | ||
490 | if (!system_wide) | 491 | if (!system_wide) |
491 | event__synthesize_thread(pid, process_synthesized_event); | 492 | event__synthesize_thread(pid, process_synthesized_event, |
493 | session); | ||
492 | else | 494 | else |
493 | event__synthesize_threads(process_synthesized_event); | 495 | event__synthesize_threads(process_synthesized_event, session); |
494 | 496 | ||
495 | if (target_pid == -1 && argc) { | 497 | if (target_pid == -1 && argc) { |
496 | pid = fork(); | 498 | pid = fork(); |
@@ -510,7 +512,8 @@ static int __cmd_record(int argc, const char **argv) | |||
510 | */ | 512 | */ |
511 | usleep(1000); | 513 | usleep(1000); |
512 | event__synthesize_thread(pid, | 514 | event__synthesize_thread(pid, |
513 | process_synthesized_event); | 515 | process_synthesized_event, |
516 | session); | ||
514 | } | 517 | } |
515 | 518 | ||
516 | child_pid = pid; | 519 | child_pid = pid; |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index e2ec49a9b731..dcd8fedc298c 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -53,8 +53,6 @@ static int exclude_other = 1; | |||
53 | 53 | ||
54 | static char callchain_default_opt[] = "fractal,0.5"; | 54 | static char callchain_default_opt[] = "fractal,0.5"; |
55 | 55 | ||
56 | static struct perf_session *session; | ||
57 | |||
58 | static u64 sample_type; | 56 | static u64 sample_type; |
59 | 57 | ||
60 | struct symbol_conf symbol_conf; | 58 | struct symbol_conf symbol_conf; |
@@ -604,7 +602,7 @@ static int validate_chain(struct ip_callchain *chain, event_t *event) | |||
604 | return 0; | 602 | return 0; |
605 | } | 603 | } |
606 | 604 | ||
607 | static int process_sample_event(event_t *event) | 605 | static int process_sample_event(event_t *event, struct perf_session *session __used) |
608 | { | 606 | { |
609 | struct sample_data data; | 607 | struct sample_data data; |
610 | int cpumode; | 608 | int cpumode; |
@@ -683,7 +681,7 @@ static int process_sample_event(event_t *event) | |||
683 | return 0; | 681 | return 0; |
684 | } | 682 | } |
685 | 683 | ||
686 | static int process_comm_event(event_t *event) | 684 | static int process_comm_event(event_t *event, struct perf_session *session __used) |
687 | { | 685 | { |
688 | struct thread *thread = threads__findnew(event->comm.pid); | 686 | struct thread *thread = threads__findnew(event->comm.pid); |
689 | 687 | ||
@@ -698,7 +696,7 @@ static int process_comm_event(event_t *event) | |||
698 | return 0; | 696 | return 0; |
699 | } | 697 | } |
700 | 698 | ||
701 | static int process_read_event(event_t *event) | 699 | static int process_read_event(event_t *event, struct perf_session *session __used) |
702 | { | 700 | { |
703 | struct perf_event_attr *attr; | 701 | struct perf_event_attr *attr; |
704 | 702 | ||
@@ -766,6 +764,7 @@ static int __cmd_report(void) | |||
766 | { | 764 | { |
767 | struct thread *idle; | 765 | struct thread *idle; |
768 | int ret; | 766 | int ret; |
767 | struct perf_session *session; | ||
769 | 768 | ||
770 | session = perf_session__new(input_name, O_RDONLY, force); | 769 | session = perf_session__new(input_name, O_RDONLY, force); |
771 | if (session == NULL) | 770 | if (session == NULL) |
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 65021fe1361e..48ab283ed86b 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -1594,7 +1594,8 @@ process_raw_event(event_t *raw_event __used, void *data, | |||
1594 | process_sched_migrate_task_event(data, event, cpu, timestamp, thread); | 1594 | process_sched_migrate_task_event(data, event, cpu, timestamp, thread); |
1595 | } | 1595 | } |
1596 | 1596 | ||
1597 | static int process_sample_event(event_t *event) | 1597 | static int process_sample_event(event_t *event, |
1598 | struct perf_session *session __used) | ||
1598 | { | 1599 | { |
1599 | struct sample_data data; | 1600 | struct sample_data data; |
1600 | struct thread *thread; | 1601 | struct thread *thread; |
@@ -1632,7 +1633,8 @@ static int process_sample_event(event_t *event) | |||
1632 | return 0; | 1633 | return 0; |
1633 | } | 1634 | } |
1634 | 1635 | ||
1635 | static int process_lost_event(event_t *event __used) | 1636 | static int process_lost_event(event_t *event __used, |
1637 | struct perf_session *session __used) | ||
1636 | { | 1638 | { |
1637 | nr_lost_chunks++; | 1639 | nr_lost_chunks++; |
1638 | nr_lost_events += event->lost.lost; | 1640 | nr_lost_events += event->lost.lost; |
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 759dd2b35fdb..db6caae1a404 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
@@ -281,21 +281,19 @@ static int cpus_cstate_state[MAX_CPUS]; | |||
281 | static u64 cpus_pstate_start_times[MAX_CPUS]; | 281 | static u64 cpus_pstate_start_times[MAX_CPUS]; |
282 | static u64 cpus_pstate_state[MAX_CPUS]; | 282 | static u64 cpus_pstate_state[MAX_CPUS]; |
283 | 283 | ||
284 | static int | 284 | static int process_comm_event(event_t *event, struct perf_session *session __used) |
285 | process_comm_event(event_t *event) | ||
286 | { | 285 | { |
287 | pid_set_comm(event->comm.pid, event->comm.comm); | 286 | pid_set_comm(event->comm.pid, event->comm.comm); |
288 | return 0; | 287 | return 0; |
289 | } | 288 | } |
290 | static int | 289 | |
291 | process_fork_event(event_t *event) | 290 | static int process_fork_event(event_t *event, struct perf_session *session __used) |
292 | { | 291 | { |
293 | pid_fork(event->fork.pid, event->fork.ppid, event->fork.time); | 292 | pid_fork(event->fork.pid, event->fork.ppid, event->fork.time); |
294 | return 0; | 293 | return 0; |
295 | } | 294 | } |
296 | 295 | ||
297 | static int | 296 | static int process_exit_event(event_t *event, struct perf_session *session __used) |
298 | process_exit_event(event_t *event) | ||
299 | { | 297 | { |
300 | pid_exit(event->fork.pid, event->fork.time); | 298 | pid_exit(event->fork.pid, event->fork.time); |
301 | return 0; | 299 | return 0; |
@@ -594,8 +592,7 @@ static u64 sample_time(event_t *event) | |||
594 | * We first queue all events, sorted backwards by insertion. | 592 | * We first queue all events, sorted backwards by insertion. |
595 | * The order will get flipped later. | 593 | * The order will get flipped later. |
596 | */ | 594 | */ |
597 | static int | 595 | static int queue_sample_event(event_t *event, struct perf_session *session __used) |
598 | queue_sample_event(event_t *event) | ||
599 | { | 596 | { |
600 | struct sample_wrapper *copy, *prev; | 597 | struct sample_wrapper *copy, *prev; |
601 | int size; | 598 | int size; |
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); |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 0756664666f1..3057e1d387b9 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -62,10 +62,9 @@ static int cleanup_scripting(void) | |||
62 | 62 | ||
63 | static char const *input_name = "perf.data"; | 63 | static char const *input_name = "perf.data"; |
64 | 64 | ||
65 | static struct perf_session *session; | ||
66 | static u64 sample_type; | 65 | static u64 sample_type; |
67 | 66 | ||
68 | static int process_sample_event(event_t *event) | 67 | static int process_sample_event(event_t *event, struct perf_session *session __used) |
69 | { | 68 | { |
70 | struct sample_data data; | 69 | struct sample_data data; |
71 | struct thread *thread; | 70 | struct thread *thread; |
@@ -125,20 +124,12 @@ static struct perf_file_handler file_handler = { | |||
125 | .sample_type_check = sample_type_check, | 124 | .sample_type_check = sample_type_check, |
126 | }; | 125 | }; |
127 | 126 | ||
128 | static int __cmd_trace(void) | 127 | static int __cmd_trace(struct perf_session *session) |
129 | { | 128 | { |
130 | int err; | ||
131 | |||
132 | session = perf_session__new(input_name, O_RDONLY, 0); | ||
133 | if (session == NULL) | ||
134 | return -ENOMEM; | ||
135 | |||
136 | register_idle_thread(); | 129 | register_idle_thread(); |
137 | register_perf_file_handler(&file_handler); | 130 | register_perf_file_handler(&file_handler); |
138 | 131 | ||
139 | err = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd); | 132 | return perf_session__process_events(session, 0, &event__cwdlen, &event__cwd); |
140 | perf_session__delete(session); | ||
141 | return err; | ||
142 | } | 133 | } |
143 | 134 | ||
144 | struct script_spec { | 135 | struct script_spec { |
@@ -313,6 +304,7 @@ static const struct option options[] = { | |||
313 | int cmd_trace(int argc, const char **argv, const char *prefix __used) | 304 | int cmd_trace(int argc, const char **argv, const char *prefix __used) |
314 | { | 305 | { |
315 | int err; | 306 | int err; |
307 | struct perf_session *session; | ||
316 | 308 | ||
317 | symbol__init(0); | 309 | symbol__init(0); |
318 | 310 | ||
@@ -330,6 +322,10 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) | |||
330 | 322 | ||
331 | setup_pager(); | 323 | setup_pager(); |
332 | 324 | ||
325 | session = perf_session__new(input_name, O_RDONLY, 0); | ||
326 | if (session == NULL) | ||
327 | return -ENOMEM; | ||
328 | |||
333 | if (generate_script_lang) { | 329 | if (generate_script_lang) { |
334 | struct stat perf_stat; | 330 | struct stat perf_stat; |
335 | 331 | ||
@@ -367,8 +363,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) | |||
367 | goto out; | 363 | goto out; |
368 | } | 364 | } |
369 | 365 | ||
370 | err = __cmd_trace(); | 366 | err = __cmd_trace(session); |
371 | 367 | ||
368 | perf_session__delete(session); | ||
372 | cleanup_scripting(); | 369 | cleanup_scripting(); |
373 | out: | 370 | out: |
374 | return err; | 371 | return err; |
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c index 6d46dda53a29..22bcdfeff55c 100644 --- a/tools/perf/util/data_map.c +++ b/tools/perf/util/data_map.c | |||
@@ -8,7 +8,8 @@ static struct perf_file_handler *curr_handler; | |||
8 | static unsigned long mmap_window = 32; | 8 | static unsigned long mmap_window = 32; |
9 | static char __cwd[PATH_MAX]; | 9 | static char __cwd[PATH_MAX]; |
10 | 10 | ||
11 | static int process_event_stub(event_t *event __used) | 11 | static int process_event_stub(event_t *event __used, |
12 | struct perf_session *session __used) | ||
12 | { | 13 | { |
13 | dump_printf(": unhandled!\n"); | 14 | dump_printf(": unhandled!\n"); |
14 | return 0; | 15 | return 0; |
@@ -61,8 +62,8 @@ void event__print_totals(void) | |||
61 | event__name[i], event__total[i]); | 62 | event__name[i], event__total[i]); |
62 | } | 63 | } |
63 | 64 | ||
64 | static int | 65 | static int process_event(event_t *event, struct perf_session *session, |
65 | process_event(event_t *event, unsigned long offset, unsigned long head) | 66 | unsigned long offset, unsigned long head) |
66 | { | 67 | { |
67 | trace_event(event); | 68 | trace_event(event); |
68 | 69 | ||
@@ -77,23 +78,23 @@ process_event(event_t *event, unsigned long offset, unsigned long head) | |||
77 | 78 | ||
78 | switch (event->header.type) { | 79 | switch (event->header.type) { |
79 | case PERF_RECORD_SAMPLE: | 80 | case PERF_RECORD_SAMPLE: |
80 | return curr_handler->process_sample_event(event); | 81 | return curr_handler->process_sample_event(event, session); |
81 | case PERF_RECORD_MMAP: | 82 | case PERF_RECORD_MMAP: |
82 | return curr_handler->process_mmap_event(event); | 83 | return curr_handler->process_mmap_event(event, session); |
83 | case PERF_RECORD_COMM: | 84 | case PERF_RECORD_COMM: |
84 | return curr_handler->process_comm_event(event); | 85 | return curr_handler->process_comm_event(event, session); |
85 | case PERF_RECORD_FORK: | 86 | case PERF_RECORD_FORK: |
86 | return curr_handler->process_fork_event(event); | 87 | return curr_handler->process_fork_event(event, session); |
87 | case PERF_RECORD_EXIT: | 88 | case PERF_RECORD_EXIT: |
88 | return curr_handler->process_exit_event(event); | 89 | return curr_handler->process_exit_event(event, session); |
89 | case PERF_RECORD_LOST: | 90 | case PERF_RECORD_LOST: |
90 | return curr_handler->process_lost_event(event); | 91 | return curr_handler->process_lost_event(event, session); |
91 | case PERF_RECORD_READ: | 92 | case PERF_RECORD_READ: |
92 | return curr_handler->process_read_event(event); | 93 | return curr_handler->process_read_event(event, session); |
93 | case PERF_RECORD_THROTTLE: | 94 | case PERF_RECORD_THROTTLE: |
94 | return curr_handler->process_throttle_event(event); | 95 | return curr_handler->process_throttle_event(event, session); |
95 | case PERF_RECORD_UNTHROTTLE: | 96 | case PERF_RECORD_UNTHROTTLE: |
96 | return curr_handler->process_unthrottle_event(event); | 97 | return curr_handler->process_unthrottle_event(event, session); |
97 | default: | 98 | default: |
98 | curr_handler->total_unknown++; | 99 | curr_handler->total_unknown++; |
99 | return -1; | 100 | return -1; |
@@ -209,7 +210,7 @@ more: | |||
209 | (void *)(long)event->header.size, | 210 | (void *)(long)event->header.size, |
210 | event->header.type); | 211 | event->header.type); |
211 | 212 | ||
212 | if (!size || process_event(event, offset, head) < 0) { | 213 | if (!size || process_event(event, self, offset, head) < 0) { |
213 | 214 | ||
214 | dump_printf("%p [%p]: skipping unknown header type: %d\n", | 215 | dump_printf("%p [%p]: skipping unknown header type: %d\n", |
215 | (void *)(offset + head), | 216 | (void *)(offset + head), |
diff --git a/tools/perf/util/data_map.h b/tools/perf/util/data_map.h index 98c5b823388c..6d4ae52bc07b 100644 --- a/tools/perf/util/data_map.h +++ b/tools/perf/util/data_map.h | |||
@@ -5,7 +5,10 @@ | |||
5 | #include "header.h" | 5 | #include "header.h" |
6 | #include "session.h" | 6 | #include "session.h" |
7 | 7 | ||
8 | typedef int (*event_type_handler_t)(event_t *); | 8 | struct perf_session; |
9 | |||
10 | typedef int (*event_type_handler_t)(event_t *self, | ||
11 | struct perf_session *session); | ||
9 | 12 | ||
10 | struct perf_file_handler { | 13 | struct perf_file_handler { |
11 | event_type_handler_t process_sample_event; | 14 | event_type_handler_t process_sample_event; |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index ba0de90cd3d4..e2c489533c6d 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -5,7 +5,9 @@ | |||
5 | #include "thread.h" | 5 | #include "thread.h" |
6 | 6 | ||
7 | static pid_t event__synthesize_comm(pid_t pid, int full, | 7 | static pid_t event__synthesize_comm(pid_t pid, int full, |
8 | int (*process)(event_t *event)) | 8 | int (*process)(event_t *event, |
9 | struct perf_session *session), | ||
10 | struct perf_session *session) | ||
9 | { | 11 | { |
10 | event_t ev; | 12 | event_t ev; |
11 | char filename[PATH_MAX]; | 13 | char filename[PATH_MAX]; |
@@ -54,7 +56,7 @@ out_race: | |||
54 | if (!full) { | 56 | if (!full) { |
55 | ev.comm.tid = pid; | 57 | ev.comm.tid = pid; |
56 | 58 | ||
57 | process(&ev); | 59 | process(&ev, session); |
58 | goto out_fclose; | 60 | goto out_fclose; |
59 | } | 61 | } |
60 | 62 | ||
@@ -72,7 +74,7 @@ out_race: | |||
72 | 74 | ||
73 | ev.comm.tid = pid; | 75 | ev.comm.tid = pid; |
74 | 76 | ||
75 | process(&ev); | 77 | process(&ev, session); |
76 | } | 78 | } |
77 | closedir(tasks); | 79 | closedir(tasks); |
78 | 80 | ||
@@ -86,7 +88,9 @@ out_failure: | |||
86 | } | 88 | } |
87 | 89 | ||
88 | static int event__synthesize_mmap_events(pid_t pid, pid_t tgid, | 90 | static int event__synthesize_mmap_events(pid_t pid, pid_t tgid, |
89 | int (*process)(event_t *event)) | 91 | int (*process)(event_t *event, |
92 | struct perf_session *session), | ||
93 | struct perf_session *session) | ||
90 | { | 94 | { |
91 | char filename[PATH_MAX]; | 95 | char filename[PATH_MAX]; |
92 | FILE *fp; | 96 | FILE *fp; |
@@ -141,7 +145,7 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid, | |||
141 | ev.mmap.pid = tgid; | 145 | ev.mmap.pid = tgid; |
142 | ev.mmap.tid = pid; | 146 | ev.mmap.tid = pid; |
143 | 147 | ||
144 | process(&ev); | 148 | process(&ev, session); |
145 | } | 149 | } |
146 | } | 150 | } |
147 | 151 | ||
@@ -149,15 +153,20 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid, | |||
149 | return 0; | 153 | return 0; |
150 | } | 154 | } |
151 | 155 | ||
152 | int event__synthesize_thread(pid_t pid, int (*process)(event_t *event)) | 156 | int event__synthesize_thread(pid_t pid, |
157 | int (*process)(event_t *event, | ||
158 | struct perf_session *session), | ||
159 | struct perf_session *session) | ||
153 | { | 160 | { |
154 | pid_t tgid = event__synthesize_comm(pid, 1, process); | 161 | pid_t tgid = event__synthesize_comm(pid, 1, process, session); |
155 | if (tgid == -1) | 162 | if (tgid == -1) |
156 | return -1; | 163 | return -1; |
157 | return event__synthesize_mmap_events(pid, tgid, process); | 164 | return event__synthesize_mmap_events(pid, tgid, process, session); |
158 | } | 165 | } |
159 | 166 | ||
160 | void event__synthesize_threads(int (*process)(event_t *event)) | 167 | void event__synthesize_threads(int (*process)(event_t *event, |
168 | struct perf_session *session), | ||
169 | struct perf_session *session) | ||
161 | { | 170 | { |
162 | DIR *proc; | 171 | DIR *proc; |
163 | struct dirent dirent, *next; | 172 | struct dirent dirent, *next; |
@@ -171,7 +180,7 @@ void event__synthesize_threads(int (*process)(event_t *event)) | |||
171 | if (*end) /* only interested in proper numerical dirents */ | 180 | if (*end) /* only interested in proper numerical dirents */ |
172 | continue; | 181 | continue; |
173 | 182 | ||
174 | event__synthesize_thread(pid, process); | 183 | event__synthesize_thread(pid, process, session); |
175 | } | 184 | } |
176 | 185 | ||
177 | closedir(proc); | 186 | closedir(proc); |
@@ -182,7 +191,7 @@ int event__cwdlen; | |||
182 | 191 | ||
183 | struct events_stats event__stats; | 192 | struct events_stats event__stats; |
184 | 193 | ||
185 | int event__process_comm(event_t *self) | 194 | int event__process_comm(event_t *self, struct perf_session *session __used) |
186 | { | 195 | { |
187 | struct thread *thread = threads__findnew(self->comm.pid); | 196 | struct thread *thread = threads__findnew(self->comm.pid); |
188 | 197 | ||
@@ -196,14 +205,14 @@ int event__process_comm(event_t *self) | |||
196 | return 0; | 205 | return 0; |
197 | } | 206 | } |
198 | 207 | ||
199 | int event__process_lost(event_t *self) | 208 | int event__process_lost(event_t *self, struct perf_session *session __used) |
200 | { | 209 | { |
201 | dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost); | 210 | dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost); |
202 | event__stats.lost += self->lost.lost; | 211 | event__stats.lost += self->lost.lost; |
203 | return 0; | 212 | return 0; |
204 | } | 213 | } |
205 | 214 | ||
206 | int event__process_mmap(event_t *self) | 215 | int event__process_mmap(event_t *self, struct perf_session *session __used) |
207 | { | 216 | { |
208 | struct thread *thread = threads__findnew(self->mmap.pid); | 217 | struct thread *thread = threads__findnew(self->mmap.pid); |
209 | struct map *map = map__new(&self->mmap, MAP__FUNCTION, | 218 | struct map *map = map__new(&self->mmap, MAP__FUNCTION, |
@@ -224,7 +233,7 @@ int event__process_mmap(event_t *self) | |||
224 | return 0; | 233 | return 0; |
225 | } | 234 | } |
226 | 235 | ||
227 | int event__process_task(event_t *self) | 236 | int event__process_task(event_t *self, struct perf_session *session __used) |
228 | { | 237 | { |
229 | struct thread *thread = threads__findnew(self->fork.pid); | 238 | struct thread *thread = threads__findnew(self->fork.pid); |
230 | struct thread *parent = threads__findnew(self->fork.ppid); | 239 | struct thread *parent = threads__findnew(self->fork.ppid); |
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 51a96c2effde..6b6429b63da3 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -156,18 +156,25 @@ struct symbol *map__find_symbol_by_name(struct map *self, const char *name, | |||
156 | void map__fixup_start(struct map *self); | 156 | void map__fixup_start(struct map *self); |
157 | void map__fixup_end(struct map *self); | 157 | void map__fixup_end(struct map *self); |
158 | 158 | ||
159 | int event__synthesize_thread(pid_t pid, int (*process)(event_t *event)); | 159 | struct perf_session; |
160 | void event__synthesize_threads(int (*process)(event_t *event)); | 160 | |
161 | int event__synthesize_thread(pid_t pid, | ||
162 | int (*process)(event_t *event, | ||
163 | struct perf_session *session), | ||
164 | struct perf_session *session); | ||
165 | void event__synthesize_threads(int (*process)(event_t *event, | ||
166 | struct perf_session *session), | ||
167 | struct perf_session *session); | ||
161 | 168 | ||
162 | extern char *event__cwd; | 169 | extern char *event__cwd; |
163 | extern int event__cwdlen; | 170 | extern int event__cwdlen; |
164 | extern struct events_stats event__stats; | 171 | extern struct events_stats event__stats; |
165 | extern unsigned long event__total[PERF_RECORD_MAX]; | 172 | extern unsigned long event__total[PERF_RECORD_MAX]; |
166 | 173 | ||
167 | int event__process_comm(event_t *self); | 174 | int event__process_comm(event_t *self, struct perf_session *session); |
168 | int event__process_lost(event_t *self); | 175 | int event__process_lost(event_t *self, struct perf_session *session); |
169 | int event__process_mmap(event_t *self); | 176 | int event__process_mmap(event_t *self, struct perf_session *session); |
170 | int event__process_task(event_t *self); | 177 | int event__process_task(event_t *self, struct perf_session *session); |
171 | 178 | ||
172 | struct addr_location; | 179 | struct addr_location; |
173 | int event__preprocess_sample(const event_t *self, struct addr_location *al, | 180 | int event__preprocess_sample(const event_t *self, struct addr_location *al, |