[PATCH 4/5] perf session: Add data_offset to reader object

From: Jiri Olsa
Date: Wed Dec 26 2018 - 08:51:52 EST


Adding data_offset to reader object.

Link: http://lkml.kernel.org/n/tip-k531enq5bmack3mjccjblvi6@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/util/session.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 40692875f196..bc2a4f80535c 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1816,6 +1816,7 @@ fetch_mmaped_event(struct perf_session *session,
struct reader {
int fd;
u64 data_size;
+ u64 data_offset;
};

static int __perf_session__process_events(struct perf_session *session)
@@ -1823,10 +1824,10 @@ static int __perf_session__process_events(struct perf_session *session)
struct reader rd = {
.fd = perf_data__fd(session->data),
.data_size = session->header.data_size,
+ .data_offset = session->header.data_offset,
};
struct ordered_events *oe = &session->ordered_events;
struct perf_tool *tool = session->tool;
- u64 data_offset = session->header.data_offset;
u64 data_size = rd.data_size;
u64 head, page_offset, file_offset, file_pos, size;
int err, mmap_prot, mmap_flags, map_idx = 0;
@@ -1838,16 +1839,16 @@ static int __perf_session__process_events(struct perf_session *session)

perf_tool__fill_defaults(tool);

- page_offset = page_size * (data_offset / page_size);
+ page_offset = page_size * (rd.data_offset / page_size);
file_offset = page_offset;
- head = data_offset - page_offset;
+ head = rd.data_offset - page_offset;

if (data_size == 0)
goto out;

ui_progress__init_size(&prog, data_size, "Processing events...");

- data_size += data_offset;
+ data_size += rd.data_offset;

mmap_size = MMAP_SIZE;
if (mmap_size > data_size) {
--
2.17.2