diff options
author | Alexey Bayduraev <[email protected]> | 2021-10-13 12:06:38 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <[email protected]> | 2021-10-25 13:47:41 -0300 |
commit | 06763e7b30d9b502c48ad982851a195781aeff81 (patch) | |
tree | 8d4b03aad6dce49e89a6ba35b62c5c8b4967bce0 | |
parent | 5965063094944be751a7bff6ccd3e404c14b65cc (diff) |
perf session: Move reader map code to a separate function
Move the mapping code into a separate reader__mmap() function.
Suggested-by: Jiri Olsa <[email protected]>
Reviewed-by: Jiri Olsa <[email protected]>
Reviewed-by: Riccardo Mancini <[email protected]>
Signed-off-by: Alexey Bayduraev <[email protected]>
Tested-by: Riccardo Mancini <[email protected]>
Acked-by: Namhyung Kim <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Antonov <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Alexei Budankov <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: https://lore.kernel.org/r/e445de5bb85bbd91287986802d6ed0ce1b419b5a.1634113027.git.alexey.v.bayduraev@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r-- | tools/perf/util/session.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index b315febea052..1abe870223f6 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2225,20 +2225,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; - - session->active_decomp = &rd->decomp_data; mmap_prot = PROT_READ; mmap_flags = MAP_SHARED; @@ -2249,13 +2239,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); @@ -2265,6 +2254,30 @@ remap: 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; + + session->active_decomp = &rd->decomp_data; + +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); |