[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <17c991ec0d814a5718dc49ae08cabc3210b4a133.1625065643.git.alexey.v.bayduraev@linux.intel.com>
Date: Wed, 30 Jun 2021 18:55: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 v8 21/22] perf session: Introduce READER_NODATA state
Adding READER_NODATA state to differentiate it from the real end-of-file
state. Also an indent depth in reades initialization loop is reduced.
Suggested-by: Namhyung Kim <namhyung@...il.com>
Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@...ux.intel.com>
---
tools/perf/util/session.c | 45 ++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index b11a502c22a3..c2b6c5f4e119 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -70,7 +70,8 @@ struct reader_state {
enum {
READER_EOF = 0,
- READER_OK = 1,
+ READER_NODATA = 1,
+ READER_OK = 2,
};
struct reader {
@@ -2305,7 +2306,7 @@ reader__read_event(struct reader *rd, struct perf_session *session,
return PTR_ERR(event);
if (!event)
- return READER_EOF;
+ return READER_NODATA;
session->active_reader = rd;
size = event->header.size;
@@ -2395,7 +2396,7 @@ static int __perf_session__process_events(struct perf_session *session)
err = reader__read_event(rd, session, &prog);
if (err < 0)
break;
- if (err == READER_EOF) {
+ if (err == READER_NODATA) {
err = reader__mmap(rd, session);
if (err <= 0)
break;
@@ -2472,25 +2473,25 @@ static int __perf_session__process_dir_events(struct perf_session *session)
readers++;
for (i = 0; i < data->dir.nr; i++) {
- if (data->dir.files[i].size) {
- rd[readers] = (struct reader) {
- .fd = data->dir.files[i].fd,
- .path = data->dir.files[i].path,
- .data_size = data->dir.files[i].size,
- .data_offset = 0,
- .in_place_update = session->data->in_place_update,
- };
- ret = reader__init(&rd[readers], NULL);
- if (ret)
- goto out_err;
- ret = reader__mmap(&rd[readers], session);
- if (ret != READER_OK) {
- if (ret == READER_EOF)
- ret = -EINVAL;
- goto out_err;
- }
- readers++;
+ if (!data->dir.files[i].size)
+ continue;
+ rd[readers] = (struct reader) {
+ .fd = data->dir.files[i].fd,
+ .path = data->dir.files[i].path,
+ .data_size = data->dir.files[i].size,
+ .data_offset = 0,
+ .in_place_update = session->data->in_place_update,
+ };
+ ret = reader__init(&rd[readers], NULL);
+ if (ret)
+ goto out_err;
+ ret = reader__mmap(&rd[readers], session);
+ if (ret != READER_OK) {
+ if (ret == READER_EOF)
+ ret = -EINVAL;
+ goto out_err;
}
+ readers++;
}
i = 0;
@@ -2507,7 +2508,7 @@ static int __perf_session__process_dir_events(struct perf_session *session)
ret = reader__read_event(&rd[i], session, &prog);
if (ret < 0)
break;
- if (ret == READER_EOF) {
+ if (ret == READER_NODATA) {
ret = reader__mmap(&rd[i], session);
if (ret < 0)
goto out_err;
--
2.19.0
Powered by blists - more mailing lists