perf session: Move reader map code to a separate function
Move the mapping code into a separate reader__mmap() function. Suggested-by: Jiri Olsa <jolsa@kernel.org> Reviewed-by: Jiri Olsa <jolsa@redhat.com> Reviewed-by: Riccardo Mancini <rickyman7@gmail.com> Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com> Tested-by: Riccardo Mancini <rickyman7@gmail.com> Acked-by: Namhyung Kim <namhyung@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Antonov <alexander.antonov@linux.intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexei Budankov <abudankov@huawei.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/e445de5bb85bbd91287986802d6ed0ce1b419b5a.1634113027.git.alexey.v.bayduraev@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
5965063094
commit
06763e7b30
@ -2225,20 +2225,10 @@ reader__release_decomp(struct reader *rd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
reader__process_events(struct reader *rd, struct perf_session *session,
|
reader__mmap(struct reader *rd, struct perf_session *session)
|
||||||
struct ui_progress *prog)
|
|
||||||
{
|
{
|
||||||
u64 page_offset, size;
|
int mmap_prot, mmap_flags;
|
||||||
int err = 0, mmap_prot, mmap_flags;
|
|
||||||
char *buf, **mmaps = rd->mmaps;
|
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_prot = PROT_READ;
|
||||||
mmap_flags = MAP_SHARED;
|
mmap_flags = MAP_SHARED;
|
||||||
@ -2249,13 +2239,12 @@ reader__process_events(struct reader *rd, struct perf_session *session,
|
|||||||
mmap_prot |= PROT_WRITE;
|
mmap_prot |= PROT_WRITE;
|
||||||
mmap_flags = MAP_PRIVATE;
|
mmap_flags = MAP_PRIVATE;
|
||||||
}
|
}
|
||||||
remap:
|
|
||||||
buf = mmap(NULL, rd->mmap_size, mmap_prot, mmap_flags, rd->fd,
|
buf = mmap(NULL, rd->mmap_size, mmap_prot, mmap_flags, rd->fd,
|
||||||
rd->file_offset);
|
rd->file_offset);
|
||||||
if (buf == MAP_FAILED) {
|
if (buf == MAP_FAILED) {
|
||||||
pr_err("failed to mmap file\n");
|
pr_err("failed to mmap file\n");
|
||||||
err = -errno;
|
return -errno;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
mmaps[rd->mmap_idx] = rd->mmap_cur = buf;
|
mmaps[rd->mmap_idx] = rd->mmap_cur = buf;
|
||||||
rd->mmap_idx = (rd->mmap_idx + 1) & (ARRAY_SIZE(rd->mmaps) - 1);
|
rd->mmap_idx = (rd->mmap_idx + 1) & (ARRAY_SIZE(rd->mmaps) - 1);
|
||||||
@ -2265,6 +2254,30 @@ remap:
|
|||||||
session->one_mmap_offset = rd->file_offset;
|
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:
|
more:
|
||||||
event = fetch_mmaped_event(rd->head, rd->mmap_size, rd->mmap_cur,
|
event = fetch_mmaped_event(rd->head, rd->mmap_size, rd->mmap_cur,
|
||||||
session->header.needs_swap);
|
session->header.needs_swap);
|
||||||
|
Loading…
Reference in New Issue
Block a user