[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 30/62] thread-pool: avoid deadlock in nested aio_poll
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 30/62] thread-pool: avoid deadlock in nested aio_poll() calls |
Date: |
Fri, 8 Aug 2014 19:39:31 +0200 |
From: Stefan Hajnoczi <address@hidden>
The thread pool has a race condition if two elements complete before
thread_pool_completion_bh() runs:
If element A's callback waits for element B using aio_poll() it will
deadlock since pool->completion_bh is not marked scheduled when the
nested aio_poll() runs.
Fix this by marking the BH scheduled while thread_pool_completion_bh()
is executing. This way any nested aio_poll() loops will enter
thread_pool_completion_bh() and complete the remaining elements.
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
thread-pool.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/thread-pool.c b/thread-pool.c
index 4cfd078..23888dc 100644
--- a/thread-pool.c
+++ b/thread-pool.c
@@ -185,6 +185,12 @@ restart:
QLIST_REMOVE(elem, all);
/* Read state before ret. */
smp_rmb();
+
+ /* Schedule ourselves in case elem->common.cb() calls aio_poll() to
+ * wait for another request that completed at the same time.
+ */
+ qemu_bh_schedule(pool->completion_bh);
+
elem->common.cb(elem->common.opaque, elem->ret);
qemu_aio_release(elem);
goto restart;
--
1.8.3.1
- [Qemu-devel] [PULL 21/62] qemu-img info: show nocow info, (continued)
- [Qemu-devel] [PULL 21/62] qemu-img info: show nocow info, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 20/62] vmdk: Optimize cluster allocation, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 24/62] block/archipelago: Add support for creating images, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 23/62] block/archipelago: Implement bdrv_parse_filename(), Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 25/62] QMP: Add support for Archipelago, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 22/62] block: Support Archipelago as a QEMU block backend, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 26/62] qemu-iotests: add support for Archipelago protocol, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 27/62] coroutine: make pool size dynamic, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 28/62] block: bump coroutine pool size for drives, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 29/62] thread-pool: avoid per-thread-pool EventNotifier, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 30/62] thread-pool: avoid deadlock in nested aio_poll() calls,
Kevin Wolf <=
- [Qemu-devel] [PULL 31/62] block: vhdx - add error check, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 32/62] block: VHDX endian fixes, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 33/62] test-coroutine: add baseline test that times the cost of function calls, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 34/62] block: allow bdrv_unref() to be passed NULL pointers, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 36/62] block: use the standard 'ret' instead of 'result', Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 39/62] block: Introduce qemu_try_blockalign(), Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 37/62] block: vpc - use block layer ops in vpc_create, instead of posix calls, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 35/62] block: vdi - use block layer ops in vdi_create, instead of posix calls, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 41/62] bochs: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 38/62] block: iotest - update 084 to test static VDI image creation, Kevin Wolf, 2014/08/08