qemu-e2k/util
Stefan Hajnoczi e62da98527 aio-posix: fix race between epoll upgrade and aio_set_fd_handler()
If another thread calls aio_set_fd_handler() while the IOThread event
loop is upgrading from ppoll(2) to epoll(7) then we might miss new
AioHandlers. The epollfd will not monitor the new AioHandler's fd,
resulting in hangs.

Take the AioHandler list lock while upgrading to epoll. This prevents
AioHandlers from changing while epoll is being set up. If we cannot lock
because we're in a nested event loop, then don't upgrade to epoll (it
will happen next time we're not in a nested call).

The downside to taking the lock is that the aio_set_fd_handler() thread
has to wait until the epoll upgrade is finished, which involves many
epoll_ctl(2) system calls. However, this scenario is rare and I couldn't
think of another solution that is still simple.

Reported-by: Qing Wang <qinwang@redhat.com>
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2090998
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Fam Zheng <fam@euphon.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20230323144859.1338495-1-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2023-03-27 15:12:17 +02:00
..
aio-posix.c aio: make aio_set_fd_poll() static to aio-posix.c 2023-03-13 15:23:37 +04:00
aio-posix.h
aio-wait.c
aio-win32.c win32: avoid mixing SOCKET and file descriptor space 2023-03-13 15:39:31 +04:00
aiocb.c
async-teardown.c Fix non-first inclusions of qemu/osdep.h 2023-02-08 07:28:05 +01:00
async.c async: clarify usage of barriers in the polling case 2023-03-07 12:39:53 +01:00
atomic64.c
base64.c
bitmap.c
bitops.c replace TABs with spaces 2023-03-20 12:43:50 +01:00
block-helpers.c
block-helpers.h
buffer.c nomaintainer: Fix Lesser GPL version number 2020-11-15 17:04:40 +01:00
bufferiszero.c include/qemu/cpuid: Introduce xgetbv_low 2023-03-05 13:44:07 -08:00
cacheflush.c util/cacheflush: fix cache on windows-arm64 2023-02-21 08:53:03 -10:00
compatfd.c
coroutine-sigaltstack.c
coroutine-ucontext.c
coroutine-win32.c
crc32c.c
crc-ccitt.c
cutils.c
dbus.c
drm.c
envlist.c replace TABs with spaces 2023-03-20 12:43:50 +01:00
error-report.c util/error: add G_GNUC_PRINTF for various functions 2023-01-11 10:44:34 +01:00
error.c error: add global &error_warn destination 2023-03-13 15:23:37 +04:00
event_notifier-posix.c
event_notifier-win32.c
fdmon-epoll.c aio-posix: fix race between epoll upgrade and aio_set_fd_handler() 2023-03-27 15:12:17 +02:00
fdmon-io_uring.c
fdmon-poll.c
fifo8.c utils/fifo8: change fatal errors from abort() to assert() 2021-02-07 20:38:20 +00:00
filemonitor-inotify.c
filemonitor-stub.c
getauxval.c
guest-random.c replay: Extract core API to 'exec/replay-core.h' 2023-02-27 22:29:01 +01:00
hbitmap.c hbitmap: fix hbitmap_status() return value for first dirty bit case 2023-02-17 14:34:24 +01:00
hexdump.c
host-utils.c
id.c
int128.c include/qemu/int128: Use Int128 structure for TCI 2023-02-04 06:19:42 -10:00
interval-tree.c
iov.c
iova-tree.c
keyval.c
lockcnt.c
log.c log: Remove unneeded new line 2023-03-08 00:37:48 +01:00
main-loop.c main-loop: remove qemu_fd_register(), win32/slirp/socket specific 2023-03-13 15:39:31 +04:00
memalign.c
memfd.c
meson.build accel: introduce accelerator blocker API 2023-01-11 09:59:39 +01:00
mmap-alloc.c
module.c
notify.c
nvdimm-utils.c
osdep.c
oslib-posix.c util: drop qemu_fork() 2023-03-13 15:23:37 +04:00
oslib-win32.c win32: add qemu_close_socket_osfhandle() 2023-03-21 11:16:03 +04:00
path.c
qdist.c
qemu-co-shared-resource.c
qemu-co-timeout.c
qemu-config.c error: Drop superfluous #include "qapi/qmp/qerror.h" 2023-02-23 13:56:14 +01:00
qemu-coroutine-io.c
qemu-coroutine-lock.c qemu-coroutine-lock: add smp_mb__after_rmw() 2023-03-07 12:39:53 +01:00
qemu-coroutine-sleep.c coroutine: Clean up superfluous inclusion of qemu/coroutine.h 2023-01-19 10:18:28 +01:00
qemu-coroutine.c coroutine: Clean up superfluous inclusion of qemu/coroutine.h 2023-01-19 10:18:28 +01:00
qemu-option.c
qemu-print.c
qemu-progress.c
qemu-sockets.c win32: replace closesocket() with close() wrapper 2023-03-13 15:39:31 +04:00
qemu-thread-common.h
qemu-thread-posix.c qemu-thread-posix: cleanup, fix, document QemuEvent 2023-03-07 12:38:40 +01:00
qemu-thread-win32.c qemu-thread-win32: cleanup, fix, document QemuEvent 2023-03-07 12:38:40 +01:00
qemu-timer-common.c
qemu-timer.c
qht.c util/qht: use striped locks under TSAN 2023-02-02 11:48:20 +00:00
qsp.c
range.c
rcu.c
readline.c readline: Extract readline_add_completion_of() from monitor 2023-02-04 07:56:54 +01:00
selfmap.c
stats64.c
sys_membarrier.c
systemd.c
thread-context.c
thread-pool.c
throttle.c
timed-average.c
trace-events util/userfaultfd: Support /dev/userfaultfd 2023-02-11 16:51:09 +01:00
trace.h
transactions.c
unicode.c
uri.c Updated the FSF address to <https://www.gnu.org/licenses/> 2023-02-27 09:15:39 +01:00
userfaultfd.c util/userfaultfd: Support /dev/userfaultfd 2023-02-11 16:51:09 +01:00
uuid.c
vfio-helpers.c
vhost-user-server.c block/export: only acquire AioContext once for vhost_user_server_stop() 2023-03-27 13:46:30 +02:00
yank.c