[PATCH v3 6/8] perf session: Move event read code to separate function
From: Alexey Bayduraev
Date: Thu Oct 07 2021 - 06:26:17 EST
Separating reading code of single event into reader__read_event
function.
Suggested-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Acked-by: Namhyung Kim <namhyung@xxxxxxxxx>
Reviewed-by: Riccardo Mancini <rickyman7@xxxxxxxxx>
Tested-by: Riccardo Mancini <rickyman7@xxxxxxxxx>
Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@xxxxxxxxxxxxxxx>
---
tools/perf/util/session.c | 44 ++++++++++++++++++++++++++-------------
1 file changed, 30 insertions(+), 14 deletions(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 6289fcafdc86..6b255b0b23e0 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -2259,31 +2259,21 @@ reader__mmap(struct reader *rd, struct perf_session *session)
}
static int
-reader__process_events(struct reader *rd, struct perf_session *session,
- struct ui_progress *prog)
+reader__read_event(struct reader *rd, struct perf_session *session,
+ struct ui_progress *prog)
{
u64 size;
int err = 0;
union perf_event *event;
s64 skip;
- err = reader__init(rd, &session->one_mmap);
- if (err)
- goto out;
-
-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);
if (IS_ERR(event))
return PTR_ERR(event);
if (!event)
- goto remap;
+ return 1;
session->active_decomp = &rd->decomp_data;
size = event->header.size;
@@ -2311,6 +2301,33 @@ reader__process_events(struct reader *rd, struct perf_session *session,
ui_progress__update(prog, size);
+out:
+ session->active_decomp = &session->decomp_data;
+ return err;
+}
+
+static int
+reader__process_events(struct reader *rd, struct perf_session *session,
+ struct ui_progress *prog)
+{
+ int err;
+
+ err = reader__init(rd, &session->one_mmap);
+ if (err)
+ goto out;
+
+remap:
+ err = reader__mmap(rd, session);
+ if (err)
+ goto out;
+
+more:
+ err = reader__read_event(rd, session, prog);
+ if (err < 0)
+ goto out;
+ else if (err == 1)
+ goto remap;
+
if (session_done())
goto out;
@@ -2318,7 +2335,6 @@ reader__process_events(struct reader *rd, struct perf_session *session,
goto more;
out:
- session->active_decomp = &session->decomp_data;
return err;
}
--
2.19.0