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

perf tools: Add 'struct perf_mmap' arg to record__write()

The struct perf_mmap map argument will hold the file pointer to write
the data to.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180913125450.21342-5-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
ded2b8fe e035f4ca

+20 -15
+14 -10
tools/perf/builtin-record.c
··· 106 106 trigger_is_ready(&switch_output_trigger); 107 107 } 108 108 109 - static int record__write(struct record *rec, void *bf, size_t size) 109 + static int record__write(struct record *rec, struct perf_mmap *map __maybe_unused, 110 + void *bf, size_t size) 110 111 { 111 - if (perf_data__write(rec->session->data, bf, size) < 0) { 112 + struct perf_data_file *file = &rec->session->data->file; 113 + 114 + if (perf_data_file__write(file, bf, size) < 0) { 112 115 pr_err("failed to write perf data, error: %m\n"); 113 116 return -1; 114 117 } ··· 130 127 struct machine *machine __maybe_unused) 131 128 { 132 129 struct record *rec = container_of(tool, struct record, tool); 133 - return record__write(rec, event, event->header.size); 130 + return record__write(rec, NULL, event, event->header.size); 134 131 } 135 132 136 - static int record__pushfn(void *to, void *bf, size_t size) 133 + static int record__pushfn(struct perf_mmap *map, void *to, void *bf, size_t size) 137 134 { 138 135 struct record *rec = to; 139 136 140 137 rec->samples++; 141 - return record__write(rec, bf, size); 138 + return record__write(rec, map, bf, size); 142 139 } 143 140 144 141 static volatile int done; ··· 173 170 #ifdef HAVE_AUXTRACE_SUPPORT 174 171 175 172 static int record__process_auxtrace(struct perf_tool *tool, 173 + struct perf_mmap *map, 176 174 union perf_event *event, void *data1, 177 175 size_t len1, void *data2, size_t len2) 178 176 { ··· 201 197 if (padding) 202 198 padding = 8 - padding; 203 199 204 - record__write(rec, event, event->header.size); 205 - record__write(rec, data1, len1); 200 + record__write(rec, map, event, event->header.size); 201 + record__write(rec, map, data1, len1); 206 202 if (len2) 207 - record__write(rec, data2, len2); 208 - record__write(rec, &pad, padding); 203 + record__write(rec, map, data2, len2); 204 + record__write(rec, map, &pad, padding); 209 205 210 206 return 0; 211 207 } ··· 553 549 * at least one event. 554 550 */ 555 551 if (bytes_written != rec->bytes_written) 556 - rc = record__write(rec, &finished_round_event, sizeof(finished_round_event)); 552 + rc = record__write(rec, NULL, &finished_round_event, sizeof(finished_round_event)); 557 553 558 554 if (overwrite) 559 555 perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_EMPTY);
+1 -1
tools/perf/util/auxtrace.c
··· 1285 1285 ev.auxtrace.tid = mm->tid; 1286 1286 ev.auxtrace.cpu = mm->cpu; 1287 1287 1288 - if (fn(tool, &ev, data1, len1, data2, len2)) 1288 + if (fn(tool, map, &ev, data1, len1, data2, len2)) 1289 1289 return -1; 1290 1290 1291 1291 mm->prev = head;
+1
tools/perf/util/auxtrace.h
··· 435 435 bool per_cpu); 436 436 437 437 typedef int (*process_auxtrace_t)(struct perf_tool *tool, 438 + struct perf_mmap *map, 438 439 union perf_event *event, void *data1, 439 440 size_t len1, void *data2, size_t len2); 440 441
+3 -3
tools/perf/util/mmap.c
··· 281 281 } 282 282 283 283 int perf_mmap__push(struct perf_mmap *md, void *to, 284 - int push(void *to, void *buf, size_t size)) 284 + int push(struct perf_mmap *map, void *to, void *buf, size_t size)) 285 285 { 286 286 u64 head = perf_mmap__read_head(md); 287 287 unsigned char *data = md->base + page_size; ··· 300 300 size = md->mask + 1 - (md->start & md->mask); 301 301 md->start += size; 302 302 303 - if (push(to, buf, size) < 0) { 303 + if (push(md, to, buf, size) < 0) { 304 304 rc = -1; 305 305 goto out; 306 306 } ··· 310 310 size = md->end - md->start; 311 311 md->start += size; 312 312 313 - if (push(to, buf, size) < 0) { 313 + if (push(md, to, buf, size) < 0) { 314 314 rc = -1; 315 315 goto out; 316 316 }
+1 -1
tools/perf/util/mmap.h
··· 93 93 union perf_event *perf_mmap__read_event(struct perf_mmap *map); 94 94 95 95 int perf_mmap__push(struct perf_mmap *md, void *to, 96 - int push(void *to, void *buf, size_t size)); 96 + int push(struct perf_mmap *map, void *to, void *buf, size_t size)); 97 97 98 98 size_t perf_mmap__mmap_len(struct perf_mmap *map); 99 99