[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/5] Use qemu_eventfd for POSIX AIO
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH 3/5] Use qemu_eventfd for POSIX AIO |
Date: |
Wed, 4 Apr 2012 17:08:13 +0200 |
Use qemu_eventfd for signaling POSIX AIO completions. If native eventfd
suport is available, this avoids multiple read accesses to drain
multiple pending signals. As before we use a pipe if eventfd is not
supported.
Signed-off-by: Jan Kiszka <address@hidden>
---
posix-aio-compat.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index c9b8ebf..7c3ff6e 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -481,7 +481,7 @@ static void posix_aio_read(void *opaque)
PosixAioState *s = opaque;
ssize_t len;
- /* read all bytes from signal pipe */
+ /* read all bytes from eventfd or signal pipe */
for (;;) {
char bytes[16];
@@ -506,10 +506,14 @@ static PosixAioState *posix_aio_state;
static void posix_aio_notify_event(void)
{
- char byte = 0;
+ /* Write 8 bytes to be compatible with eventfd. */
+ static const uint64_t val = 1;
ssize_t ret;
- ret = write(posix_aio_state->wfd, &byte, sizeof(byte));
+ do {
+ ret = write(posix_aio_state->wfd, &val, sizeof(val));
+ } while (ret < 0 && errno == EINTR);
+
if (ret < 0 && errno != EAGAIN)
die("write()");
}
@@ -623,7 +627,7 @@ int paio_init(void)
s = g_malloc(sizeof(PosixAioState));
s->first_aio = NULL;
- if (qemu_pipe(fds) == -1) {
+ if (qemu_eventfd(fds) == -1) {
fprintf(stderr, "failed to create pipe\n");
g_free(s);
return -1;
--
1.7.3.4
- [Qemu-devel] [PATCH 0/5] Spread the use of QEMU threading & locking API, Jan Kiszka, 2012/04/04
- [Qemu-devel] [PATCH 3/5] Use qemu_eventfd for POSIX AIO,
Jan Kiszka <=
- [Qemu-devel] [PATCH 1/5] Introduce qemu_cond_timedwait for POSIX, Jan Kiszka, 2012/04/04
- [Qemu-devel] [PATCH 5/5] Switch compatfd to QEMU thread, Jan Kiszka, 2012/04/04
- [Qemu-devel] [PATCH 2/5] Switch POSIX compat AIO to QEMU abstractions, Jan Kiszka, 2012/04/04
- [Qemu-devel] [PATCH 4/5] Reorder POSIX compat AIO code, Jan Kiszka, 2012/04/04
- Re: [Qemu-devel] [PATCH 0/5] Spread the use of QEMU threading & locking API, Paolo Bonzini, 2012/04/04