mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
5f50be9b58
If we want to wake up a coroutine from a worker thread, aio_co_wake() currently does not work. In that scenario, aio_co_wake() calls aio_co_enter(), but there is no current AioContext and therefore qemu_get_current_aio_context() returns the main thread. aio_co_wake() then attempts to call aio_context_acquire() instead of going through aio_co_schedule(). The default case of qemu_get_current_aio_context() was added to cover synchronous I/O started from the vCPU thread, but the main and vCPU threads are quite different. The main thread is an I/O thread itself, only running a more complicated event loop; the vCPU thread instead is essentially a worker thread that occasionally calls qemu_mutex_lock_iothread(). It is only in those critical sections that it acts as if it were the home thread of the main AioContext. Therefore, this patch detaches qemu_get_current_aio_context() from iothreads, which is a useless complication. The AioContext pointer is stored directly in the thread-local variable, including for the main loop. Worker threads (including vCPU threads) optionally behave as temporary home threads if they have taken the big QEMU lock, but if that is not the case they will always schedule coroutines on remote threads via aio_co_schedule(). With this change, the stub qemu_mutex_iothread_locked() must be changed from true to false. The previous value of true was needed because the main thread did not have an AioContext in the thread-local variable, but now it does have one. Reported-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20210609122234.544153-1-pbonzini@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> [eblake: tweak commit message per Vladimir's review] Signed-off-by: Eric Blake <eblake@redhat.com>
57 lines
2 KiB
Meson
57 lines
2 KiB
Meson
stub_ss.add(files('arch_type.c'))
|
|
stub_ss.add(files('bdrv-next-monitor-owned.c'))
|
|
stub_ss.add(files('blk-commit-all.c'))
|
|
stub_ss.add(files('blk-exp-close-all.c'))
|
|
stub_ss.add(files('blockdev-close-all-bdrv-states.c'))
|
|
stub_ss.add(files('change-state-handler.c'))
|
|
stub_ss.add(files('cmos.c'))
|
|
stub_ss.add(files('cpu-get-clock.c'))
|
|
stub_ss.add(files('cpus-get-virtual-clock.c'))
|
|
stub_ss.add(files('qemu-timer-notify-cb.c'))
|
|
stub_ss.add(files('icount.c'))
|
|
stub_ss.add(files('dump.c'))
|
|
stub_ss.add(files('error-printf.c'))
|
|
stub_ss.add(files('fdset.c'))
|
|
stub_ss.add(files('fw_cfg.c'))
|
|
stub_ss.add(files('gdbstub.c'))
|
|
stub_ss.add(files('get-vm-name.c'))
|
|
stub_ss.add(when: 'CONFIG_LINUX_IO_URING', if_true: files('io_uring.c'))
|
|
stub_ss.add(files('iothread-lock.c'))
|
|
stub_ss.add(files('isa-bus.c'))
|
|
stub_ss.add(files('is-daemonized.c'))
|
|
stub_ss.add(when: 'CONFIG_LINUX_AIO', if_true: files('linux-aio.c'))
|
|
stub_ss.add(files('migr-blocker.c'))
|
|
stub_ss.add(files('module-opts.c'))
|
|
stub_ss.add(files('monitor.c'))
|
|
stub_ss.add(files('monitor-core.c'))
|
|
stub_ss.add(files('pci-bus.c'))
|
|
stub_ss.add(files('pci-host-piix.c'))
|
|
stub_ss.add(files('qemu-timer-notify-cb.c'))
|
|
stub_ss.add(files('qmp_memory_device.c'))
|
|
stub_ss.add(files('qmp-command-available.c'))
|
|
stub_ss.add(files('qtest.c'))
|
|
stub_ss.add(files('ram-block.c'))
|
|
stub_ss.add(files('ramfb.c'))
|
|
stub_ss.add(files('replay.c'))
|
|
stub_ss.add(files('runstate-check.c'))
|
|
stub_ss.add(files('sysbus.c'))
|
|
stub_ss.add(files('target-get-monitor-def.c'))
|
|
stub_ss.add(files('target-monitor-defs.c'))
|
|
stub_ss.add(files('trace-control.c'))
|
|
stub_ss.add(files('uuid.c'))
|
|
stub_ss.add(files('vmgenid.c'))
|
|
stub_ss.add(files('vmstate.c'))
|
|
stub_ss.add(files('vm-stop.c'))
|
|
stub_ss.add(files('win32-kbd-hook.c'))
|
|
stub_ss.add(files('cpu-synchronize-state.c'))
|
|
if have_block
|
|
stub_ss.add(files('replay-tools.c'))
|
|
endif
|
|
if have_system
|
|
stub_ss.add(files('semihost.c'))
|
|
stub_ss.add(files('usb-dev-stub.c'))
|
|
stub_ss.add(files('xen-hw-stub.c'))
|
|
stub_ss.add(files('virtio-gpu-udmabuf.c'))
|
|
else
|
|
stub_ss.add(files('qdev.c'))
|
|
endif
|