[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <7e4309ecdbb54fad42b75ae68e474b17a1f40b07.1633596227.git.alexey.v.bayduraev@linux.intel.com>
Date: Thu, 7 Oct 2021 13:25:39 +0300
From: Alexey Bayduraev <alexey.v.bayduraev@...ux.intel.com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Jiri Olsa <jolsa@...hat.com>, Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
linux-kernel <linux-kernel@...r.kernel.org>,
Andi Kleen <ak@...ux.intel.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Alexander Antonov <alexander.antonov@...ux.intel.com>,
Alexei Budankov <abudankov@...wei.com>,
Riccardo Mancini <rickyman7@...il.com>
Subject: [PATCH v3 4/8] perf session: Move map code to separate function
Moving mapping code into separate reader__mmap function.
Suggested-by: Jiri Olsa <jolsa@...nel.org>
Acked-by: Namhyung Kim <namhyung@...il.com>
Reviewed-by: Riccardo Mancini <rickyman7@...il.com>
Tested-by: Riccardo Mancini <rickyman7@...il.com>
Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@...ux.intel.com>
---
tools/perf/util/session.c | 39 ++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 00417b0d29ec..36faa2d598b2 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -2220,18 +2220,10 @@ reader__release_decomp(struct reader *rd)
}
static int
-reader__process_events(struct reader *rd, struct perf_session *session,
- struct ui_progress *prog)
+reader__mmap(struct reader *rd, struct perf_session *session)
{
- u64 page_offset, size;
- int err = 0, mmap_prot, mmap_flags;
+ int mmap_prot, mmap_flags;
char *buf, **mmaps = rd->mmaps;
- union perf_event *event;
- s64 skip;
-
- err = reader__init(rd, &session->one_mmap);
- if (err)
- goto out;
mmap_prot = PROT_READ;
mmap_flags = MAP_SHARED;
@@ -2242,13 +2234,12 @@ reader__process_events(struct reader *rd, struct perf_session *session,
mmap_prot |= PROT_WRITE;
mmap_flags = MAP_PRIVATE;
}
-remap:
+
buf = mmap(NULL, rd->mmap_size, mmap_prot, mmap_flags, rd->fd,
rd->file_offset);
if (buf == MAP_FAILED) {
pr_err("failed to mmap file\n");
- err = -errno;
- goto out;
+ return -errno;
}
mmaps[rd->mmap_idx] = rd->mmap_cur = buf;
rd->mmap_idx = (rd->mmap_idx + 1) & (ARRAY_SIZE(rd->mmaps) - 1);
@@ -2258,6 +2249,28 @@ reader__process_events(struct reader *rd, struct perf_session *session,
session->one_mmap_offset = rd->file_offset;
}
+ return 0;
+}
+
+static int
+reader__process_events(struct reader *rd, struct perf_session *session,
+ struct ui_progress *prog)
+{
+ u64 page_offset, size;
+ int err = 0;
+ char **mmaps = rd->mmaps;
+ union perf_event *event;
+ s64 skip;
+
+ err = reader__init(rd, &session->one_mmap);
+ if (err)
+ goto out;
+
+remap:
+ err = reader__mmap(rd, session);
+ if (err)
+ goto out;
+
more:
event = fetch_mmaped_event(rd->head, rd->mmap_size, rd->mmap_cur,
session->header.needs_swap);
--
2.19.0
Powered by blists - more mailing lists