Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6233dd5e authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

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: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0ed1e0be
Loading
Loading
Loading
Loading
+6 −14
Original line number Original line Diff line number Diff line
@@ -76,7 +76,7 @@ struct perf_record {
	long			samples;
	long			samples;
};
};


static int do_write_output(struct perf_record *rec, void *buf, size_t size)
static int perf_record__write(struct perf_record *rec, void *buf, size_t size)
{
{
	struct perf_data_file *file = &rec->file;
	struct perf_data_file *file = &rec->file;


@@ -97,21 +97,13 @@ static int do_write_output(struct perf_record *rec, void *buf, size_t size)
	return 0;
	return 0;
}
}


static int write_output(struct perf_record *rec, void *buf, size_t size)
{
	return do_write_output(rec, buf, size);
}

static int process_synthesized_event(struct perf_tool *tool,
static int process_synthesized_event(struct perf_tool *tool,
				     union perf_event *event,
				     union perf_event *event,
				     struct perf_sample *sample __maybe_unused,
				     struct perf_sample *sample __maybe_unused,
				     struct machine *machine __maybe_unused)
				     struct machine *machine __maybe_unused)
{
{
	struct perf_record *rec = container_of(tool, struct perf_record, tool);
	struct perf_record *rec = container_of(tool, struct perf_record, tool);
	if (write_output(rec, event, event->header.size) < 0)
	return perf_record__write(rec, event, event->header.size);
		return -1;

	return 0;
}
}


static int perf_record__mmap_read(struct perf_record *rec,
static int perf_record__mmap_read(struct perf_record *rec,
@@ -136,7 +128,7 @@ static int perf_record__mmap_read(struct perf_record *rec,
		size = md->mask + 1 - (old & md->mask);
		size = md->mask + 1 - (old & md->mask);
		old += size;
		old += size;


		if (write_output(rec, buf, size) < 0) {
		if (perf_record__write(rec, buf, size) < 0) {
			rc = -1;
			rc = -1;
			goto out;
			goto out;
		}
		}
@@ -146,7 +138,7 @@ static int perf_record__mmap_read(struct perf_record *rec,
	size = head - old;
	size = head - old;
	old += size;
	old += size;


	if (write_output(rec, buf, size) < 0) {
	if (perf_record__write(rec, buf, size) < 0) {
		rc = -1;
		rc = -1;
		goto out;
		goto out;
	}
	}
@@ -335,7 +327,7 @@ static int perf_record__mmap_read_all(struct perf_record *rec)
	}
	}


	if (perf_header__has_feat(&rec->session->header, HEADER_TRACING_DATA))
	if (perf_header__has_feat(&rec->session->header, HEADER_TRACING_DATA))
		rc = write_output(rec, &finished_round_event,
		rc = perf_record__write(rec, &finished_round_event,
					sizeof(finished_round_event));
					sizeof(finished_round_event));


out:
out: