From: Mark McLoughlin <markmc@redhat.com>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm@vger.kernel.org, Mark McLoughlin <markmc@redhat.com>
Subject: [PATCH 4/6] kvm: qemu: aggregate reads from eventfd
Date: Thu, 30 Oct 2008 17:51:51 +0000 [thread overview]
Message-ID: <1225389113-28332-5-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1225389113-28332-4-git-send-email-markmc@redhat.com>
Keep reading from eventfd until it's empty and aggregate the results.
Only really important when we're emulating eventfd using a pipe as
in that case we may have multiple "1" values queued up, potentially
leading to the pipe buffer filling up and the write side blocking.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
qemu/compatfd.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/qemu/compatfd.c b/qemu/compatfd.c
index 7e3e7f7..2da6dd6 100644
--- a/qemu/compatfd.c
+++ b/qemu/compatfd.c
@@ -153,7 +153,7 @@ int qemu_eventfd_write(int eventfd, uint64_t value)
return offset == 8 ? 0 : -1;
}
-uint64_t qemu_eventfd_read(int eventfd)
+static uint64_t qemu_eventfd_read_one(int eventfd)
{
char buffer[8];
size_t offset = 0;
@@ -177,3 +177,22 @@ uint64_t qemu_eventfd_read(int eventfd)
return value;
}
+
+uint64_t qemu_eventfd_read(int eventfd)
+{
+ uint64_t ret;
+ fd_set fds;
+ struct timeval tv;
+
+ FD_ZERO(&fds);
+ FD_SET(eventfd, &fds);
+
+ tv.tv_sec = tv.tv_usec = 0;
+
+ ret = 0;
+ do {
+ ret += qemu_eventfd_read_one(eventfd);
+ } while (select(eventfd + 1, &fds, NULL, NULL, &tv) > 0);
+
+ return ret;
+}
--
1.5.4.3
next prev parent reply other threads:[~2008-10-30 17:53 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-30 17:51 [PATCH 0/6] Kill off the virtio_net tx mitigation timer Mark McLoughlin
2008-10-30 17:51 ` [PATCH 1/6] kvm: qemu: virtio: remove unused variable Mark McLoughlin
2008-10-30 17:51 ` [PATCH 2/6] kvm: qemu: dup the qemu_eventfd() return Mark McLoughlin
2008-10-30 17:51 ` [PATCH 3/6] kvm: qemu: add qemu_eventfd_write() and qemu_eventfd_read() Mark McLoughlin
2008-10-30 17:51 ` Mark McLoughlin [this message]
2008-10-30 17:51 ` [PATCH 5/6] kvm: qemu: virtio-net: handle all tx in I/O thread without timer Mark McLoughlin
2008-10-30 17:51 ` [PATCH 6/6] kvm: qemu: virtio-net: drop mutex during tx tapfd write Mark McLoughlin
2008-11-04 11:43 ` Avi Kivity
2008-10-30 19:24 ` [PATCH 5/6] kvm: qemu: virtio-net: handle all tx in I/O thread without timer Anthony Liguori
2008-10-31 9:16 ` Mark McLoughlin
2008-11-03 15:07 ` Mark McLoughlin
2008-11-02 9:56 ` Avi Kivity
2008-11-04 15:23 ` David S. Ahern
2008-11-06 17:02 ` Mark McLoughlin
2008-11-06 17:13 ` David S. Ahern
2008-11-06 17:43 ` Avi Kivity
2008-10-30 19:20 ` [PATCH 0/6] Kill off the virtio_net tx mitigation timer Anthony Liguori
2008-11-02 9:48 ` Avi Kivity
2008-11-03 12:23 ` Mark McLoughlin
2008-11-03 12:40 ` Avi Kivity
2008-11-03 15:04 ` Mark McLoughlin
2008-11-03 15:19 ` Avi Kivity
2008-11-06 16:46 ` Mark McLoughlin
2008-11-06 17:38 ` Avi Kivity
2008-11-06 17:45 ` Mark McLoughlin
2008-11-09 11:29 ` Avi Kivity
2008-11-02 9:57 ` Avi Kivity
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=1225389113-28332-5-git-send-email-markmc@redhat.com \
--to=markmc@redhat.com \
--cc=avi@qumranet.com \
--cc=kvm@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox