diff options
Diffstat (limited to 'tools/perf/util/event.c')
-rw-r--r-- | tools/perf/util/event.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 52cf479bc593..dad55d04ffdd 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -56,13 +56,22 @@ const char *perf_event__name(unsigned int id) | |||
56 | return perf_event__names[id]; | 56 | return perf_event__names[id]; |
57 | } | 57 | } |
58 | 58 | ||
59 | static struct perf_sample synth_sample = { | 59 | static int perf_tool__process_synth_event(struct perf_tool *tool, |
60 | union perf_event *event, | ||
61 | struct machine *machine, | ||
62 | perf_event__handler_t process) | ||
63 | { | ||
64 | struct perf_sample synth_sample = { | ||
60 | .pid = -1, | 65 | .pid = -1, |
61 | .tid = -1, | 66 | .tid = -1, |
62 | .time = -1, | 67 | .time = -1, |
63 | .stream_id = -1, | 68 | .stream_id = -1, |
64 | .cpu = -1, | 69 | .cpu = -1, |
65 | .period = 1, | 70 | .period = 1, |
71 | .cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK, | ||
72 | }; | ||
73 | |||
74 | return process(tool, event, &synth_sample, machine); | ||
66 | }; | 75 | }; |
67 | 76 | ||
68 | /* | 77 | /* |
@@ -186,7 +195,7 @@ pid_t perf_event__synthesize_comm(struct perf_tool *tool, | |||
186 | if (perf_event__prepare_comm(event, pid, machine, &tgid, &ppid) != 0) | 195 | if (perf_event__prepare_comm(event, pid, machine, &tgid, &ppid) != 0) |
187 | return -1; | 196 | return -1; |
188 | 197 | ||
189 | if (process(tool, event, &synth_sample, machine) != 0) | 198 | if (perf_tool__process_synth_event(tool, event, machine, process) != 0) |
190 | return -1; | 199 | return -1; |
191 | 200 | ||
192 | return tgid; | 201 | return tgid; |
@@ -218,7 +227,7 @@ static int perf_event__synthesize_fork(struct perf_tool *tool, | |||
218 | 227 | ||
219 | event->fork.header.size = (sizeof(event->fork) + machine->id_hdr_size); | 228 | event->fork.header.size = (sizeof(event->fork) + machine->id_hdr_size); |
220 | 229 | ||
221 | if (process(tool, event, &synth_sample, machine) != 0) | 230 | if (perf_tool__process_synth_event(tool, event, machine, process) != 0) |
222 | return -1; | 231 | return -1; |
223 | 232 | ||
224 | return 0; | 233 | return 0; |
@@ -344,7 +353,7 @@ out: | |||
344 | event->mmap2.pid = tgid; | 353 | event->mmap2.pid = tgid; |
345 | event->mmap2.tid = pid; | 354 | event->mmap2.tid = pid; |
346 | 355 | ||
347 | if (process(tool, event, &synth_sample, machine) != 0) { | 356 | if (perf_tool__process_synth_event(tool, event, machine, process) != 0) { |
348 | rc = -1; | 357 | rc = -1; |
349 | break; | 358 | break; |
350 | } | 359 | } |
@@ -402,7 +411,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool, | |||
402 | 411 | ||
403 | memcpy(event->mmap.filename, pos->dso->long_name, | 412 | memcpy(event->mmap.filename, pos->dso->long_name, |
404 | pos->dso->long_name_len + 1); | 413 | pos->dso->long_name_len + 1); |
405 | if (process(tool, event, &synth_sample, machine) != 0) { | 414 | if (perf_tool__process_synth_event(tool, event, machine, process) != 0) { |
406 | rc = -1; | 415 | rc = -1; |
407 | break; | 416 | break; |
408 | } | 417 | } |
@@ -472,7 +481,7 @@ static int __event__synthesize_thread(union perf_event *comm_event, | |||
472 | /* | 481 | /* |
473 | * Send the prepared comm event | 482 | * Send the prepared comm event |
474 | */ | 483 | */ |
475 | if (process(tool, comm_event, &synth_sample, machine) != 0) | 484 | if (perf_tool__process_synth_event(tool, comm_event, machine, process) != 0) |
476 | break; | 485 | break; |
477 | 486 | ||
478 | rc = 0; | 487 | rc = 0; |
@@ -701,7 +710,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, | |||
701 | event->mmap.len = map->end - event->mmap.start; | 710 | event->mmap.len = map->end - event->mmap.start; |
702 | event->mmap.pid = machine->pid; | 711 | event->mmap.pid = machine->pid; |
703 | 712 | ||
704 | err = process(tool, event, &synth_sample, machine); | 713 | err = perf_tool__process_synth_event(tool, event, machine, process); |
705 | free(event); | 714 | free(event); |
706 | 715 | ||
707 | return err; | 716 | return err; |