qemu-patch-raspberry4/include
Paolo Bonzini 5f50be9b58 async: the main AioContext is only "current" if under the BQL
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>
2021-06-18 10:59:52 -05:00
..
authz Prefer 'on' | 'off' over 'yes' | 'no' for bool options 2021-01-29 17:07:53 +00:00
block async: the main AioContext is only "current" if under the BQL 2021-06-18 10:59:52 -05:00
chardev chardev: Fix yank with the chardev-change case 2021-04-01 15:27:44 +04:00
crypto crypto: add reload for QCryptoTLSCredsClass 2021-03-23 08:48:21 +01:00
disas Drop the deprecated lm32 target 2021-05-12 18:20:25 +02:00
exec memory: Introduce RAM_NORESERVE and wire it up in qemu_ram_mmap() 2021-06-15 20:27:38 +02:00
fpu softfloat: Convert modrem operations to FloatParts 2021-06-03 14:09:02 -07:00
hw * avoid deprecation warnings for SASL on macOS 10.11 or newer 2021-06-17 15:43:26 +01:00
io io: add qio_channel_readv_full_all_eof & qio_channel_readv_full_all helpers 2021-02-10 09:23:28 +00:00
libdecnumber include: Make headers more self-contained 2019-08-16 13:31:51 +02:00
migration cpu: Move CPUClass::vmsd to SysemuCPUOps 2021-05-26 15:33:59 -07:00
monitor hmp: Add "calc_dirty_rate" and "info dirty_rate" cmds 2021-06-08 20:18:26 +01:00
net vhost-vdpa: remove the unused vhost_vdpa_get_acked_features() 2021-06-11 10:30:13 +08:00
qapi vl: plumb keyval-based options into -readconfig 2021-06-04 13:50:04 +02:00
qemu * avoid deprecation warnings for SASL on macOS 10.11 or newer 2021-06-17 15:43:26 +01:00
qom qom: move user_creatable_add_opts logic to vl.c and QAPIfy it 2021-03-19 10:18:17 +01:00
scsi scsi: inline sg_io_sense_from_errno() into the callers. 2021-03-06 11:42:56 +01:00
semihosting semihosting: Move include/hw/semihosting/ -> include/semihosting/ 2021-03-10 15:34:12 +00:00
standard-headers headers: Add udmabuf.h 2021-05-27 12:06:37 +02:00
sysemu * avoid deprecation warnings for SASL on macOS 10.11 or newer 2021-06-17 15:43:26 +01:00
tcg tcg: Fix documentation for tcg_constant_* vs tcg_temp_free_* 2021-06-13 17:42:40 -07:00
ui ui/pixman: Add qemu_pixman_to_drm_format() 2021-05-27 12:07:37 +02:00
user trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
elf.h Drop the deprecated unicore32 target 2021-05-12 18:20:52 +02:00
glib-compat.h configure: bump min required glib version to 2.56 2021-06-02 09:11:32 +02:00
qemu-common.h qemu-common.h: Update copyright string to 2021 2021-03-09 22:19:24 +01:00
qemu-io.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
trace-tcg.h trace: get rid of generated-events.h/generated-events.c 2016-10-12 09:54:52 +02:00