aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-01-29 11:01:45 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-29 13:25:37 -0500
commit8115d60c323dd9931b95221c0a392aeddc1d6ef3 (patch)
tree13e75d71c5163c78efc9d8ab33988cc6c7be74a1 /tools/perf
parent8d50e5b4171a69cf48ca94a1e7c14033d0b4771d (diff)
perf tools: Kill event_t typedef, use 'union perf_event' instead
And move the event_t methods to the perf_event__ too. No code changes, just namespace consistency. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-annotate.c11
-rw-r--r--tools/perf/builtin-diff.c14
-rw-r--r--tools/perf/builtin-inject.c82
-rw-r--r--tools/perf/builtin-kmem.c10
-rw-r--r--tools/perf/builtin-lock.c6
-rw-r--r--tools/perf/builtin-record.c56
-rw-r--r--tools/perf/builtin-report.c30
-rw-r--r--tools/perf/builtin-sched.c15
-rw-r--r--tools/perf/builtin-script.c17
-rw-r--r--tools/perf/builtin-test.c6
-rw-r--r--tools/perf/builtin-timechart.c11
-rw-r--r--tools/perf/builtin-top.c33
-rw-r--r--tools/perf/util/build-id.c19
-rw-r--r--tools/perf/util/callchain.c3
-rw-r--r--tools/perf/util/callchain.h4
-rw-r--r--tools/perf/util/debug.c2
-rw-r--r--tools/perf/util/debug.h2
-rw-r--r--tools/perf/util/event.c187
-rw-r--r--tools/perf/util/event.h69
-rw-r--r--tools/perf/util/evlist.c6
-rw-r--r--tools/perf/util/evlist.h4
-rw-r--r--tools/perf/util/evsel.c10
-rw-r--r--tools/perf/util/header.c83
-rw-r--r--tools/perf/util/header.h50
-rw-r--r--tools/perf/util/hist.c2
-rw-r--r--tools/perf/util/session.c169
-rw-r--r--tools/perf/util/session.h13
27 files changed, 475 insertions, 439 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index ef3675135414..70067862e07f 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -58,12 +58,13 @@ static int hists__add_entry(struct hists *self, struct addr_location *al)
58 return hist_entry__inc_addr_samples(he, al->addr); 58 return hist_entry__inc_addr_samples(he, al->addr);
59} 59}
60 60
61static int process_sample_event(event_t *event, struct perf_sample *sample, 61static int process_sample_event(union perf_event *event,
62 struct perf_sample *sample,
62 struct perf_session *session) 63 struct perf_session *session)
63{ 64{
64 struct addr_location al; 65 struct addr_location al;
65 66
66 if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) { 67 if (perf_event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
67 pr_warning("problem processing %d event, skipping it.\n", 68 pr_warning("problem processing %d event, skipping it.\n",
68 event->header.type); 69 event->header.type);
69 return -1; 70 return -1;
@@ -372,9 +373,9 @@ find_next:
372 373
373static struct perf_event_ops event_ops = { 374static struct perf_event_ops event_ops = {
374 .sample = process_sample_event, 375 .sample = process_sample_event,
375 .mmap = event__process_mmap, 376 .mmap = perf_event__process_mmap,
376 .comm = event__process_comm, 377 .comm = perf_event__process_comm,
377 .fork = event__process_task, 378 .fork = perf_event__process_task,
378 .ordered_samples = true, 379 .ordered_samples = true,
379 .ordering_requires_timestamps = true, 380 .ordering_requires_timestamps = true,
380}; 381};
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 0822149dc768..6b7d91160ecb 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -30,13 +30,13 @@ static int hists__add_entry(struct hists *self,
30 return -ENOMEM; 30 return -ENOMEM;
31} 31}
32 32
33static int diff__process_sample_event(event_t *event, 33static int diff__process_sample_event(union perf_event *event,
34 struct perf_sample *sample, 34 struct perf_sample *sample,
35 struct perf_session *session) 35 struct perf_session *session)
36{ 36{
37 struct addr_location al; 37 struct addr_location al;
38 38
39 if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) { 39 if (perf_event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
40 pr_warning("problem processing %d event, skipping it.\n", 40 pr_warning("problem processing %d event, skipping it.\n",
41 event->header.type); 41 event->header.type);
42 return -1; 42 return -1;
@@ -56,11 +56,11 @@ static int diff__process_sample_event(event_t *event,
56 56
57static struct perf_event_ops event_ops = { 57static struct perf_event_ops event_ops = {
58 .sample = diff__process_sample_event, 58 .sample = diff__process_sample_event,
59 .mmap = event__process_mmap, 59 .mmap = perf_event__process_mmap,
60 .comm = event__process_comm, 60 .comm = perf_event__process_comm,
61 .exit = event__process_task, 61 .exit = perf_event__process_task,
62 .fork = event__process_task, 62 .fork = perf_event__process_task,
63 .lost = event__process_lost, 63 .lost = perf_event__process_lost,
64 .ordered_samples = true, 64 .ordered_samples = true,
65 .ordering_requires_timestamps = true, 65 .ordering_requires_timestamps = true,
66}; 66};
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 4c9388ce878c..e29f04ed3396 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -16,8 +16,8 @@
16static char const *input_name = "-"; 16static char const *input_name = "-";
17static bool inject_build_ids; 17static bool inject_build_ids;
18 18
19static int event__repipe_synth(event_t *event, 19static int perf_event__repipe_synth(union perf_event *event,
20 struct perf_session *session __used) 20 struct perf_session *session __used)
21{ 21{
22 uint32_t size; 22 uint32_t size;
23 void *buf = event; 23 void *buf = event;
@@ -36,41 +36,44 @@ static int event__repipe_synth(event_t *event,
36 return 0; 36 return 0;
37} 37}
38 38
39static int event__repipe(event_t *event, struct perf_sample *sample __used, 39static int perf_event__repipe(union perf_event *event,
40 struct perf_session *session) 40 struct perf_sample *sample __used,
41 struct perf_session *session)
41{ 42{
42 return event__repipe_synth(event, session); 43 return perf_event__repipe_synth(event, session);
43} 44}
44 45
45static int event__repipe_mmap(event_t *self, struct perf_sample *sample, 46static int perf_event__repipe_mmap(union perf_event *event,
46 struct perf_session *session) 47 struct perf_sample *sample,
48 struct perf_session *session)
47{ 49{
48 int err; 50 int err;
49 51
50 err = event__process_mmap(self, sample, session); 52 err = perf_event__process_mmap(event, sample, session);
51 event__repipe(self, sample, session); 53 perf_event__repipe(event, sample, session);
52 54
53 return err; 55 return err;
54} 56}
55 57
56static int event__repipe_task(event_t *self, struct perf_sample *sample, 58static int perf_event__repipe_task(union perf_event *event,
57 struct perf_session *session) 59 struct perf_sample *sample,
60 struct perf_session *session)
58{ 61{
59 int err; 62 int err;
60 63
61 err = event__process_task(self, sample, session); 64 err = perf_event__process_task(event, sample, session);
62 event__repipe(self, sample, session); 65 perf_event__repipe(event, sample, session);
63 66
64 return err; 67 return err;
65} 68}
66 69
67static int event__repipe_tracing_data(event_t *self, 70static int perf_event__repipe_tracing_data(union perf_event *event,
68 struct perf_session *session) 71 struct perf_session *session)
69{ 72{
70 int err; 73 int err;
71 74
72 event__repipe_synth(self, session); 75 perf_event__repipe_synth(event, session);
73 err = event__process_tracing_data(self, session); 76 err = perf_event__process_tracing_data(event, session);
74 77
75 return err; 78 return err;
76} 79}
@@ -109,8 +112,8 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)
109 if (self->kernel) 112 if (self->kernel)
110 misc = PERF_RECORD_MISC_KERNEL; 113 misc = PERF_RECORD_MISC_KERNEL;
111 114
112 err = event__synthesize_build_id(self, misc, event__repipe, 115 err = perf_event__synthesize_build_id(self, misc, perf_event__repipe,
113 machine, session); 116 machine, session);
114 if (err) { 117 if (err) {
115 pr_err("Can't synthesize build_id event for %s\n", self->long_name); 118 pr_err("Can't synthesize build_id event for %s\n", self->long_name);
116 return -1; 119 return -1;
@@ -119,8 +122,9 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)
119 return 0; 122 return 0;
120} 123}
121 124
122static int event__inject_buildid(event_t *event, struct perf_sample *sample, 125static int perf_event__inject_buildid(union perf_event *event,
123 struct perf_session *session) 126 struct perf_sample *sample,
127 struct perf_session *session)
124{ 128{
125 struct addr_location al; 129 struct addr_location al;
126 struct thread *thread; 130 struct thread *thread;
@@ -155,24 +159,24 @@ static int event__inject_buildid(event_t *event, struct perf_sample *sample,
155 } 159 }
156 160
157repipe: 161repipe:
158 event__repipe(event, sample, session); 162 perf_event__repipe(event, sample, session);
159 return 0; 163 return 0;
160} 164}
161 165
162struct perf_event_ops inject_ops = { 166struct perf_event_ops inject_ops = {
163 .sample = event__repipe, 167 .sample = perf_event__repipe,
164 .mmap = event__repipe, 168 .mmap = perf_event__repipe,
165 .comm = event__repipe, 169 .comm = perf_event__repipe,
166 .fork = event__repipe, 170 .fork = perf_event__repipe,
167 .exit = event__repipe, 171 .exit = perf_event__repipe,
168 .lost = event__repipe, 172 .lost = perf_event__repipe,
169 .read = event__repipe, 173 .read = perf_event__repipe,
170 .throttle = event__repipe, 174 .throttle = perf_event__repipe,
171 .unthrottle = event__repipe, 175 .unthrottle = perf_event__repipe,
172 .attr = event__repipe_synth, 176 .attr = perf_event__repipe_synth,
173 .event_type = event__repipe_synth, 177 .event_type = perf_event__repipe_synth,
174 .tracing_data = event__repipe_synth, 178 .tracing_data = perf_event__repipe_synth,
175 .build_id = event__repipe_synth, 179 .build_id = perf_event__repipe_synth,
176}; 180};
177 181
178extern volatile int session_done; 182extern volatile int session_done;
@@ -190,10 +194,10 @@ static int __cmd_inject(void)
190 signal(SIGINT, sig_handler); 194 signal(SIGINT, sig_handler);
191 195
192 if (inject_build_ids) { 196 if (inject_build_ids) {
193 inject_ops.sample = event__inject_buildid; 197 inject_ops.sample = perf_event__inject_buildid;
194 inject_ops.mmap = event__repipe_mmap; 198 inject_ops.mmap = perf_event__repipe_mmap;
195 inject_ops.fork = event__repipe_task; 199 inject_ops.fork = perf_event__repipe_task;
196 inject_ops.tracing_data = event__repipe_tracing_data; 200 inject_ops.tracing_data = perf_event__repipe_tracing_data;
197 } 201 }
198 202
199 session = perf_session__new(input_name, O_RDONLY, false, true, &inject_ops); 203 session = perf_session__new(input_name, O_RDONLY, false, true, &inject_ops);
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 3c1cdcf29902..7f618f4e7b79 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -275,9 +275,8 @@ static void process_free_event(void *data,
275 s_alloc->alloc_cpu = -1; 275 s_alloc->alloc_cpu = -1;
276} 276}
277 277
278static void 278static void process_raw_event(union perf_event *raw_event __used, void *data,
279process_raw_event(event_t *raw_event __used, void *data, 279 int cpu, u64 timestamp, struct thread *thread)
280 int cpu, u64 timestamp, struct thread *thread)
281{ 280{
282 struct event *event; 281 struct event *event;
283 int type; 282 int type;
@@ -304,7 +303,8 @@ process_raw_event(event_t *raw_event __used, void *data,
304 } 303 }
305} 304}
306 305
307static int process_sample_event(event_t *event, struct perf_sample *sample, 306static int process_sample_event(union perf_event *event,
307 struct perf_sample *sample,
308 struct perf_session *session) 308 struct perf_session *session)
309{ 309{
310 struct thread *thread = perf_session__findnew(session, event->ip.pid); 310 struct thread *thread = perf_session__findnew(session, event->ip.pid);
@@ -325,7 +325,7 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
325 325
326static struct perf_event_ops event_ops = { 326static struct perf_event_ops event_ops = {
327 .sample = process_sample_event, 327 .sample = process_sample_event,
328 .comm = event__process_comm, 328 .comm = perf_event__process_comm,
329 .ordered_samples = true, 329 .ordered_samples = true,
330}; 330};
331 331
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index c3f512791344..e00d93847c44 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -834,14 +834,14 @@ static void dump_info(void)
834 die("Unknown type of information\n"); 834 die("Unknown type of information\n");
835} 835}
836 836
837static int process_sample_event(event_t *self, struct perf_sample *sample, 837static int process_sample_event(union perf_event *event, struct perf_sample *sample,
838 struct perf_session *s) 838 struct perf_session *s)
839{ 839{
840 struct thread *thread = perf_session__findnew(s, sample->tid); 840 struct thread *thread = perf_session__findnew(s, sample->tid);
841 841
842 if (thread == NULL) { 842 if (thread == NULL) {
843 pr_debug("problem processing %d event, skipping it.\n", 843 pr_debug("problem processing %d event, skipping it.\n",
844 self->header.type); 844 event->header.type);
845 return -1; 845 return -1;
846 } 846 }
847 847
@@ -852,7 +852,7 @@ static int process_sample_event(event_t *self, struct perf_sample *sample,
852 852
853static struct perf_event_ops eops = { 853static struct perf_event_ops eops = {
854 .sample = process_sample_event, 854 .sample = process_sample_event,
855 .comm = event__process_comm, 855 .comm = perf_event__process_comm,
856 .ordered_samples = true, 856 .ordered_samples = true,
857}; 857};
858 858
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 5d3e4b32072b..edc3555098c8 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -100,7 +100,7 @@ static void write_output(void *buf, size_t size)
100 } 100 }
101} 101}
102 102
103static int process_synthesized_event(event_t *event, 103static int process_synthesized_event(union perf_event *event,
104 struct perf_sample *sample __used, 104 struct perf_sample *sample __used,
105 struct perf_session *self __used) 105 struct perf_session *self __used)
106{ 106{
@@ -404,7 +404,7 @@ static void atexit_header(void)
404 } 404 }
405} 405}
406 406
407static void event__synthesize_guest_os(struct machine *machine, void *data) 407static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
408{ 408{
409 int err; 409 int err;
410 struct perf_session *psession = data; 410 struct perf_session *psession = data;
@@ -420,8 +420,8 @@ static void event__synthesize_guest_os(struct machine *machine, void *data)
420 *method is used to avoid symbol missing when the first addr is 420 *method is used to avoid symbol missing when the first addr is
421 *in module instead of in guest kernel. 421 *in module instead of in guest kernel.
422 */ 422 */
423 err = event__synthesize_modules(process_synthesized_event, 423 err = perf_event__synthesize_modules(process_synthesized_event,
424 psession, machine); 424 psession, machine);
425 if (err < 0) 425 if (err < 0)
426 pr_err("Couldn't record guest kernel [%d]'s reference" 426 pr_err("Couldn't record guest kernel [%d]'s reference"
427 " relocation symbol.\n", machine->pid); 427 " relocation symbol.\n", machine->pid);
@@ -430,11 +430,12 @@ static void event__synthesize_guest_os(struct machine *machine, void *data)
430 * We use _stext for guest kernel because guest kernel's /proc/kallsyms 430 * We use _stext for guest kernel because guest kernel's /proc/kallsyms
431 * have no _text sometimes. 431 * have no _text sometimes.
432 */ 432 */
433 err = event__synthesize_kernel_mmap(process_synthesized_event, 433 err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
434 psession, machine, "_text"); 434 psession, machine, "_text");
435 if (err < 0) 435 if (err < 0)
436 err = event__synthesize_kernel_mmap(process_synthesized_event, 436 err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
437 psession, machine, "_stext"); 437 psession, machine,
438 "_stext");
438 if (err < 0) 439 if (err < 0)
439 pr_err("Couldn't record guest kernel [%d]'s reference" 440 pr_err("Couldn't record guest kernel [%d]'s reference"
440 " relocation symbol.\n", machine->pid); 441 " relocation symbol.\n", machine->pid);
@@ -617,16 +618,16 @@ static int __cmd_record(int argc, const char **argv)
617 perf_session__set_sample_id_all(session, sample_id_all_avail); 618 perf_session__set_sample_id_all(session, sample_id_all_avail);
618 619
619 if (pipe_output) { 620 if (pipe_output) {
620 err = event__synthesize_attrs(&session->header, 621 err = perf_event__synthesize_attrs(&session->header,
621 process_synthesized_event, 622 process_synthesized_event,
622 session); 623 session);
623 if (err < 0) { 624 if (err < 0) {
624 pr_err("Couldn't synthesize attrs.\n"); 625 pr_err("Couldn't synthesize attrs.\n");
625 return err; 626 return err;
626 } 627 }
627 628
628 err = event__synthesize_event_types(process_synthesized_event, 629 err = perf_event__synthesize_event_types(process_synthesized_event,
629 session); 630 session);
630 if (err < 0) { 631 if (err < 0) {
631 pr_err("Couldn't synthesize event_types.\n"); 632 pr_err("Couldn't synthesize event_types.\n");
632 return err; 633 return err;
@@ -641,9 +642,9 @@ static int __cmd_record(int argc, const char **argv)
641 * return this more properly and also 642 * return this more properly and also
642 * propagate errors that now are calling die() 643 * propagate errors that now are calling die()
643 */ 644 */
644 err = event__synthesize_tracing_data(output, evsel_list, 645 err = perf_event__synthesize_tracing_data(output, evsel_list,
645 process_synthesized_event, 646 process_synthesized_event,
646 session); 647 session);
647 if (err <= 0) { 648 if (err <= 0) {
648 pr_err("Couldn't record tracing data.\n"); 649 pr_err("Couldn't record tracing data.\n");
649 return err; 650 return err;
@@ -658,31 +659,34 @@ static int __cmd_record(int argc, const char **argv)
658 return -1; 659 return -1;
659 } 660 }
660 661
661 err = event__synthesize_kernel_mmap(process_synthesized_event, 662 err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
662 session, machine, "_text"); 663 session, machine, "_text");
663 if (err < 0) 664 if (err < 0)
664 err = event__synthesize_kernel_mmap(process_synthesized_event, 665 err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
665 session, machine, "_stext"); 666 session, machine, "_stext");
666 if (err < 0) 667 if (err < 0)
667 pr_err("Couldn't record kernel reference relocation symbol\n" 668 pr_err("Couldn't record kernel reference relocation symbol\n"
668 "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" 669 "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
669 "Check /proc/kallsyms permission or run as root.\n"); 670 "Check /proc/kallsyms permission or run as root.\n");
670 671
671 err = event__synthesize_modules(process_synthesized_event, 672 err = perf_event__synthesize_modules(process_synthesized_event,
672 session, machine); 673 session, machine);
673 if (err < 0) 674 if (err < 0)
674 pr_err("Couldn't record kernel module information.\n" 675 pr_err("Couldn't record kernel module information.\n"
675 "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" 676 "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
676 "Check /proc/modules permission or run as root.\n"); 677 "Check /proc/modules permission or run as root.\n");
677 678
678 if (perf_guest) 679 if (perf_guest)
679 perf_session__process_machines(session, event__synthesize_guest_os); 680 perf_session__process_machines(session,
681 perf_event__synthesize_guest_os);
680 682
681 if (!system_wide) 683 if (!system_wide)
682 event__synthesize_thread(target_tid, process_synthesized_event, 684 perf_event__synthesize_thread(target_tid,
683 session); 685 process_synthesized_event,
686 session);
684 else 687 else
685 event__synthesize_threads(process_synthesized_event, session); 688 perf_event__synthesize_threads(process_synthesized_event,
689 session);
686 690
687 if (realtime_prio) { 691 if (realtime_prio) {
688 struct sched_param param; 692 struct sched_param param;
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index bbbadcc04097..a6a4e5457b6f 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -149,13 +149,14 @@ static int add_event_total(struct perf_session *session,
149 return 0; 149 return 0;
150} 150}
151 151
152static int process_sample_event(event_t *event, struct perf_sample *sample, 152static int process_sample_event(union perf_event *event,
153 struct perf_sample *sample,
153 struct perf_session *session) 154 struct perf_session *session)
154{ 155{
155 struct addr_location al; 156 struct addr_location al;
156 struct perf_event_attr *attr; 157 struct perf_event_attr *attr;
157 158
158 if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) { 159 if (perf_event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
159 fprintf(stderr, "problem processing %d event, skipping it.\n", 160 fprintf(stderr, "problem processing %d event, skipping it.\n",
160 event->header.type); 161 event->header.type);
161 return -1; 162 return -1;
@@ -179,7 +180,8 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
179 return 0; 180 return 0;
180} 181}
181 182
182static int process_read_event(event_t *event, struct perf_sample *sample __used, 183static int process_read_event(union perf_event *event,
184 struct perf_sample *sample __used,
183 struct perf_session *session __used) 185 struct perf_session *session __used)
184{ 186{
185 struct perf_event_attr *attr; 187 struct perf_event_attr *attr;
@@ -232,17 +234,17 @@ static int perf_session__setup_sample_type(struct perf_session *self)
232} 234}
233 235
234static struct perf_event_ops event_ops = { 236static struct perf_event_ops event_ops = {
235 .sample = process_sample_event, 237 .sample = process_sample_event,
236 .mmap = event__process_mmap, 238 .mmap = perf_event__process_mmap,
237 .comm = event__process_comm, 239 .comm = perf_event__process_comm,
238 .exit = event__process_task, 240 .exit = perf_event__process_task,
239 .fork = event__process_task, 241 .fork = perf_event__process_task,
240 .lost = event__process_lost, 242 .lost = perf_event__process_lost,
241 .read = process_read_event, 243 .read = process_read_event,
242 .attr = event__process_attr, 244 .attr = perf_event__process_attr,
243 .event_type = event__process_event_type, 245 .event_type = perf_event__process_event_type,
244 .tracing_data = event__process_tracing_data, 246 .tracing_data = perf_event__process_tracing_data,
245 .build_id = event__process_build_id, 247 .build_id = perf_event__process_build_id,
246 .ordered_samples = true, 248 .ordered_samples = true,
247 .ordering_requires_timestamps = true, 249 .ordering_requires_timestamps = true,
248}; 250};
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index ff993c8b175d..ae2621182927 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1580,9 +1580,9 @@ process_sched_migrate_task_event(void *data, struct perf_session *session,
1580 event, cpu, timestamp, thread); 1580 event, cpu, timestamp, thread);
1581} 1581}
1582 1582
1583static void 1583static void process_raw_event(union perf_event *raw_event __used,
1584process_raw_event(event_t *raw_event __used, struct perf_session *session, 1584 struct perf_session *session, void *data, int cpu,
1585 void *data, int cpu, u64 timestamp, struct thread *thread) 1585 u64 timestamp, struct thread *thread)
1586{ 1586{
1587 struct event *event; 1587 struct event *event;
1588 int type; 1588 int type;
@@ -1607,7 +1607,8 @@ process_raw_event(event_t *raw_event __used, struct perf_session *session,
1607 process_sched_migrate_task_event(data, session, event, cpu, timestamp, thread); 1607 process_sched_migrate_task_event(data, session, event, cpu, timestamp, thread);
1608} 1608}
1609 1609
1610static int process_sample_event(event_t *event, struct perf_sample *sample, 1610static int process_sample_event(union perf_event *event,
1611 struct perf_sample *sample,
1611 struct perf_session *session) 1612 struct perf_session *session)
1612{ 1613{
1613 struct thread *thread; 1614 struct thread *thread;
@@ -1635,9 +1636,9 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
1635 1636
1636static struct perf_event_ops event_ops = { 1637static struct perf_event_ops event_ops = {
1637 .sample = process_sample_event, 1638 .sample = process_sample_event,
1638 .comm = event__process_comm, 1639 .comm = perf_event__process_comm,
1639 .lost = event__process_lost, 1640 .lost = perf_event__process_lost,
1640 .fork = event__process_task, 1641 .fork = perf_event__process_task,
1641 .ordered_samples = true, 1642 .ordered_samples = true,
1642}; 1643};
1643 1644
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 5c4c809008af..5f40df635dcb 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -63,7 +63,8 @@ static int cleanup_scripting(void)
63 63
64static char const *input_name = "perf.data"; 64static char const *input_name = "perf.data";
65 65
66static int process_sample_event(event_t *event, struct perf_sample *sample, 66static int process_sample_event(union perf_event *event,
67 struct perf_sample *sample,
67 struct perf_session *session) 68 struct perf_session *session)
68{ 69{
69 struct thread *thread = perf_session__findnew(session, event->ip.pid); 70 struct thread *thread = perf_session__findnew(session, event->ip.pid);
@@ -100,14 +101,14 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
100} 101}
101 102
102static struct perf_event_ops event_ops = { 103static struct perf_event_ops event_ops = {
103 .sample = process_sample_event, 104 .sample = process_sample_event,
104 .comm = event__process_comm, 105 .comm = perf_event__process_comm,
105 .attr = event__process_attr, 106 .attr = perf_event__process_attr,
106 .event_type = event__process_event_type, 107 .event_type = perf_event__process_event_type,
107 .tracing_data = event__process_tracing_data, 108 .tracing_data = perf_event__process_tracing_data,
108 .build_id = event__process_build_id, 109 .build_id = perf_event__process_build_id,
109 .ordering_requires_timestamps = true,
110 .ordered_samples = true, 110 .ordered_samples = true,
111 .ordering_requires_timestamps = true,
111}; 112};
112 113
113extern volatile int session_done; 114extern volatile int session_done;
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index df62433a34a7..845b9bd54ed4 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -454,7 +454,7 @@ out_thread_map_delete:
454static int test__basic_mmap(void) 454static int test__basic_mmap(void)
455{ 455{
456 int err = -1; 456 int err = -1;
457 event_t *event; 457 union perf_event *event;
458 struct thread_map *threads; 458 struct thread_map *threads;
459 struct cpu_map *cpus; 459 struct cpu_map *cpus;
460 struct perf_evlist *evlist; 460 struct perf_evlist *evlist;
@@ -554,11 +554,11 @@ static int test__basic_mmap(void)
554 554
555 if (event->header.type != PERF_RECORD_SAMPLE) { 555 if (event->header.type != PERF_RECORD_SAMPLE) {
556 pr_debug("unexpected %s event\n", 556 pr_debug("unexpected %s event\n",
557 event__get_event_name(event->header.type)); 557 perf_event__name(event->header.type));
558 goto out_munmap; 558 goto out_munmap;
559 } 559 }
560 560
561 event__parse_sample(event, attr.sample_type, false, &sample); 561 perf_event__parse_sample(event, attr.sample_type, false, &sample);
562 evsel = perf_evlist__id2evsel(evlist, sample.id); 562 evsel = perf_evlist__id2evsel(evlist, sample.id);
563 if (evsel == NULL) { 563 if (evsel == NULL) {
564 pr_debug("event with id %" PRIu64 564 pr_debug("event with id %" PRIu64
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 01cf0c3771a6..0801275c500e 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -276,21 +276,24 @@ static int cpus_cstate_state[MAX_CPUS];
276static u64 cpus_pstate_start_times[MAX_CPUS]; 276static u64 cpus_pstate_start_times[MAX_CPUS];
277static u64 cpus_pstate_state[MAX_CPUS]; 277static u64 cpus_pstate_state[MAX_CPUS];
278 278
279static int process_comm_event(event_t *event, struct perf_sample *sample __used, 279static int process_comm_event(union perf_event *event,
280 struct perf_sample *sample __used,
280 struct perf_session *session __used) 281 struct perf_session *session __used)
281{ 282{
282 pid_set_comm(event->comm.tid, event->comm.comm); 283 pid_set_comm(event->comm.tid, event->comm.comm);
283 return 0; 284 return 0;
284} 285}
285 286
286static int process_fork_event(event_t *event, struct perf_sample *sample __used, 287static int process_fork_event(union perf_event *event,
288 struct perf_sample *sample __used,
287 struct perf_session *session __used) 289 struct perf_session *session __used)
288{ 290{
289 pid_fork(event->fork.pid, event->fork.ppid, event->fork.time); 291 pid_fork(event->fork.pid, event->fork.ppid, event->fork.time);
290 return 0; 292 return 0;
291} 293}
292 294
293static int process_exit_event(event_t *event, struct perf_sample *sample __used, 295static int process_exit_event(union perf_event *event,
296 struct perf_sample *sample __used,
294 struct perf_session *session __used) 297 struct perf_session *session __used)
295{ 298{
296 pid_exit(event->fork.pid, event->fork.time); 299 pid_exit(event->fork.pid, event->fork.time);
@@ -486,7 +489,7 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te)
486} 489}
487 490
488 491
489static int process_sample_event(event_t *event __used, 492static int process_sample_event(union perf_event *event __used,
490 struct perf_sample *sample, 493 struct perf_sample *sample,
491 struct perf_session *session) 494 struct perf_session *session)
492{ 495{
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index d923127b41b6..2f4d1f244be1 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -401,7 +401,7 @@ static void show_details(struct sym_entry *syme)
401} 401}
402 402
403/* 403/*
404 * Symbols will be added here in event__process_sample and will get out 404 * Symbols will be added here in perf_event__process_sample and will get out
405 * after decayed. 405 * after decayed.
406 */ 406 */
407static LIST_HEAD(active_symbols); 407static LIST_HEAD(active_symbols);
@@ -996,15 +996,15 @@ static int symbol_filter(struct map *map, struct symbol *sym)
996 return 0; 996 return 0;
997} 997}
998 998
999static void event__process_sample(const event_t *self, 999static void perf_event__process_sample(const union perf_event *event,
1000 struct perf_sample *sample, 1000 struct perf_sample *sample,
1001 struct perf_session *session) 1001 struct perf_session *session)
1002{ 1002{
1003 u64 ip = self->ip.ip; 1003 u64 ip = event->ip.ip;
1004 struct sym_entry *syme; 1004 struct sym_entry *syme;
1005 struct addr_location al; 1005 struct addr_location al;
1006 struct machine *machine; 1006 struct machine *machine;
1007 u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 1007 u8 origin = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
1008 1008
1009 ++samples; 1009 ++samples;
1010 1010
@@ -1023,7 +1023,7 @@ static void event__process_sample(const event_t *self,
1023 break; 1023 break;
1024 case PERF_RECORD_MISC_GUEST_KERNEL: 1024 case PERF_RECORD_MISC_GUEST_KERNEL:
1025 ++guest_kernel_samples; 1025 ++guest_kernel_samples;
1026 machine = perf_session__find_machine(session, self->ip.pid); 1026 machine = perf_session__find_machine(session, event->ip.pid);
1027 break; 1027 break;
1028 case PERF_RECORD_MISC_GUEST_USER: 1028 case PERF_RECORD_MISC_GUEST_USER:
1029 ++guest_us_samples; 1029 ++guest_us_samples;
@@ -1038,15 +1038,15 @@ static void event__process_sample(const event_t *self,
1038 1038
1039 if (!machine && perf_guest) { 1039 if (!machine && perf_guest) {
1040 pr_err("Can't find guest [%d]'s kernel information\n", 1040 pr_err("Can't find guest [%d]'s kernel information\n",
1041 self->ip.pid); 1041 event->ip.pid);
1042 return; 1042 return;
1043 } 1043 }
1044 1044
1045 if (self->header.misc & PERF_RECORD_MISC_EXACT_IP) 1045 if (event->header.misc & PERF_RECORD_MISC_EXACT_IP)
1046 exact_samples++; 1046 exact_samples++;
1047 1047
1048 if (event__preprocess_sample(self, session, &al, sample, 1048 if (perf_event__preprocess_sample(event, session, &al, sample,
1049 symbol_filter) < 0 || 1049 symbol_filter) < 0 ||
1050 al.filtered) 1050 al.filtered)
1051 return; 1051 return;
1052 1052
@@ -1108,15 +1108,15 @@ static void event__process_sample(const event_t *self,
1108static void perf_session__mmap_read_cpu(struct perf_session *self, int cpu) 1108static void perf_session__mmap_read_cpu(struct perf_session *self, int cpu)
1109{ 1109{
1110 struct perf_sample sample; 1110 struct perf_sample sample;
1111 event_t *event; 1111 union perf_event *event;
1112 1112
1113 while ((event = perf_evlist__read_on_cpu(evsel_list, cpu)) != NULL) { 1113 while ((event = perf_evlist__read_on_cpu(evsel_list, cpu)) != NULL) {
1114 perf_session__parse_sample(self, event, &sample); 1114 perf_session__parse_sample(self, event, &sample);
1115 1115
1116 if (event->header.type == PERF_RECORD_SAMPLE) 1116 if (event->header.type == PERF_RECORD_SAMPLE)
1117 event__process_sample(event, &sample, self); 1117 perf_event__process_sample(event, &sample, self);
1118 else 1118 else
1119 event__process(event, &sample, self); 1119 perf_event__process(event, &sample, self);
1120 } 1120 }
1121} 1121}
1122 1122
@@ -1199,9 +1199,10 @@ static int __cmd_top(void)
1199 return -ENOMEM; 1199 return -ENOMEM;
1200 1200
1201 if (target_tid != -1) 1201 if (target_tid != -1)
1202 event__synthesize_thread(target_tid, event__process, session); 1202 perf_event__synthesize_thread(target_tid, perf_event__process,
1203 session);
1203 else 1204 else
1204 event__synthesize_threads(event__process, session); 1205 perf_event__synthesize_threads(perf_event__process, session);
1205 1206
1206 start_counters(evsel_list); 1207 start_counters(evsel_list);
1207 first = list_entry(evsel_list->entries.next, struct perf_evsel, node); 1208 first = list_entry(evsel_list->entries.next, struct perf_evsel, node);
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index b184a7fa0843..31f934af9861 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -14,7 +14,7 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include "debug.h" 15#include "debug.h"
16 16
17static int build_id__mark_dso_hit(event_t *event, 17static int build_id__mark_dso_hit(union perf_event *event,
18 struct perf_sample *sample __used, 18 struct perf_sample *sample __used,
19 struct perf_session *session) 19 struct perf_session *session)
20{ 20{
@@ -37,13 +37,14 @@ static int build_id__mark_dso_hit(event_t *event,
37 return 0; 37 return 0;
38} 38}
39 39
40static int event__exit_del_thread(event_t *self, struct perf_sample *sample __used, 40static int perf_event__exit_del_thread(union perf_event *event,
41 struct perf_session *session) 41 struct perf_sample *sample __used,
42 struct perf_session *session)
42{ 43{
43 struct thread *thread = perf_session__findnew(session, self->fork.tid); 44 struct thread *thread = perf_session__findnew(session, event->fork.tid);
44 45
45 dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid, 46 dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
46 self->fork.ppid, self->fork.ptid); 47 event->fork.ppid, event->fork.ptid);
47 48
48 if (thread) { 49 if (thread) {
49 rb_erase(&thread->rb_node, &session->threads); 50 rb_erase(&thread->rb_node, &session->threads);
@@ -56,9 +57,9 @@ static int event__exit_del_thread(event_t *self, struct perf_sample *sample __us
56 57
57struct perf_event_ops build_id__mark_dso_hit_ops = { 58struct perf_event_ops build_id__mark_dso_hit_ops = {
58 .sample = build_id__mark_dso_hit, 59 .sample = build_id__mark_dso_hit,
59 .mmap = event__process_mmap, 60 .mmap = perf_event__process_mmap,
60 .fork = event__process_task, 61 .fork = perf_event__process_task,
61 .exit = event__exit_del_thread, 62 .exit = perf_event__exit_del_thread,
62}; 63};
63 64
64char *dso__build_id_filename(struct dso *self, char *bf, size_t size) 65char *dso__build_id_filename(struct dso *self, char *bf, size_t size)
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index f8c66d1435e0..9f7106a8d9a4 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -18,7 +18,8 @@
18#include "util.h" 18#include "util.h"
19#include "callchain.h" 19#include "callchain.h"
20 20
21bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event) 21bool ip_callchain__valid(struct ip_callchain *chain,
22 const union perf_event *event)
22{ 23{
23 unsigned int chain_size = event->header.size; 24 unsigned int chain_size = event->header.size;
24 chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event; 25 chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event;
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 67137256a1cd..1a79df9f739f 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -95,8 +95,8 @@ int callchain_append(struct callchain_root *root,
95int callchain_merge(struct callchain_cursor *cursor, 95int callchain_merge(struct callchain_cursor *cursor,
96 struct callchain_root *dst, struct callchain_root *src); 96 struct callchain_root *dst, struct callchain_root *src);
97 97
98bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event); 98bool ip_callchain__valid(struct ip_callchain *chain,
99 99 const union perf_event *event);
100/* 100/*
101 * Initialize a cursor before adding entries inside, but keep 101 * Initialize a cursor before adding entries inside, but keep
102 * the previously allocated entries as a cache. 102 * the previously allocated entries as a cache.
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 01bbe8ecec3f..d4536a9e0d8c 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -57,7 +57,7 @@ void ui__warning(const char *format, ...)
57} 57}
58#endif 58#endif
59 59
60void trace_event(event_t *event) 60void trace_event(union perf_event *event)
61{ 61{
62 unsigned char *raw_event = (void *)event; 62 unsigned char *raw_event = (void *)event;
63 const char *color = PERF_COLOR_BLUE; 63 const char *color = PERF_COLOR_BLUE;
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index ca35fd66b5df..93516cf4682c 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -9,7 +9,7 @@ extern int verbose;
9extern bool quiet, dump_trace; 9extern bool quiet, dump_trace;
10 10
11int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); 11int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
12void trace_event(event_t *event); 12void trace_event(union perf_event *event);
13 13
14struct ui_progress; 14struct ui_progress;
15 15
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 5c886fbd50ce..731265f4ad19 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -7,7 +7,7 @@
7#include "strlist.h" 7#include "strlist.h"
8#include "thread.h" 8#include "thread.h"
9 9
10static const char *event__name[] = { 10static const char *perf_event__names[] = {
11 [0] = "TOTAL", 11 [0] = "TOTAL",
12 [PERF_RECORD_MMAP] = "MMAP", 12 [PERF_RECORD_MMAP] = "MMAP",
13 [PERF_RECORD_LOST] = "LOST", 13 [PERF_RECORD_LOST] = "LOST",
@@ -25,13 +25,13 @@ static const char *event__name[] = {
25 [PERF_RECORD_FINISHED_ROUND] = "FINISHED_ROUND", 25 [PERF_RECORD_FINISHED_ROUND] = "FINISHED_ROUND",
26}; 26};
27 27
28const char *event__get_event_name(unsigned int id) 28const char *perf_event__name(unsigned int id)
29{ 29{
30 if (id >= ARRAY_SIZE(event__name)) 30 if (id >= ARRAY_SIZE(perf_event__names))
31 return "INVALID"; 31 return "INVALID";
32 if (!event__name[id]) 32 if (!perf_event__names[id])
33 return "UNKNOWN"; 33 return "UNKNOWN";
34 return event__name[id]; 34 return perf_event__names[id];
35} 35}
36 36
37static struct perf_sample synth_sample = { 37static struct perf_sample synth_sample = {
@@ -43,9 +43,9 @@ static struct perf_sample synth_sample = {
43 .period = 1, 43 .period = 1,
44}; 44};
45 45
46static pid_t event__synthesize_comm(event_t *event, pid_t pid, int full, 46static pid_t perf_event__synthesize_comm(union perf_event *event, pid_t pid,
47 event__handler_t process, 47 int full, perf_event__handler_t process,
48 struct perf_session *session) 48 struct perf_session *session)
49{ 49{
50 char filename[PATH_MAX]; 50 char filename[PATH_MAX];
51 char bf[BUFSIZ]; 51 char bf[BUFSIZ];
@@ -126,9 +126,10 @@ out:
126 return tgid; 126 return tgid;
127} 127}
128 128
129static int event__synthesize_mmap_events(event_t *event, pid_t pid, pid_t tgid, 129static int perf_event__synthesize_mmap_events(union perf_event *event,
130 event__handler_t process, 130 pid_t pid, pid_t tgid,
131 struct perf_session *session) 131 perf_event__handler_t process,
132 struct perf_session *session)
132{ 133{
133 char filename[PATH_MAX]; 134 char filename[PATH_MAX];
134 FILE *fp; 135 FILE *fp;
@@ -199,14 +200,14 @@ static int event__synthesize_mmap_events(event_t *event, pid_t pid, pid_t tgid,
199 return 0; 200 return 0;
200} 201}
201 202
202int event__synthesize_modules(event__handler_t process, 203int perf_event__synthesize_modules(perf_event__handler_t process,
203 struct perf_session *session, 204 struct perf_session *session,
204 struct machine *machine) 205 struct machine *machine)
205{ 206{
206 struct rb_node *nd; 207 struct rb_node *nd;
207 struct map_groups *kmaps = &machine->kmaps; 208 struct map_groups *kmaps = &machine->kmaps;
208 event_t *event = zalloc(sizeof(event->mmap) + session->id_hdr_size); 209 union perf_event *event = zalloc((sizeof(event->mmap) +
209 210 session->id_hdr_size));
210 if (event == NULL) { 211 if (event == NULL) {
211 pr_debug("Not enough memory synthesizing mmap event " 212 pr_debug("Not enough memory synthesizing mmap event "
212 "for kernel modules\n"); 213 "for kernel modules\n");
@@ -251,22 +252,23 @@ int event__synthesize_modules(event__handler_t process,
251 return 0; 252 return 0;
252} 253}
253 254
254static int __event__synthesize_thread(event_t *comm_event, event_t *mmap_event, 255static int __event__synthesize_thread(union perf_event *comm_event,
255 pid_t pid, event__handler_t process, 256 union perf_event *mmap_event,
257 pid_t pid, perf_event__handler_t process,
256 struct perf_session *session) 258 struct perf_session *session)
257{ 259{
258 pid_t tgid = event__synthesize_comm(comm_event, pid, 1, process, 260 pid_t tgid = perf_event__synthesize_comm(comm_event, pid, 1, process,
259 session); 261 session);
260 if (tgid == -1) 262 if (tgid == -1)
261 return -1; 263 return -1;
262 return event__synthesize_mmap_events(mmap_event, pid, tgid, 264 return perf_event__synthesize_mmap_events(mmap_event, pid, tgid,
263 process, session); 265 process, session);
264} 266}
265 267
266int event__synthesize_thread(pid_t pid, event__handler_t process, 268int perf_event__synthesize_thread(pid_t pid, perf_event__handler_t process,
267 struct perf_session *session) 269 struct perf_session *session)
268{ 270{
269 event_t *comm_event, *mmap_event; 271 union perf_event *comm_event, *mmap_event;
270 int err = -1; 272 int err = -1;
271 273
272 comm_event = malloc(sizeof(comm_event->comm) + session->id_hdr_size); 274 comm_event = malloc(sizeof(comm_event->comm) + session->id_hdr_size);
@@ -286,12 +288,12 @@ out:
286 return err; 288 return err;
287} 289}
288 290
289int event__synthesize_threads(event__handler_t process, 291int perf_event__synthesize_threads(perf_event__handler_t process,
290 struct perf_session *session) 292 struct perf_session *session)
291{ 293{
292 DIR *proc; 294 DIR *proc;
293 struct dirent dirent, *next; 295 struct dirent dirent, *next;
294 event_t *comm_event, *mmap_event; 296 union perf_event *comm_event, *mmap_event;
295 int err = -1; 297 int err = -1;
296 298
297 comm_event = malloc(sizeof(comm_event->comm) + session->id_hdr_size); 299 comm_event = malloc(sizeof(comm_event->comm) + session->id_hdr_size);
@@ -349,10 +351,10 @@ static int find_symbol_cb(void *arg, const char *name, char type,
349 return 1; 351 return 1;
350} 352}
351 353
352int event__synthesize_kernel_mmap(event__handler_t process, 354int perf_event__synthesize_kernel_mmap(perf_event__handler_t process,
353 struct perf_session *session, 355 struct perf_session *session,
354 struct machine *machine, 356 struct machine *machine,
355 const char *symbol_name) 357 const char *symbol_name)
356{ 358{
357 size_t size; 359 size_t size;
358 const char *filename, *mmap_name; 360 const char *filename, *mmap_name;
@@ -366,8 +368,8 @@ int event__synthesize_kernel_mmap(event__handler_t process,
366 * kernels. 368 * kernels.
367 */ 369 */
368 struct process_symbol_args args = { .name = symbol_name, }; 370 struct process_symbol_args args = { .name = symbol_name, };
369 event_t *event = zalloc(sizeof(event->mmap) + session->id_hdr_size); 371 union perf_event *event = zalloc((sizeof(event->mmap) +
370 372 session->id_hdr_size));
371 if (event == NULL) { 373 if (event == NULL) {
372 pr_debug("Not enough memory synthesizing mmap event " 374 pr_debug("Not enough memory synthesizing mmap event "
373 "for kernel modules\n"); 375 "for kernel modules\n");
@@ -440,14 +442,15 @@ static int thread__set_comm_adjust(struct thread *self, const char *comm,
440 return 0; 442 return 0;
441} 443}
442 444
443int event__process_comm(event_t *self, struct perf_sample *sample __used, 445int perf_event__process_comm(union perf_event *event,
444 struct perf_session *session) 446 struct perf_sample *sample __used,
447 struct perf_session *session)
445{ 448{
446 struct thread *thread = perf_session__findnew(session, self->comm.tid); 449 struct thread *thread = perf_session__findnew(session, event->comm.tid);
447 450
448 dump_printf(": %s:%d\n", self->comm.comm, self->comm.tid); 451 dump_printf(": %s:%d\n", event->comm.comm, event->comm.tid);
449 452
450 if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm, 453 if (thread == NULL || thread__set_comm_adjust(thread, event->comm.comm,
451 &session->hists)) { 454 &session->hists)) {
452 dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); 455 dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
453 return -1; 456 return -1;
@@ -456,19 +459,21 @@ int event__process_comm(event_t *self, struct perf_sample *sample __used,
456 return 0; 459 return 0;
457} 460}
458 461
459int event__process_lost(event_t *self, struct perf_sample *sample __used, 462int perf_event__process_lost(union perf_event *event,
460 struct perf_session *session) 463 struct perf_sample *sample __used,
464 struct perf_session *session)
461{ 465{
462 dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n", 466 dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n",
463 self->lost.id, self->lost.lost); 467 event->lost.id, event->lost.lost);
464 session->hists.stats.total_lost += self->lost.lost; 468 session->hists.stats.total_lost += event->lost.lost;
465 return 0; 469 return 0;
466} 470}
467 471
468static void event_set_kernel_mmap_len(struct map **maps, event_t *self) 472static void perf_event__set_kernel_mmap_len(union perf_event *event,
473 struct map **maps)
469{ 474{
470 maps[MAP__FUNCTION]->start = self->mmap.start; 475 maps[MAP__FUNCTION]->start = event->mmap.start;
471 maps[MAP__FUNCTION]->end = self->mmap.start + self->mmap.len; 476 maps[MAP__FUNCTION]->end = event->mmap.start + event->mmap.len;
472 /* 477 /*
473 * Be a bit paranoid here, some perf.data file came with 478 * Be a bit paranoid here, some perf.data file came with
474 * a zero sized synthesized MMAP event for the kernel. 479 * a zero sized synthesized MMAP event for the kernel.
@@ -477,8 +482,8 @@ static void event_set_kernel_mmap_len(struct map **maps, event_t *self)
477 maps[MAP__FUNCTION]->end = ~0ULL; 482 maps[MAP__FUNCTION]->end = ~0ULL;
478} 483}
479 484
480static int event__process_kernel_mmap(event_t *self, 485static int perf_event__process_kernel_mmap(union perf_event *event,
481 struct perf_session *session) 486 struct perf_session *session)
482{ 487{
483 struct map *map; 488 struct map *map;
484 char kmmap_prefix[PATH_MAX]; 489 char kmmap_prefix[PATH_MAX];
@@ -486,9 +491,9 @@ static int event__process_kernel_mmap(event_t *self,
486 enum dso_kernel_type kernel_type; 491 enum dso_kernel_type kernel_type;
487 bool is_kernel_mmap; 492 bool is_kernel_mmap;
488 493
489 machine = perf_session__findnew_machine(session, self->mmap.pid); 494 machine = perf_session__findnew_machine(session, event->mmap.pid);
490 if (!machine) { 495 if (!machine) {
491 pr_err("Can't find id %d's machine\n", self->mmap.pid); 496 pr_err("Can't find id %d's machine\n", event->mmap.pid);
492 goto out_problem; 497 goto out_problem;
493 } 498 }
494 499
@@ -498,17 +503,17 @@ static int event__process_kernel_mmap(event_t *self,
498 else 503 else
499 kernel_type = DSO_TYPE_GUEST_KERNEL; 504 kernel_type = DSO_TYPE_GUEST_KERNEL;
500 505
501 is_kernel_mmap = memcmp(self->mmap.filename, 506 is_kernel_mmap = memcmp(event->mmap.filename,
502 kmmap_prefix, 507 kmmap_prefix,
503 strlen(kmmap_prefix)) == 0; 508 strlen(kmmap_prefix)) == 0;
504 if (self->mmap.filename[0] == '/' || 509 if (event->mmap.filename[0] == '/' ||
505 (!is_kernel_mmap && self->mmap.filename[0] == '[')) { 510 (!is_kernel_mmap && event->mmap.filename[0] == '[')) {
506 511
507 char short_module_name[1024]; 512 char short_module_name[1024];
508 char *name, *dot; 513 char *name, *dot;
509 514
510 if (self->mmap.filename[0] == '/') { 515 if (event->mmap.filename[0] == '/') {
511 name = strrchr(self->mmap.filename, '/'); 516 name = strrchr(event->mmap.filename, '/');
512 if (name == NULL) 517 if (name == NULL)
513 goto out_problem; 518 goto out_problem;
514 519
@@ -520,10 +525,10 @@ static int event__process_kernel_mmap(event_t *self,
520 "[%.*s]", (int)(dot - name), name); 525 "[%.*s]", (int)(dot - name), name);
521 strxfrchar(short_module_name, '-', '_'); 526 strxfrchar(short_module_name, '-', '_');
522 } else 527 } else
523 strcpy(short_module_name, self->mmap.filename); 528 strcpy(short_module_name, event->mmap.filename);
524 529
525 map = machine__new_module(machine, self->mmap.start, 530 map = machine__new_module(machine, event->mmap.start,
526 self->mmap.filename); 531 event->mmap.filename);
527 if (map == NULL) 532 if (map == NULL)
528 goto out_problem; 533 goto out_problem;
529 534
@@ -533,9 +538,9 @@ static int event__process_kernel_mmap(event_t *self,
533 538
534 map->dso->short_name = name; 539 map->dso->short_name = name;
535 map->dso->sname_alloc = 1; 540 map->dso->sname_alloc = 1;
536 map->end = map->start + self->mmap.len; 541 map->end = map->start + event->mmap.len;
537 } else if (is_kernel_mmap) { 542 } else if (is_kernel_mmap) {
538 const char *symbol_name = (self->mmap.filename + 543 const char *symbol_name = (event->mmap.filename +
539 strlen(kmmap_prefix)); 544 strlen(kmmap_prefix));
540 /* 545 /*
541 * Should be there already, from the build-id table in 546 * Should be there already, from the build-id table in
@@ -550,10 +555,10 @@ static int event__process_kernel_mmap(event_t *self,
550 if (__machine__create_kernel_maps(machine, kernel) < 0) 555 if (__machine__create_kernel_maps(machine, kernel) < 0)
551 goto out_problem; 556 goto out_problem;
552 557
553 event_set_kernel_mmap_len(machine->vmlinux_maps, self); 558 perf_event__set_kernel_mmap_len(event, machine->vmlinux_maps);
554 perf_session__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, 559 perf_session__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps,
555 symbol_name, 560 symbol_name,
556 self->mmap.pgoff); 561 event->mmap.pgoff);
557 if (machine__is_default_guest(machine)) { 562 if (machine__is_default_guest(machine)) {
558 /* 563 /*
559 * preload dso of guest kernel and modules 564 * preload dso of guest kernel and modules
@@ -567,22 +572,23 @@ out_problem:
567 return -1; 572 return -1;
568} 573}
569 574
570int event__process_mmap(event_t *self, struct perf_sample *sample __used, 575int perf_event__process_mmap(union perf_event *event,
571 struct perf_session *session) 576 struct perf_sample *sample __used,
577 struct perf_session *session)
572{ 578{
573 struct machine *machine; 579 struct machine *machine;
574 struct thread *thread; 580 struct thread *thread;
575 struct map *map; 581 struct map *map;
576 u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 582 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
577 int ret = 0; 583 int ret = 0;
578 584
579 dump_printf(" %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %s\n", 585 dump_printf(" %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %s\n",
580 self->mmap.pid, self->mmap.tid, self->mmap.start, 586 event->mmap.pid, event->mmap.tid, event->mmap.start,
581 self->mmap.len, self->mmap.pgoff, self->mmap.filename); 587 event->mmap.len, event->mmap.pgoff, event->mmap.filename);
582 588
583 if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL || 589 if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
584 cpumode == PERF_RECORD_MISC_KERNEL) { 590 cpumode == PERF_RECORD_MISC_KERNEL) {
585 ret = event__process_kernel_mmap(self, session); 591 ret = perf_event__process_kernel_mmap(event, session);
586 if (ret < 0) 592 if (ret < 0)
587 goto out_problem; 593 goto out_problem;
588 return 0; 594 return 0;
@@ -591,12 +597,12 @@ int event__process_mmap(event_t *self, struct perf_sample *sample __used,
591 machine = perf_session__find_host_machine(session); 597 machine = perf_session__find_host_machine(session);
592 if (machine == NULL) 598 if (machine == NULL)
593 goto out_problem; 599 goto out_problem;
594 thread = perf_session__findnew(session, self->mmap.pid); 600 thread = perf_session__findnew(session, event->mmap.pid);
595 if (thread == NULL) 601 if (thread == NULL)
596 goto out_problem; 602 goto out_problem;
597 map = map__new(&machine->user_dsos, self->mmap.start, 603 map = map__new(&machine->user_dsos, event->mmap.start,
598 self->mmap.len, self->mmap.pgoff, 604 event->mmap.len, event->mmap.pgoff,
599 self->mmap.pid, self->mmap.filename, 605 event->mmap.pid, event->mmap.filename,
600 MAP__FUNCTION); 606 MAP__FUNCTION);
601 if (map == NULL) 607 if (map == NULL)
602 goto out_problem; 608 goto out_problem;
@@ -609,16 +615,17 @@ out_problem:
609 return 0; 615 return 0;
610} 616}
611 617
612int event__process_task(event_t *self, struct perf_sample *sample __used, 618int perf_event__process_task(union perf_event *event,
613 struct perf_session *session) 619 struct perf_sample *sample __used,
620 struct perf_session *session)
614{ 621{
615 struct thread *thread = perf_session__findnew(session, self->fork.tid); 622 struct thread *thread = perf_session__findnew(session, event->fork.tid);
616 struct thread *parent = perf_session__findnew(session, self->fork.ptid); 623 struct thread *parent = perf_session__findnew(session, event->fork.ptid);
617 624
618 dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid, 625 dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
619 self->fork.ppid, self->fork.ptid); 626 event->fork.ppid, event->fork.ptid);
620 627
621 if (self->header.type == PERF_RECORD_EXIT) { 628 if (event->header.type == PERF_RECORD_EXIT) {
622 perf_session__remove_thread(session, thread); 629 perf_session__remove_thread(session, thread);
623 return 0; 630 return 0;
624 } 631 }
@@ -632,22 +639,22 @@ int event__process_task(event_t *self, struct perf_sample *sample __used,
632 return 0; 639 return 0;
633} 640}
634 641
635int event__process(event_t *event, struct perf_sample *sample, 642int perf_event__process(union perf_event *event, struct perf_sample *sample,
636 struct perf_session *session) 643 struct perf_session *session)
637{ 644{
638 switch (event->header.type) { 645 switch (event->header.type) {
639 case PERF_RECORD_COMM: 646 case PERF_RECORD_COMM:
640 event__process_comm(event, sample, session); 647 perf_event__process_comm(event, sample, session);
641 break; 648 break;
642 case PERF_RECORD_MMAP: 649 case PERF_RECORD_MMAP:
643 event__process_mmap(event, sample, session); 650 perf_event__process_mmap(event, sample, session);
644 break; 651 break;
645 case PERF_RECORD_FORK: 652 case PERF_RECORD_FORK:
646 case PERF_RECORD_EXIT: 653 case PERF_RECORD_EXIT:
647 event__process_task(event, sample, session); 654 perf_event__process_task(event, sample, session);
648 break; 655 break;
649 case PERF_RECORD_LOST: 656 case PERF_RECORD_LOST:
650 event__process_lost(event, sample, session); 657 perf_event__process_lost(event, sample, session);
651 default: 658 default:
652 break; 659 break;
653 } 660 }
@@ -756,12 +763,14 @@ static void dso__calc_col_width(struct dso *self, struct hists *hists)
756 self->slen_calculated = 1; 763 self->slen_calculated = 1;
757} 764}
758 765
759int event__preprocess_sample(const event_t *self, struct perf_session *session, 766int perf_event__preprocess_sample(const union perf_event *event,
760 struct addr_location *al, struct perf_sample *sample, 767 struct perf_session *session,
761 symbol_filter_t filter) 768 struct addr_location *al,
769 struct perf_sample *sample,
770 symbol_filter_t filter)
762{ 771{
763 u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 772 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
764 struct thread *thread = perf_session__findnew(session, self->ip.pid); 773 struct thread *thread = perf_session__findnew(session, event->ip.pid);
765 774
766 if (thread == NULL) 775 if (thread == NULL)
767 return -1; 776 return -1;
@@ -783,7 +792,7 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session,
783 machine__create_kernel_maps(&session->host_machine); 792 machine__create_kernel_maps(&session->host_machine);
784 793
785 thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, 794 thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION,
786 self->ip.pid, self->ip.ip, al); 795 event->ip.pid, event->ip.ip, al);
787 dump_printf(" ...... dso: %s\n", 796 dump_printf(" ...... dso: %s\n",
788 al->map ? al->map->dso->long_name : 797 al->map ? al->map->dso->long_name :
789 al->level == 'H' ? "[hypervisor]" : "<not found>"); 798 al->level == 'H' ? "[hypervisor]" : "<not found>");
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 84fd71ffd619..eecb42273d59 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -117,7 +117,7 @@ struct tracing_data_event {
117 u32 size; 117 u32 size;
118}; 118};
119 119
120typedef union event_union { 120union perf_event {
121 struct perf_event_header header; 121 struct perf_event_header header;
122 struct ip_event ip; 122 struct ip_event ip;
123 struct mmap_event mmap; 123 struct mmap_event mmap;
@@ -130,49 +130,52 @@ typedef union event_union {
130 struct event_type_event event_type; 130 struct event_type_event event_type;
131 struct tracing_data_event tracing_data; 131 struct tracing_data_event tracing_data;
132 struct build_id_event build_id; 132 struct build_id_event build_id;
133} event_t; 133};
134 134
135void event__print_totals(void); 135void perf_event__print_totals(void);
136 136
137struct perf_session; 137struct perf_session;
138 138
139typedef int (*event__handler_synth_t)(event_t *event, 139typedef int (*perf_event__handler_synth_t)(union perf_event *event,
140 struct perf_session *session);
141typedef int (*perf_event__handler_t)(union perf_event *event,
142 struct perf_sample *sample,
140 struct perf_session *session); 143 struct perf_session *session);
141typedef int (*event__handler_t)(event_t *event, struct perf_sample *sample,
142 struct perf_session *session);
143 144
144int event__synthesize_thread(pid_t pid, event__handler_t process, 145int perf_event__synthesize_thread(pid_t pid, perf_event__handler_t process,
146 struct perf_session *session);
147int perf_event__synthesize_threads(perf_event__handler_t process,
148 struct perf_session *session);
149int perf_event__synthesize_kernel_mmap(perf_event__handler_t process,
150 struct perf_session *session,
151 struct machine *machine,
152 const char *symbol_name);
153
154int perf_event__synthesize_modules(perf_event__handler_t process,
155 struct perf_session *session,
156 struct machine *machine);
157
158int perf_event__process_comm(union perf_event *event, struct perf_sample *sample,
145 struct perf_session *session); 159 struct perf_session *session);
146int event__synthesize_threads(event__handler_t process, 160int perf_event__process_lost(union perf_event *event, struct perf_sample *sample,
147 struct perf_session *session); 161 struct perf_session *session);
148int event__synthesize_kernel_mmap(event__handler_t process, 162int perf_event__process_mmap(union perf_event *event, struct perf_sample *sample,
149 struct perf_session *session, 163 struct perf_session *session);
150 struct machine *machine, 164int perf_event__process_task(union perf_event *event, struct perf_sample *sample,
151 const char *symbol_name); 165 struct perf_session *session);
152 166int perf_event__process(union perf_event *event, struct perf_sample *sample,
153int event__synthesize_modules(event__handler_t process,
154 struct perf_session *session,
155 struct machine *machine);
156
157int event__process_comm(event_t *event, struct perf_sample *sample,
158 struct perf_session *session);
159int event__process_lost(event_t *event, struct perf_sample *sample,
160 struct perf_session *session);
161int event__process_mmap(event_t *event, struct perf_sample *sample,
162 struct perf_session *session);
163int event__process_task(event_t *event, struct perf_sample *sample,
164 struct perf_session *session); 167 struct perf_session *session);
165int event__process(event_t *event, struct perf_sample *sample,
166 struct perf_session *session);
167 168
168struct addr_location; 169struct addr_location;
169int event__preprocess_sample(const event_t *self, struct perf_session *session, 170int perf_event__preprocess_sample(const union perf_event *self,
170 struct addr_location *al, struct perf_sample *sample, 171 struct perf_session *session,
171 symbol_filter_t filter); 172 struct addr_location *al,
173 struct perf_sample *sample,
174 symbol_filter_t filter);
172 175
173const char *event__get_event_name(unsigned int id); 176const char *perf_event__name(unsigned int id);
174 177
175int event__parse_sample(const event_t *event, u64 type, bool sample_id_all, 178int perf_event__parse_sample(const union perf_event *event, u64 type,
176 struct perf_sample *sample); 179 bool sample_id_all, struct perf_sample *sample);
177 180
178#endif /* __PERF_RECORD_H */ 181#endif /* __PERF_RECORD_H */
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index b498eecbe850..917fc18d0bed 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -107,7 +107,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
107 return NULL; 107 return NULL;
108} 108}
109 109
110event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) 110union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
111{ 111{
112 /* XXX Move this to perf.c, making it generally available */ 112 /* XXX Move this to perf.c, making it generally available */
113 unsigned int page_size = sysconf(_SC_PAGE_SIZE); 113 unsigned int page_size = sysconf(_SC_PAGE_SIZE);
@@ -115,7 +115,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
115 unsigned int head = perf_mmap__read_head(md); 115 unsigned int head = perf_mmap__read_head(md);
116 unsigned int old = md->prev; 116 unsigned int old = md->prev;
117 unsigned char *data = md->base + page_size; 117 unsigned char *data = md->base + page_size;
118 event_t *event = NULL; 118 union perf_event *event = NULL;
119 119
120 if (evlist->overwrite) { 120 if (evlist->overwrite) {
121 /* 121 /*
@@ -140,7 +140,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
140 if (old != head) { 140 if (old != head) {
141 size_t size; 141 size_t size;
142 142
143 event = (event_t *)&data[old & md->mask]; 143 event = (union perf_event *)&data[old & md->mask];
144 size = event->header.size; 144 size = event->header.size;
145 145
146 /* 146 /*
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 2706ae40c8b3..022ae404b908 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -17,7 +17,7 @@ struct perf_evlist {
17 int nr_fds; 17 int nr_fds;
18 int mmap_len; 18 int mmap_len;
19 bool overwrite; 19 bool overwrite;
20 event_t event_copy; 20 union perf_event event_copy;
21 struct perf_mmap *mmap; 21 struct perf_mmap *mmap;
22 struct pollfd *pollfd; 22 struct pollfd *pollfd;
23}; 23};
@@ -37,6 +37,6 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
37 37
38struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); 38struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
39 39
40event_t *perf_evlist__read_on_cpu(struct perf_evlist *self, int cpu); 40union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *self, int cpu);
41 41
42#endif /* __PERF_EVLIST_H */ 42#endif /* __PERF_EVLIST_H */
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index a13488511880..fddeb08f48a7 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -367,8 +367,8 @@ out_unmap:
367 return -1; 367 return -1;
368} 368}
369 369
370static int event__parse_id_sample(const event_t *event, u64 type, 370static int perf_event__parse_id_sample(const union perf_event *event, u64 type,
371 struct perf_sample *sample) 371 struct perf_sample *sample)
372{ 372{
373 const u64 *array = event->sample.array; 373 const u64 *array = event->sample.array;
374 374
@@ -405,8 +405,8 @@ static int event__parse_id_sample(const event_t *event, u64 type,
405 return 0; 405 return 0;
406} 406}
407 407
408int event__parse_sample(const event_t *event, u64 type, bool sample_id_all, 408int perf_event__parse_sample(const union perf_event *event, u64 type,
409 struct perf_sample *data) 409 bool sample_id_all, struct perf_sample *data)
410{ 410{
411 const u64 *array; 411 const u64 *array;
412 412
@@ -416,7 +416,7 @@ int event__parse_sample(const event_t *event, u64 type, bool sample_id_all,
416 if (event->header.type != PERF_RECORD_SAMPLE) { 416 if (event->header.type != PERF_RECORD_SAMPLE) {
417 if (!sample_id_all) 417 if (!sample_id_all)
418 return 0; 418 return 0;
419 return event__parse_id_sample(event, type, data); 419 return perf_event__parse_id_sample(event, type, data);
420 } 420 }
421 421
422 array = event->sample.array; 422 array = event->sample.array;
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index f0138d472339..c0de5ec44145 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1000,11 +1000,11 @@ perf_header__find_attr(u64 id, struct perf_header *header)
1000 return NULL; 1000 return NULL;
1001} 1001}
1002 1002
1003int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, 1003int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
1004 event__handler_t process, 1004 perf_event__handler_t process,
1005 struct perf_session *session) 1005 struct perf_session *session)
1006{ 1006{
1007 event_t *ev; 1007 union perf_event *ev;
1008 size_t size; 1008 size_t size;
1009 int err; 1009 int err;
1010 1010
@@ -1031,8 +1031,9 @@ int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
1031 return err; 1031 return err;
1032} 1032}
1033 1033
1034int event__synthesize_attrs(struct perf_header *self, event__handler_t process, 1034int perf_event__synthesize_attrs(struct perf_header *self,
1035 struct perf_session *session) 1035 perf_event__handler_t process,
1036 struct perf_session *session)
1036{ 1037{
1037 struct perf_header_attr *attr; 1038 struct perf_header_attr *attr;
1038 int i, err = 0; 1039 int i, err = 0;
@@ -1040,8 +1041,8 @@ int event__synthesize_attrs(struct perf_header *self, event__handler_t process,
1040 for (i = 0; i < self->attrs; i++) { 1041 for (i = 0; i < self->attrs; i++) {
1041 attr = self->attr[i]; 1042 attr = self->attr[i];
1042 1043
1043 err = event__synthesize_attr(&attr->attr, attr->ids, attr->id, 1044 err = perf_event__synthesize_attr(&attr->attr, attr->ids,
1044 process, session); 1045 attr->id, process, session);
1045 if (err) { 1046 if (err) {
1046 pr_debug("failed to create perf header attribute\n"); 1047 pr_debug("failed to create perf header attribute\n");
1047 return err; 1048 return err;
@@ -1051,21 +1052,22 @@ int event__synthesize_attrs(struct perf_header *self, event__handler_t process,
1051 return err; 1052 return err;
1052} 1053}
1053 1054
1054int event__process_attr(event_t *self, struct perf_session *session) 1055int perf_event__process_attr(union perf_event *event,
1056 struct perf_session *session)
1055{ 1057{
1056 struct perf_header_attr *attr; 1058 struct perf_header_attr *attr;
1057 unsigned int i, ids, n_ids; 1059 unsigned int i, ids, n_ids;
1058 1060
1059 attr = perf_header_attr__new(&self->attr.attr); 1061 attr = perf_header_attr__new(&event->attr.attr);
1060 if (attr == NULL) 1062 if (attr == NULL)
1061 return -ENOMEM; 1063 return -ENOMEM;
1062 1064
1063 ids = self->header.size; 1065 ids = event->header.size;
1064 ids -= (void *)&self->attr.id - (void *)self; 1066 ids -= (void *)&event->attr.id - (void *)event;
1065 n_ids = ids / sizeof(u64); 1067 n_ids = ids / sizeof(u64);
1066 1068
1067 for (i = 0; i < n_ids; i++) { 1069 for (i = 0; i < n_ids; i++) {
1068 if (perf_header_attr__add_id(attr, self->attr.id[i]) < 0) { 1070 if (perf_header_attr__add_id(attr, event->attr.id[i]) < 0) {
1069 perf_header_attr__delete(attr); 1071 perf_header_attr__delete(attr);
1070 return -ENOMEM; 1072 return -ENOMEM;
1071 } 1073 }
@@ -1081,11 +1083,11 @@ int event__process_attr(event_t *self, struct perf_session *session)
1081 return 0; 1083 return 0;
1082} 1084}
1083 1085
1084int event__synthesize_event_type(u64 event_id, char *name, 1086int perf_event__synthesize_event_type(u64 event_id, char *name,
1085 event__handler_t process, 1087 perf_event__handler_t process,
1086 struct perf_session *session) 1088 struct perf_session *session)
1087{ 1089{
1088 event_t ev; 1090 union perf_event ev;
1089 size_t size = 0; 1091 size_t size = 0;
1090 int err = 0; 1092 int err = 0;
1091 1093
@@ -1106,8 +1108,8 @@ int event__synthesize_event_type(u64 event_id, char *name,
1106 return err; 1108 return err;
1107} 1109}
1108 1110
1109int event__synthesize_event_types(event__handler_t process, 1111int perf_event__synthesize_event_types(perf_event__handler_t process,
1110 struct perf_session *session) 1112 struct perf_session *session)
1111{ 1113{
1112 struct perf_trace_event_type *type; 1114 struct perf_trace_event_type *type;
1113 int i, err = 0; 1115 int i, err = 0;
@@ -1115,8 +1117,9 @@ int event__synthesize_event_types(event__handler_t process,
1115 for (i = 0; i < event_count; i++) { 1117 for (i = 0; i < event_count; i++) {
1116 type = &events[i]; 1118 type = &events[i];
1117 1119
1118 err = event__synthesize_event_type(type->event_id, type->name, 1120 err = perf_event__synthesize_event_type(type->event_id,
1119 process, session); 1121 type->name, process,
1122 session);
1120 if (err) { 1123 if (err) {
1121 pr_debug("failed to create perf header event type\n"); 1124 pr_debug("failed to create perf header event type\n");
1122 return err; 1125 return err;
@@ -1126,21 +1129,21 @@ int event__synthesize_event_types(event__handler_t process,
1126 return err; 1129 return err;
1127} 1130}
1128 1131
1129int event__process_event_type(event_t *self, 1132int perf_event__process_event_type(union perf_event *event,
1130 struct perf_session *session __unused) 1133 struct perf_session *session __unused)
1131{ 1134{
1132 if (perf_header__push_event(self->event_type.event_type.event_id, 1135 if (perf_header__push_event(event->event_type.event_type.event_id,
1133 self->event_type.event_type.name) < 0) 1136 event->event_type.event_type.name) < 0)
1134 return -ENOMEM; 1137 return -ENOMEM;
1135 1138
1136 return 0; 1139 return 0;
1137} 1140}
1138 1141
1139int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, 1142int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
1140 event__handler_t process, 1143 perf_event__handler_t process,
1141 struct perf_session *session __unused) 1144 struct perf_session *session __unused)
1142{ 1145{
1143 event_t ev; 1146 union perf_event ev;
1144 ssize_t size = 0, aligned_size = 0, padding; 1147 ssize_t size = 0, aligned_size = 0, padding;
1145 int err = 0; 1148 int err = 0;
1146 1149
@@ -1163,10 +1166,10 @@ int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
1163 return aligned_size; 1166 return aligned_size;
1164} 1167}
1165 1168
1166int event__process_tracing_data(event_t *self, 1169int perf_event__process_tracing_data(union perf_event *event,
1167 struct perf_session *session) 1170 struct perf_session *session)
1168{ 1171{
1169 ssize_t size_read, padding, size = self->tracing_data.size; 1172 ssize_t size_read, padding, size = event->tracing_data.size;
1170 off_t offset = lseek(session->fd, 0, SEEK_CUR); 1173 off_t offset = lseek(session->fd, 0, SEEK_CUR);
1171 char buf[BUFSIZ]; 1174 char buf[BUFSIZ];
1172 1175
@@ -1192,12 +1195,12 @@ int event__process_tracing_data(event_t *self,
1192 return size_read + padding; 1195 return size_read + padding;
1193} 1196}
1194 1197
1195int event__synthesize_build_id(struct dso *pos, u16 misc, 1198int perf_event__synthesize_build_id(struct dso *pos, u16 misc,
1196 event__handler_t process, 1199 perf_event__handler_t process,
1197 struct machine *machine, 1200 struct machine *machine,
1198 struct perf_session *session) 1201 struct perf_session *session)
1199{ 1202{
1200 event_t ev; 1203 union perf_event ev;
1201 size_t len; 1204 size_t len;
1202 int err = 0; 1205 int err = 0;
1203 1206
@@ -1220,11 +1223,11 @@ int event__synthesize_build_id(struct dso *pos, u16 misc,
1220 return err; 1223 return err;
1221} 1224}
1222 1225
1223int event__process_build_id(event_t *self, 1226int perf_event__process_build_id(union perf_event *event,
1224 struct perf_session *session) 1227 struct perf_session *session)
1225{ 1228{
1226 __event_process_build_id(&self->build_id, 1229 __event_process_build_id(&event->build_id,
1227 self->build_id.filename, 1230 event->build_id.filename,
1228 session); 1231 session);
1229 return 0; 1232 return 0;
1230} 1233}
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 65afd7f74e0d..f042cebcec1e 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -100,32 +100,32 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
100 const char *name, bool is_kallsyms); 100 const char *name, bool is_kallsyms);
101int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir); 101int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
102 102
103int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, 103int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
104 event__handler_t process, 104 perf_event__handler_t process,
105 struct perf_session *session); 105 struct perf_session *session);
106int event__synthesize_attrs(struct perf_header *self, 106int perf_event__synthesize_attrs(struct perf_header *self,
107 event__handler_t process, 107 perf_event__handler_t process,
108 struct perf_session *session);
109int event__process_attr(event_t *self, struct perf_session *session);
110
111int event__synthesize_event_type(u64 event_id, char *name,
112 event__handler_t process,
113 struct perf_session *session); 108 struct perf_session *session);
114int event__synthesize_event_types(event__handler_t process, 109int perf_event__process_attr(union perf_event *event, struct perf_session *session);
115 struct perf_session *session); 110
116int event__process_event_type(event_t *self, 111int perf_event__synthesize_event_type(u64 event_id, char *name,
117 struct perf_session *session); 112 perf_event__handler_t process,
118 113 struct perf_session *session);
119int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, 114int perf_event__synthesize_event_types(perf_event__handler_t process,
120 event__handler_t process, 115 struct perf_session *session);
116int perf_event__process_event_type(union perf_event *event,
121 struct perf_session *session); 117 struct perf_session *session);
122int event__process_tracing_data(event_t *self,
123 struct perf_session *session);
124
125int event__synthesize_build_id(struct dso *pos, u16 misc,
126 event__handler_t process,
127 struct machine *machine,
128 struct perf_session *session);
129int event__process_build_id(event_t *self, struct perf_session *session);
130 118
119int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
120 perf_event__handler_t process,
121 struct perf_session *session);
122int perf_event__process_tracing_data(union perf_event *event,
123 struct perf_session *session);
124
125int perf_event__synthesize_build_id(struct dso *pos, u16 misc,
126 perf_event__handler_t process,
127 struct machine *machine,
128 struct perf_session *session);
129int perf_event__process_build_id(union perf_event *event,
130 struct perf_session *session);
131#endif /* __PERF_HEADER_H */ 131#endif /* __PERF_HEADER_H */
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 02ed318d7312..95887804dc8e 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1182,7 +1182,7 @@ size_t hists__fprintf_nr_events(struct hists *self, FILE *fp)
1182 size_t ret = 0; 1182 size_t ret = 0;
1183 1183
1184 for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) { 1184 for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) {
1185 const char *name = event__get_event_name(i); 1185 const char *name = perf_event__name(i);
1186 1186
1187 if (!strcmp(name, "UNKNOWN")) 1187 if (!strcmp(name, "UNKNOWN"))
1188 continue; 1188 continue;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index ee0b61102571..a3a871f7bda3 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -165,7 +165,7 @@ struct perf_session *perf_session__new(const char *filename, int mode,
165 } else if (mode == O_WRONLY) { 165 } else if (mode == O_WRONLY) {
166 /* 166 /*
167 * In O_RDONLY mode this will be performed when reading the 167 * In O_RDONLY mode this will be performed when reading the
168 * kernel MMAP event, in event__process_mmap(). 168 * kernel MMAP event, in perf_event__process_mmap().
169 */ 169 */
170 if (perf_session__create_kernel_maps(self) < 0) 170 if (perf_session__create_kernel_maps(self) < 0)
171 goto out_delete; 171 goto out_delete;
@@ -291,14 +291,14 @@ int perf_session__resolve_callchain(struct perf_session *self,
291 return 0; 291 return 0;
292} 292}
293 293
294static int process_event_synth_stub(event_t *event __used, 294static int process_event_synth_stub(union perf_event *event __used,
295 struct perf_session *session __used) 295 struct perf_session *session __used)
296{ 296{
297 dump_printf(": unhandled!\n"); 297 dump_printf(": unhandled!\n");
298 return 0; 298 return 0;
299} 299}
300 300
301static int process_event_stub(event_t *event __used, 301static int process_event_stub(union perf_event *event __used,
302 struct perf_sample *sample __used, 302 struct perf_sample *sample __used,
303 struct perf_session *session __used) 303 struct perf_session *session __used)
304{ 304{
@@ -306,7 +306,7 @@ static int process_event_stub(event_t *event __used,
306 return 0; 306 return 0;
307} 307}
308 308
309static int process_finished_round_stub(event_t *event __used, 309static int process_finished_round_stub(union perf_event *event __used,
310 struct perf_session *session __used, 310 struct perf_session *session __used,
311 struct perf_event_ops *ops __used) 311 struct perf_event_ops *ops __used)
312{ 312{
@@ -314,7 +314,7 @@ static int process_finished_round_stub(event_t *event __used,
314 return 0; 314 return 0;
315} 315}
316 316
317static int process_finished_round(event_t *event, 317static int process_finished_round(union perf_event *event,
318 struct perf_session *session, 318 struct perf_session *session,
319 struct perf_event_ops *ops); 319 struct perf_event_ops *ops);
320 320
@@ -331,7 +331,7 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
331 if (handler->exit == NULL) 331 if (handler->exit == NULL)
332 handler->exit = process_event_stub; 332 handler->exit = process_event_stub;
333 if (handler->lost == NULL) 333 if (handler->lost == NULL)
334 handler->lost = event__process_lost; 334 handler->lost = perf_event__process_lost;
335 if (handler->read == NULL) 335 if (handler->read == NULL)
336 handler->read = process_event_stub; 336 handler->read = process_event_stub;
337 if (handler->throttle == NULL) 337 if (handler->throttle == NULL)
@@ -365,98 +365,98 @@ void mem_bswap_64(void *src, int byte_size)
365 } 365 }
366} 366}
367 367
368static void event__all64_swap(event_t *self) 368static void perf_event__all64_swap(union perf_event *event)
369{ 369{
370 struct perf_event_header *hdr = &self->header; 370 struct perf_event_header *hdr = &event->header;
371 mem_bswap_64(hdr + 1, self->header.size - sizeof(*hdr)); 371 mem_bswap_64(hdr + 1, event->header.size - sizeof(*hdr));
372} 372}
373 373
374static void event__comm_swap(event_t *self) 374static void perf_event__comm_swap(union perf_event *event)
375{ 375{
376 self->comm.pid = bswap_32(self->comm.pid); 376 event->comm.pid = bswap_32(event->comm.pid);
377 self->comm.tid = bswap_32(self->comm.tid); 377 event->comm.tid = bswap_32(event->comm.tid);
378} 378}
379 379
380static void event__mmap_swap(event_t *self) 380static void perf_event__mmap_swap(union perf_event *event)
381{ 381{
382 self->mmap.pid = bswap_32(self->mmap.pid); 382 event->mmap.pid = bswap_32(event->mmap.pid);
383 self->mmap.tid = bswap_32(self->mmap.tid); 383 event->mmap.tid = bswap_32(event->mmap.tid);
384 self->mmap.start = bswap_64(self->mmap.start); 384 event->mmap.start = bswap_64(event->mmap.start);
385 self->mmap.len = bswap_64(self->mmap.len); 385 event->mmap.len = bswap_64(event->mmap.len);
386 self->mmap.pgoff = bswap_64(self->mmap.pgoff); 386 event->mmap.pgoff = bswap_64(event->mmap.pgoff);
387} 387}
388 388
389static void event__task_swap(event_t *self) 389static void perf_event__task_swap(union perf_event *event)
390{ 390{
391 self->fork.pid = bswap_32(self->fork.pid); 391 event->fork.pid = bswap_32(event->fork.pid);
392 self->fork.tid = bswap_32(self->fork.tid); 392 event->fork.tid = bswap_32(event->fork.tid);
393 self->fork.ppid = bswap_32(self->fork.ppid); 393 event->fork.ppid = bswap_32(event->fork.ppid);
394 self->fork.ptid = bswap_32(self->fork.ptid); 394 event->fork.ptid = bswap_32(event->fork.ptid);
395 self->fork.time = bswap_64(self->fork.time); 395 event->fork.time = bswap_64(event->fork.time);
396} 396}
397 397
398static void event__read_swap(event_t *self) 398static void perf_event__read_swap(union perf_event *event)
399{ 399{
400 self->read.pid = bswap_32(self->read.pid); 400 event->read.pid = bswap_32(event->read.pid);
401 self->read.tid = bswap_32(self->read.tid); 401 event->read.tid = bswap_32(event->read.tid);
402 self->read.value = bswap_64(self->read.value); 402 event->read.value = bswap_64(event->read.value);
403 self->read.time_enabled = bswap_64(self->read.time_enabled); 403 event->read.time_enabled = bswap_64(event->read.time_enabled);
404 self->read.time_running = bswap_64(self->read.time_running); 404 event->read.time_running = bswap_64(event->read.time_running);
405 self->read.id = bswap_64(self->read.id); 405 event->read.id = bswap_64(event->read.id);
406} 406}
407 407
408static void event__attr_swap(event_t *self) 408static void perf_event__attr_swap(union perf_event *event)
409{ 409{
410 size_t size; 410 size_t size;
411 411
412 self->attr.attr.type = bswap_32(self->attr.attr.type); 412 event->attr.attr.type = bswap_32(event->attr.attr.type);
413 self->attr.attr.size = bswap_32(self->attr.attr.size); 413 event->attr.attr.size = bswap_32(event->attr.attr.size);
414 self->attr.attr.config = bswap_64(self->attr.attr.config); 414 event->attr.attr.config = bswap_64(event->attr.attr.config);
415 self->attr.attr.sample_period = bswap_64(self->attr.attr.sample_period); 415 event->attr.attr.sample_period = bswap_64(event->attr.attr.sample_period);
416 self->attr.attr.sample_type = bswap_64(self->attr.attr.sample_type); 416 event->attr.attr.sample_type = bswap_64(event->attr.attr.sample_type);
417 self->attr.attr.read_format = bswap_64(self->attr.attr.read_format); 417 event->attr.attr.read_format = bswap_64(event->attr.attr.read_format);
418 self->attr.attr.wakeup_events = bswap_32(self->attr.attr.wakeup_events); 418 event->attr.attr.wakeup_events = bswap_32(event->attr.attr.wakeup_events);
419 self->attr.attr.bp_type = bswap_32(self->attr.attr.bp_type); 419 event->attr.attr.bp_type = bswap_32(event->attr.attr.bp_type);
420 self->attr.attr.bp_addr = bswap_64(self->attr.attr.bp_addr); 420 event->attr.attr.bp_addr = bswap_64(event->attr.attr.bp_addr);
421 self->attr.attr.bp_len = bswap_64(self->attr.attr.bp_len); 421 event->attr.attr.bp_len = bswap_64(event->attr.attr.bp_len);
422 422
423 size = self->header.size; 423 size = event->header.size;
424 size -= (void *)&self->attr.id - (void *)self; 424 size -= (void *)&event->attr.id - (void *)event;
425 mem_bswap_64(self->attr.id, size); 425 mem_bswap_64(event->attr.id, size);
426} 426}
427 427
428static void event__event_type_swap(event_t *self) 428static void perf_event__event_type_swap(union perf_event *event)
429{ 429{
430 self->event_type.event_type.event_id = 430 event->event_type.event_type.event_id =
431 bswap_64(self->event_type.event_type.event_id); 431 bswap_64(event->event_type.event_type.event_id);
432} 432}
433 433
434static void event__tracing_data_swap(event_t *self) 434static void perf_event__tracing_data_swap(union perf_event *event)
435{ 435{
436 self->tracing_data.size = bswap_32(self->tracing_data.size); 436 event->tracing_data.size = bswap_32(event->tracing_data.size);
437} 437}
438 438
439typedef void (*event__swap_op)(event_t *self); 439typedef void (*perf_event__swap_op)(union perf_event *event);
440 440
441static event__swap_op event__swap_ops[] = { 441static perf_event__swap_op perf_event__swap_ops[] = {
442 [PERF_RECORD_MMAP] = event__mmap_swap, 442 [PERF_RECORD_MMAP] = perf_event__mmap_swap,
443 [PERF_RECORD_COMM] = event__comm_swap, 443 [PERF_RECORD_COMM] = perf_event__comm_swap,
444 [PERF_RECORD_FORK] = event__task_swap, 444 [PERF_RECORD_FORK] = perf_event__task_swap,
445 [PERF_RECORD_EXIT] = event__task_swap, 445 [PERF_RECORD_EXIT] = perf_event__task_swap,
446 [PERF_RECORD_LOST] = event__all64_swap, 446 [PERF_RECORD_LOST] = perf_event__all64_swap,
447 [PERF_RECORD_READ] = event__read_swap, 447 [PERF_RECORD_READ] = perf_event__read_swap,
448 [PERF_RECORD_SAMPLE] = event__all64_swap, 448 [PERF_RECORD_SAMPLE] = perf_event__all64_swap,
449 [PERF_RECORD_HEADER_ATTR] = event__attr_swap, 449 [PERF_RECORD_HEADER_ATTR] = perf_event__attr_swap,
450 [PERF_RECORD_HEADER_EVENT_TYPE] = event__event_type_swap, 450 [PERF_RECORD_HEADER_EVENT_TYPE] = perf_event__event_type_swap,
451 [PERF_RECORD_HEADER_TRACING_DATA] = event__tracing_data_swap, 451 [PERF_RECORD_HEADER_TRACING_DATA] = perf_event__tracing_data_swap,
452 [PERF_RECORD_HEADER_BUILD_ID] = NULL, 452 [PERF_RECORD_HEADER_BUILD_ID] = NULL,
453 [PERF_RECORD_HEADER_MAX] = NULL, 453 [PERF_RECORD_HEADER_MAX] = NULL,
454}; 454};
455 455
456struct sample_queue { 456struct sample_queue {
457 u64 timestamp; 457 u64 timestamp;
458 u64 file_offset; 458 u64 file_offset;
459 event_t *event; 459 union perf_event *event;
460 struct list_head list; 460 struct list_head list;
461}; 461};
462 462
@@ -474,7 +474,7 @@ static void perf_session_free_sample_buffers(struct perf_session *session)
474} 474}
475 475
476static int perf_session_deliver_event(struct perf_session *session, 476static int perf_session_deliver_event(struct perf_session *session,
477 event_t *event, 477 union perf_event *event,
478 struct perf_sample *sample, 478 struct perf_sample *sample,
479 struct perf_event_ops *ops, 479 struct perf_event_ops *ops,
480 u64 file_offset); 480 u64 file_offset);
@@ -552,7 +552,7 @@ static void flush_sample_queue(struct perf_session *s,
552 * Flush every events below timestamp 7 552 * Flush every events below timestamp 7
553 * etc... 553 * etc...
554 */ 554 */
555static int process_finished_round(event_t *event __used, 555static int process_finished_round(union perf_event *event __used,
556 struct perf_session *session, 556 struct perf_session *session,
557 struct perf_event_ops *ops) 557 struct perf_event_ops *ops)
558{ 558{
@@ -609,7 +609,7 @@ static void __queue_event(struct sample_queue *new, struct perf_session *s)
609 609
610#define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct sample_queue)) 610#define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct sample_queue))
611 611
612static int perf_session_queue_event(struct perf_session *s, event_t *event, 612static int perf_session_queue_event(struct perf_session *s, union perf_event *event,
613 struct perf_sample *sample, u64 file_offset) 613 struct perf_sample *sample, u64 file_offset)
614{ 614{
615 struct ordered_samples *os = &s->ordered_samples; 615 struct ordered_samples *os = &s->ordered_samples;
@@ -662,7 +662,7 @@ static void callchain__printf(struct perf_sample *sample)
662} 662}
663 663
664static void perf_session__print_tstamp(struct perf_session *session, 664static void perf_session__print_tstamp(struct perf_session *session,
665 event_t *event, 665 union perf_event *event,
666 struct perf_sample *sample) 666 struct perf_sample *sample)
667{ 667{
668 if (event->header.type != PERF_RECORD_SAMPLE && 668 if (event->header.type != PERF_RECORD_SAMPLE &&
@@ -678,7 +678,7 @@ static void perf_session__print_tstamp(struct perf_session *session,
678 printf("%" PRIu64 " ", sample->time); 678 printf("%" PRIu64 " ", sample->time);
679} 679}
680 680
681static void dump_event(struct perf_session *session, event_t *event, 681static void dump_event(struct perf_session *session, union perf_event *event,
682 u64 file_offset, struct perf_sample *sample) 682 u64 file_offset, struct perf_sample *sample)
683{ 683{
684 if (!dump_trace) 684 if (!dump_trace)
@@ -693,10 +693,10 @@ static void dump_event(struct perf_session *session, event_t *event,
693 perf_session__print_tstamp(session, event, sample); 693 perf_session__print_tstamp(session, event, sample);
694 694
695 printf("%#" PRIx64 " [%#x]: PERF_RECORD_%s", file_offset, 695 printf("%#" PRIx64 " [%#x]: PERF_RECORD_%s", file_offset,
696 event->header.size, event__get_event_name(event->header.type)); 696 event->header.size, perf_event__name(event->header.type));
697} 697}
698 698
699static void dump_sample(struct perf_session *session, event_t *event, 699static void dump_sample(struct perf_session *session, union perf_event *event,
700 struct perf_sample *sample) 700 struct perf_sample *sample)
701{ 701{
702 if (!dump_trace) 702 if (!dump_trace)
@@ -711,7 +711,7 @@ static void dump_sample(struct perf_session *session, event_t *event,
711} 711}
712 712
713static int perf_session_deliver_event(struct perf_session *session, 713static int perf_session_deliver_event(struct perf_session *session,
714 event_t *event, 714 union perf_event *event,
715 struct perf_sample *sample, 715 struct perf_sample *sample,
716 struct perf_event_ops *ops, 716 struct perf_event_ops *ops,
717 u64 file_offset) 717 u64 file_offset)
@@ -745,7 +745,7 @@ static int perf_session_deliver_event(struct perf_session *session,
745} 745}
746 746
747static int perf_session__preprocess_sample(struct perf_session *session, 747static int perf_session__preprocess_sample(struct perf_session *session,
748 event_t *event, struct perf_sample *sample) 748 union perf_event *event, struct perf_sample *sample)
749{ 749{
750 if (event->header.type != PERF_RECORD_SAMPLE || 750 if (event->header.type != PERF_RECORD_SAMPLE ||
751 !(session->sample_type & PERF_SAMPLE_CALLCHAIN)) 751 !(session->sample_type & PERF_SAMPLE_CALLCHAIN))
@@ -760,7 +760,7 @@ static int perf_session__preprocess_sample(struct perf_session *session,
760 return 0; 760 return 0;
761} 761}
762 762
763static int perf_session__process_user_event(struct perf_session *session, event_t *event, 763static int perf_session__process_user_event(struct perf_session *session, union perf_event *event,
764 struct perf_event_ops *ops, u64 file_offset) 764 struct perf_event_ops *ops, u64 file_offset)
765{ 765{
766 dump_event(session, event, file_offset, NULL); 766 dump_event(session, event, file_offset, NULL);
@@ -785,15 +785,16 @@ static int perf_session__process_user_event(struct perf_session *session, event_
785} 785}
786 786
787static int perf_session__process_event(struct perf_session *session, 787static int perf_session__process_event(struct perf_session *session,
788 event_t *event, 788 union perf_event *event,
789 struct perf_event_ops *ops, 789 struct perf_event_ops *ops,
790 u64 file_offset) 790 u64 file_offset)
791{ 791{
792 struct perf_sample sample; 792 struct perf_sample sample;
793 int ret; 793 int ret;
794 794
795 if (session->header.needs_swap && event__swap_ops[event->header.type]) 795 if (session->header.needs_swap &&
796 event__swap_ops[event->header.type](event); 796 perf_event__swap_ops[event->header.type])
797 perf_event__swap_ops[event->header.type](event);
797 798
798 if (event->header.type >= PERF_RECORD_HEADER_MAX) 799 if (event->header.type >= PERF_RECORD_HEADER_MAX)
799 return -EINVAL; 800 return -EINVAL;
@@ -845,7 +846,7 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se
845static void perf_session__warn_about_errors(const struct perf_session *session, 846static void perf_session__warn_about_errors(const struct perf_session *session,
846 const struct perf_event_ops *ops) 847 const struct perf_event_ops *ops)
847{ 848{
848 if (ops->lost == event__process_lost && 849 if (ops->lost == perf_event__process_lost &&
849 session->hists.stats.total_lost != 0) { 850 session->hists.stats.total_lost != 0) {
850 ui__warning("Processed %" PRIu64 " events and LOST %" PRIu64 851 ui__warning("Processed %" PRIu64 " events and LOST %" PRIu64
851 "!\n\nCheck IO/CPU overload!\n\n", 852 "!\n\nCheck IO/CPU overload!\n\n",
@@ -877,7 +878,7 @@ volatile int session_done;
877static int __perf_session__process_pipe_events(struct perf_session *self, 878static int __perf_session__process_pipe_events(struct perf_session *self,
878 struct perf_event_ops *ops) 879 struct perf_event_ops *ops)
879{ 880{
880 event_t event; 881 union perf_event event;
881 uint32_t size; 882 uint32_t size;
882 int skip = 0; 883 int skip = 0;
883 u64 head; 884 u64 head;
@@ -958,7 +959,7 @@ int __perf_session__process_events(struct perf_session *session,
958 struct ui_progress *progress; 959 struct ui_progress *progress;
959 size_t page_size, mmap_size; 960 size_t page_size, mmap_size;
960 char *buf, *mmaps[8]; 961 char *buf, *mmaps[8];
961 event_t *event; 962 union perf_event *event;
962 uint32_t size; 963 uint32_t size;
963 964
964 perf_event_ops__fill_defaults(ops); 965 perf_event_ops__fill_defaults(ops);
@@ -1003,7 +1004,7 @@ remap:
1003 file_pos = file_offset + head; 1004 file_pos = file_offset + head;
1004 1005
1005more: 1006more:
1006 event = (event_t *)(buf + head); 1007 event = (union perf_event *)(buf + head);
1007 1008
1008 if (session->header.needs_swap) 1009 if (session->header.needs_swap)
1009 perf_event_header__bswap(&event->header); 1010 perf_event_header__bswap(&event->header);
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 365bf533a396..977b3a1b14aa 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -57,10 +57,11 @@ struct perf_session {
57 57
58struct perf_event_ops; 58struct perf_event_ops;
59 59
60typedef int (*event_op)(event_t *self, struct perf_sample *sample, 60typedef int (*event_op)(union perf_event *self, struct perf_sample *sample,
61 struct perf_session *session); 61 struct perf_session *session);
62typedef int (*event_synth_op)(event_t *self, struct perf_session *session); 62typedef int (*event_synth_op)(union perf_event *self,
63typedef int (*event_op2)(event_t *self, struct perf_session *session, 63 struct perf_session *session);
64typedef int (*event_op2)(union perf_event *self, struct perf_session *session,
64 struct perf_event_ops *ops); 65 struct perf_event_ops *ops);
65 66
66struct perf_event_ops { 67struct perf_event_ops {
@@ -157,11 +158,11 @@ size_t perf_session__fprintf_nr_events(struct perf_session *self, FILE *fp)
157} 158}
158 159
159static inline int perf_session__parse_sample(struct perf_session *session, 160static inline int perf_session__parse_sample(struct perf_session *session,
160 const event_t *event, 161 const union perf_event *event,
161 struct perf_sample *sample) 162 struct perf_sample *sample)
162{ 163{
163 return event__parse_sample(event, session->sample_type, 164 return perf_event__parse_sample(event, session->sample_type,
164 session->sample_id_all, sample); 165 session->sample_id_all, sample);
165} 166}
166 167
167#endif /* __PERF_SESSION_H */ 168#endif /* __PERF_SESSION_H */