aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2013-11-28 05:30:13 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-12-02 07:22:45 -0500
commit6233dd5efdf9e2c2da1b003cfb70307b7b2028e8 (patch)
treed09e6cdd068f625f8ed9e88618717058663fb87f /tools/perf
parent0ed1e0bee0b2c6b4cc6d7a63787739a9d3ac8aa8 (diff)
perf record: Unify data output code into perf_record__write function
Unifying current 2 data output functions do_write_output and write_output into single one perf_record__write. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1385634619-8129-2-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-record.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 65615a8bc25e..d93e2eef0979 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -76,7 +76,7 @@ struct perf_record {
76 long samples; 76 long samples;
77}; 77};
78 78
79static int do_write_output(struct perf_record *rec, void *buf, size_t size) 79static int perf_record__write(struct perf_record *rec, void *buf, size_t size)
80{ 80{
81 struct perf_data_file *file = &rec->file; 81 struct perf_data_file *file = &rec->file;
82 82
@@ -97,21 +97,13 @@ static int do_write_output(struct perf_record *rec, void *buf, size_t size)
97 return 0; 97 return 0;
98} 98}
99 99
100static int write_output(struct perf_record *rec, void *buf, size_t size)
101{
102 return do_write_output(rec, buf, size);
103}
104
105static int process_synthesized_event(struct perf_tool *tool, 100static int process_synthesized_event(struct perf_tool *tool,
106 union perf_event *event, 101 union perf_event *event,
107 struct perf_sample *sample __maybe_unused, 102 struct perf_sample *sample __maybe_unused,
108 struct machine *machine __maybe_unused) 103 struct machine *machine __maybe_unused)
109{ 104{
110 struct perf_record *rec = container_of(tool, struct perf_record, tool); 105 struct perf_record *rec = container_of(tool, struct perf_record, tool);
111 if (write_output(rec, event, event->header.size) < 0) 106 return perf_record__write(rec, event, event->header.size);
112 return -1;
113
114 return 0;
115} 107}
116 108
117static int perf_record__mmap_read(struct perf_record *rec, 109static int perf_record__mmap_read(struct perf_record *rec,
@@ -136,7 +128,7 @@ static int perf_record__mmap_read(struct perf_record *rec,
136 size = md->mask + 1 - (old & md->mask); 128 size = md->mask + 1 - (old & md->mask);
137 old += size; 129 old += size;
138 130
139 if (write_output(rec, buf, size) < 0) { 131 if (perf_record__write(rec, buf, size) < 0) {
140 rc = -1; 132 rc = -1;
141 goto out; 133 goto out;
142 } 134 }
@@ -146,7 +138,7 @@ static int perf_record__mmap_read(struct perf_record *rec,
146 size = head - old; 138 size = head - old;
147 old += size; 139 old += size;
148 140
149 if (write_output(rec, buf, size) < 0) { 141 if (perf_record__write(rec, buf, size) < 0) {
150 rc = -1; 142 rc = -1;
151 goto out; 143 goto out;
152 } 144 }
@@ -335,8 +327,8 @@ static int perf_record__mmap_read_all(struct perf_record *rec)
335 } 327 }
336 328
337 if (perf_header__has_feat(&rec->session->header, HEADER_TRACING_DATA)) 329 if (perf_header__has_feat(&rec->session->header, HEADER_TRACING_DATA))
338 rc = write_output(rec, &finished_round_event, 330 rc = perf_record__write(rec, &finished_round_event,
339 sizeof(finished_round_event)); 331 sizeof(finished_round_event));
340 332
341out: 333out:
342 return rc; 334 return rc;