mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 12:43:55 +08:00
perf session: Move init/release code to separate functions
Separate init/release code into reader__init() and reader__release_decomp() functions. Remove a duplicate call to ui_progress__init_size(), the same call can be found in __perf_session__process_events(). For multiple traces ui_progress should be initialized by total size before reader__init() calls. 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/8bacf247de220be8e57af1d2b796322175f5e257.1634113027.git.alexey.v.bayduraev@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
3a3535e67d
commit
5965063094
@ -2189,28 +2189,23 @@ struct reader {
|
||||
};
|
||||
|
||||
static int
|
||||
reader__process_events(struct reader *rd, struct perf_session *session,
|
||||
struct ui_progress *prog)
|
||||
reader__init(struct reader *rd, bool *one_mmap)
|
||||
{
|
||||
u64 data_size = rd->data_size;
|
||||
u64 page_offset, size;
|
||||
int err = 0, mmap_prot, mmap_flags;
|
||||
char *buf, **mmaps = rd->mmaps;
|
||||
union perf_event *event;
|
||||
s64 skip;
|
||||
u64 page_offset;
|
||||
char **mmaps = rd->mmaps;
|
||||
|
||||
page_offset = page_size * (rd->data_offset / page_size);
|
||||
rd->file_offset = page_offset;
|
||||
rd->head = rd->data_offset - page_offset;
|
||||
|
||||
ui_progress__init_size(prog, data_size, "Processing events...");
|
||||
|
||||
data_size += rd->data_offset;
|
||||
|
||||
rd->mmap_size = MMAP_SIZE;
|
||||
if (rd->mmap_size > data_size) {
|
||||
rd->mmap_size = data_size;
|
||||
session->one_mmap = true;
|
||||
if (one_mmap)
|
||||
*one_mmap = true;
|
||||
}
|
||||
|
||||
memset(mmaps, 0, sizeof(rd->mmaps));
|
||||
@ -2218,6 +2213,31 @@ reader__process_events(struct reader *rd, struct perf_session *session,
|
||||
if (zstd_init(&rd->zstd_data, 0))
|
||||
return -1;
|
||||
rd->decomp_data.zstd_decomp = &rd->zstd_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
reader__release_decomp(struct reader *rd)
|
||||
{
|
||||
perf_decomp__release_events(rd->decomp_data.decomp);
|
||||
zstd_fini(&rd->zstd_data);
|
||||
}
|
||||
|
||||
static int
|
||||
reader__process_events(struct reader *rd, struct perf_session *session,
|
||||
struct ui_progress *prog)
|
||||
{
|
||||
u64 page_offset, size;
|
||||
int err = 0, 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;
|
||||
@ -2291,7 +2311,7 @@ more:
|
||||
if (session_done())
|
||||
goto out;
|
||||
|
||||
if (rd->file_pos < data_size)
|
||||
if (rd->file_pos < rd->data_size + rd->data_offset)
|
||||
goto more;
|
||||
|
||||
out:
|
||||
@ -2348,8 +2368,7 @@ out_err:
|
||||
*/
|
||||
ordered_events__reinit(&session->ordered_events);
|
||||
auxtrace__free_events(session);
|
||||
perf_decomp__release_events(rd.decomp_data.decomp);
|
||||
zstd_fini(&rd.zstd_data);
|
||||
reader__release_decomp(&rd);
|
||||
session->one_mmap = false;
|
||||
return err;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user