Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf inject: Re-pipe AUX area tracing events

New AUX area tracing events must be re-piped by default.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1429608114-18194-1-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
cd17a9b5 7a680eb9

+58 -5
+58 -5
tools/perf/builtin-inject.c
··· 38 38 union perf_event event[0]; 39 39 }; 40 40 41 - static int perf_event__repipe_synth(struct perf_tool *tool, 42 - union perf_event *event) 41 + static int output_bytes(struct perf_inject *inject, void *buf, size_t sz) 43 42 { 44 - struct perf_inject *inject = container_of(tool, struct perf_inject, tool); 45 43 ssize_t size; 46 44 47 - size = perf_data_file__write(&inject->output, event, 48 - event->header.size); 45 + size = perf_data_file__write(&inject->output, buf, sz); 49 46 if (size < 0) 50 47 return -errno; 51 48 52 49 inject->bytes_written += size; 53 50 return 0; 51 + } 52 + 53 + static int copy_bytes(struct perf_inject *inject, int fd, off_t size) 54 + { 55 + char buf[4096]; 56 + ssize_t ssz; 57 + int ret; 58 + 59 + while (size > 0) { 60 + ssz = read(fd, buf, min(size, (off_t)sizeof(buf))); 61 + if (ssz < 0) 62 + return -errno; 63 + ret = output_bytes(inject, buf, ssz); 64 + if (ret) 65 + return ret; 66 + size -= ssz; 67 + } 68 + 69 + return 0; 70 + } 71 + 72 + static int perf_event__repipe_synth(struct perf_tool *tool, 73 + union perf_event *event) 74 + { 75 + struct perf_inject *inject = container_of(tool, struct perf_inject, 76 + tool); 77 + 78 + return output_bytes(inject, event, event->header.size); 54 79 } 55 80 56 81 static int perf_event__repipe_oe_synth(struct perf_tool *tool, ··· 109 84 return 0; 110 85 111 86 return perf_event__repipe_synth(tool, event); 87 + } 88 + 89 + static s64 perf_event__repipe_auxtrace(struct perf_tool *tool, 90 + union perf_event *event, 91 + struct perf_session *session 92 + __maybe_unused) 93 + { 94 + struct perf_inject *inject = container_of(tool, struct perf_inject, 95 + tool); 96 + int ret; 97 + 98 + if (perf_data_file__is_pipe(session->file) || !session->one_mmap) { 99 + ret = output_bytes(inject, event, event->header.size); 100 + if (ret < 0) 101 + return ret; 102 + ret = copy_bytes(inject, perf_data_file__fd(session->file), 103 + event->auxtrace.size); 104 + } else { 105 + ret = output_bytes(inject, event, 106 + event->header.size + event->auxtrace.size); 107 + } 108 + if (ret < 0) 109 + return ret; 110 + 111 + return event->auxtrace.size; 112 112 } 113 113 114 114 static int perf_event__repipe(struct perf_tool *tool, ··· 463 413 .unthrottle = perf_event__repipe, 464 414 .attr = perf_event__repipe_attr, 465 415 .tracing_data = perf_event__repipe_op2_synth, 416 + .auxtrace_info = perf_event__repipe_op2_synth, 417 + .auxtrace = perf_event__repipe_auxtrace, 418 + .auxtrace_error = perf_event__repipe_op2_synth, 466 419 .finished_round = perf_event__repipe_oe_synth, 467 420 .build_id = perf_event__repipe_op2_synth, 468 421 .id_index = perf_event__repipe_op2_synth,