From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>, Andi Kleen <ak@linux.intel.com>,
Alexey Budankov <alexey.budankov@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH V2 2/6] perf tools: Handle read errors from ctl_fd
Date: Tue, 1 Sep 2020 12:37:54 +0300 [thread overview]
Message-ID: <20200901093758.32293-3-adrian.hunter@intel.com> (raw)
In-Reply-To: <20200901093758.32293-1-adrian.hunter@intel.com>
Handle read errors from ctl_fd such as EINTR, EAGAIN and EWOULDBLOCK.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/evlist.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 62e3f87547ce..47d1045a19af 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1802,6 +1802,7 @@ static int evlist__ctlfd_recv(struct evlist *evlist, enum evlist_ctl_cmd *cmd,
char c;
size_t bytes_read = 0;
+ *cmd = EVLIST_CTL_CMD_UNSUPPORTED;
memset(cmd_data, 0, data_size);
data_size--;
@@ -1813,17 +1814,22 @@ static int evlist__ctlfd_recv(struct evlist *evlist, enum evlist_ctl_cmd *cmd,
cmd_data[bytes_read++] = c;
if (bytes_read == data_size)
break;
- } else {
- if (err == -1)
+ continue;
+ } else if (err == -1) {
+ if (errno == EINTR)
+ continue;
+ if (errno == EAGAIN || errno == EWOULDBLOCK)
+ err = 0;
+ else
pr_err("Failed to read from ctlfd %d: %m\n", evlist->ctl_fd.fd);
- break;
}
+ break;
} while (1);
pr_debug("Message from ctl_fd: \"%s%s\"\n", cmd_data,
bytes_read == data_size ? "" : c == '\n' ? "\\n" : "\\0");
- if (err > 0) {
+ if (bytes_read > 0) {
if (!strncmp(cmd_data, EVLIST_CTL_CMD_ENABLE_TAG,
(sizeof(EVLIST_CTL_CMD_ENABLE_TAG)-1))) {
*cmd = EVLIST_CTL_CMD_ENABLE;
@@ -1833,7 +1839,7 @@ static int evlist__ctlfd_recv(struct evlist *evlist, enum evlist_ctl_cmd *cmd,
}
}
- return err;
+ return bytes_read ? (int)bytes_read : err;
}
static int evlist__ctlfd_ack(struct evlist *evlist)
--
2.17.1
next prev parent reply other threads:[~2020-09-01 9:38 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-01 9:37 [PATCH V2 0/6] perf tools: Enable AUX area tracing snapshots using a FIFO Adrian Hunter
2020-09-01 9:37 ` [PATCH V2 1/6] perf tools: Consolidate --control option parsing into one function Adrian Hunter
2020-09-02 16:06 ` Alexey Budankov
2020-09-03 20:15 ` Arnaldo Carvalho de Melo
2020-09-01 9:37 ` Adrian Hunter [this message]
2020-09-02 16:11 ` [PATCH V2 2/6] perf tools: Handle read errors from ctl_fd Alexey Budankov
2020-09-03 20:16 ` Arnaldo Carvalho de Melo
2020-09-01 9:37 ` [PATCH V2 3/6] perf tools: Use AsciiDoc formatting for --control option documentation Adrian Hunter
2020-09-02 16:12 ` Alexey Budankov
2020-09-03 20:17 ` Arnaldo Carvalho de Melo
2020-09-01 9:37 ` [PATCH V2 4/6] perf tools: Add FIFO file names as alternative options to --control Adrian Hunter
2020-09-01 20:06 ` Jiri Olsa
2020-09-02 10:57 ` [PATCH V3 " Adrian Hunter
2020-09-02 17:03 ` Alexey Budankov
2020-09-03 10:38 ` Adrian Hunter
2020-09-03 12:29 ` [PATCH] perf tools: Consolidate close_control_option()'s into one function Adrian Hunter
2020-09-04 18:56 ` Arnaldo Carvalho de Melo
2020-09-03 20:21 ` [PATCH V3 4/6] perf tools: Add FIFO file names as alternative options to --control Arnaldo Carvalho de Melo
2020-09-01 9:37 ` [PATCH V2 5/6] perf record: Add 'snapshot' control command Adrian Hunter
2020-09-02 17:03 ` Alexey Budankov
2020-09-03 10:44 ` Adrian Hunter
2020-09-01 9:37 ` [PATCH V2 6/6] perf intel-pt: Document snapshot " Adrian Hunter
2020-09-02 16:53 ` Alexey Budankov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200901093758.32293-3-adrian.hunter@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexey.budankov@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.