diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2017-01-17 11:20:27 +0000 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2017-01-17 11:20:27 +0000 |
| commit | 02b351d8466a26c93bf35ff8fd5c316e6aee8c0f (patch) | |
| tree | 00cdc531a449ba44ca0e0920ca967b93dee76f90 /util/qemu-thread-posix.c | |
| parent | a8c611e1133f97c979922f41103f79309339dc27 (diff) | |
| parent | 7d506c90afa47facdb993bc19c15863eef584f1d (diff) | |
| download | focaccia-qemu-02b351d8466a26c93bf35ff8fd5c316e6aee8c0f.tar.gz focaccia-qemu-02b351d8466a26c93bf35ff8fd5c316e6aee8c0f.zip | |
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
# gpg: Signature made Mon 16 Jan 2017 13:38:52 GMT # gpg: using RSA key 0x9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha/tags/block-pull-request: async: optimize aio_bh_poll aio: document locking aio-win32: remove walking_handlers, protecting AioHandler list with list_lock aio-posix: remove walking_handlers, protecting AioHandler list with list_lock aio: tweak walking in dispatch phase aio-posix: split aio_dispatch_handlers out of aio_dispatch qemu-thread: optimize QemuLockCnt with futexes on Linux aio: make ctx->list_lock a QemuLockCnt, subsuming ctx->walking_bh qemu-thread: introduce QemuLockCnt aio: rename bh_lock to list_lock block: get rid of bdrv_io_unplugged_begin/end Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util/qemu-thread-posix.c')
| -rw-r--r-- | util/qemu-thread-posix.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index d20cddec0c..37cd8ba3fe 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -11,10 +11,6 @@ * */ #include "qemu/osdep.h" -#ifdef __linux__ -#include <sys/syscall.h> -#include <linux/futex.h> -#endif #include "qemu/thread.h" #include "qemu/atomic.h" #include "qemu/notify.h" @@ -294,28 +290,9 @@ void qemu_sem_wait(QemuSemaphore *sem) } #ifdef __linux__ -#define futex(...) syscall(__NR_futex, __VA_ARGS__) - -static inline void futex_wake(QemuEvent *ev, int n) -{ - futex(ev, FUTEX_WAKE, n, NULL, NULL, 0); -} - -static inline void futex_wait(QemuEvent *ev, unsigned val) -{ - while (futex(ev, FUTEX_WAIT, (int) val, NULL, NULL, 0)) { - switch (errno) { - case EWOULDBLOCK: - return; - case EINTR: - break; /* get out of switch and retry */ - default: - abort(); - } - } -} +#include "qemu/futex.h" #else -static inline void futex_wake(QemuEvent *ev, int n) +static inline void qemu_futex_wake(QemuEvent *ev, int n) { pthread_mutex_lock(&ev->lock); if (n == 1) { @@ -326,7 +303,7 @@ static inline void futex_wake(QemuEvent *ev, int n) pthread_mutex_unlock(&ev->lock); } -static inline void futex_wait(QemuEvent *ev, unsigned val) +static inline void qemu_futex_wait(QemuEvent *ev, unsigned val) { pthread_mutex_lock(&ev->lock); if (ev->value == val) { @@ -338,7 +315,7 @@ static inline void futex_wait(QemuEvent *ev, unsigned val) /* Valid transitions: * - free->set, when setting the event - * - busy->set, when setting the event, followed by futex_wake + * - busy->set, when setting the event, followed by qemu_futex_wake * - set->free, when resetting the event * - free->busy, when waiting * @@ -381,7 +358,7 @@ void qemu_event_set(QemuEvent *ev) if (atomic_read(&ev->value) != EV_SET) { if (atomic_xchg(&ev->value, EV_SET) == EV_BUSY) { /* There were waiters, wake them up. */ - futex_wake(ev, INT_MAX); + qemu_futex_wake(ev, INT_MAX); } } } @@ -419,7 +396,7 @@ void qemu_event_wait(QemuEvent *ev) return; } } - futex_wait(ev, EV_BUSY); + qemu_futex_wait(ev, EV_BUSY); } } |