lkml.org 
[lkml]   [2021]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v8 21/22] perf session: Introduce READER_NODATA state
Date
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@gmail.com>
Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@linux.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
\
 
 \ /
  Last update: 2021-06-30 18:00    [W:0.248 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site