summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Bayduraev <alexey.v.bayduraev@linux.intel.com>2021-10-13 12:06:37 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-10-25 13:47:41 -0300
commit5965063094944be751a7bff6ccd3e404c14b65cc (patch)
tree569a793eabc638834e7c79d0e5553181b500e382
parent3a3535e67dfdc29b4a2b455220244fb776f1df61 (diff)
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>
-rw-r--r--tools/perf/util/session.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 79a447130193..b315febea052 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -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;
}