[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <62fe2c88cf00300c8e27d7056e6640a7db0aff7a.1633424934.git.alexey.v.bayduraev@linux.intel.com>
Date: Tue, 5 Oct 2021 13:27:00 +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 v2 3/5] perf session: Move init/exit code to separate functions
Separating init/exit code into reader__init and reader__exit functions.
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 | 42 ++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 50f2ec523ae0..53cd7a3b5efd 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -2190,28 +2190,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)
{
struct reader_state *st = &rd->state;
- u64 page_offset, size;
- int err = 0, mmap_prot, mmap_flags;
- char *buf, **mmaps = st->mmaps;
- union perf_event *event;
- s64 skip;
+ u64 page_offset;
+ char **mmaps = st->mmaps;
page_offset = page_size * (rd->data_offset / page_size);
st->file_offset = page_offset;
st->head = rd->data_offset - page_offset;
- ui_progress__init_size(prog, rd->data_size, "Processing events...");
-
st->data_size = rd->data_size + rd->data_offset;
st->mmap_size = MMAP_SIZE;
if (st->mmap_size > st->data_size) {
st->mmap_size = st->data_size;
- session->one_mmap = true;
+ if (one_mmap)
+ *one_mmap = true;
}
memset(mmaps, 0, sizeof(st->mmaps));
@@ -2220,6 +2215,27 @@ reader__process_events(struct reader *rd, struct perf_session *session,
return -1;
rd->decomp_data.zstd_decomp = &rd->zstd_data;
+ return 0;
+}
+
+static void
+reader__exit(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)
+{
+ struct reader_state *st = &rd->state;
+ u64 page_offset, size;
+ int err = 0, mmap_prot, mmap_flags;
+ char *buf, **mmaps = st->mmaps;
+ union perf_event *event;
+ s64 skip;
+
mmap_prot = PROT_READ;
mmap_flags = MAP_SHARED;
@@ -2297,8 +2313,6 @@ reader__process_events(struct reader *rd, struct perf_session *session,
out:
session->active_decomp = &session->decomp_data;
- perf_decomp__release_events(rd->decomp_data.decomp);
- zstd_fini(&rd->zstd_data);
return err;
}
@@ -2330,6 +2344,9 @@ static int __perf_session__process_events(struct perf_session *session)
ui_progress__init_size(&prog, rd.data_size, "Processing events...");
+ err = reader__init(&rd, &session->one_mmap);
+ if (err)
+ goto out_err;
err = reader__process_events(&rd, session, &prog);
if (err)
goto out_err;
@@ -2352,6 +2369,7 @@ static int __perf_session__process_events(struct perf_session *session)
ordered_events__reinit(&session->ordered_events);
auxtrace__free_events(session);
session->one_mmap = false;
+ reader__exit(&rd);
return err;
}
--
2.19.0
Powered by blists - more mailing lists