mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-28 02:00:34 -07:00
Add co_wrapper_bdrv_rdlock and co_wrapper_mixed_bdrv_rdlock option to
the block-coroutine-wrapper.py script.
This "_bdrv_rdlock" option takes and releases the graph rdlock when a
coroutine function is created.
This means that when used together with "_mixed", the function marked
with co_wrapper_mixed_bdrv_rdlock will support both coroutine and
non-coroutine case, and in the latter case it will create a coroutine
that takes and releases the rdlock. When called from a coroutine, the
caller must already hold the graph lock.
Example:
void co_wrapper_mixed_bdrv_rdlock bdrv_f1();
Becomes
static void bdrv_co_enter_f1()
{
bdrv_graph_co_rdlock();
bdrv_co_function();
bdrv_graph_co_rdunlock();
}
void bdrv_f1()
{
if (qemu_in_coroutine) {
assume_graph_lock();
bdrv_co_function();
} else {
qemu_co_enter(bdrv_co_enter_f1);
...
}
}
When used alone, the function will not work in coroutine context, and
when called in non-coroutine context it will create a new coroutine that
takes care of taking and releasing the rdlock automatically.
Example:
void co_wrapper_bdrv_rdlock bdrv_f1();
Becomes
static void bdrv_co_enter_f1()
{
bdrv_graph_co_rdlock();
bdrv_co_function();
bdrv_graph_co_rdunlock();
}
void bdrv_f1()
{
assert(!qemu_in_coroutine());
qemu_co_enter(bdrv_co_enter_f1);
...
}
About their usage:
- co_wrapper does not take the rdlock, so it can be used also outside
the block layer.
- co_wrapper_mixed will be used by many blk_* functions, since the
coroutine function needs to call blk_wait_while_drained() and
the rdlock *must* be taken afterwards, otherwise it's a deadlock.
In the future this annotation will go away, and blk_* will use
co_wrapper directly.
- co_wrapper_bdrv_rdlock will be used by BlockDriver callbacks, ideally
by all of them in the future.
- co_wrapper_mixed_bdrv_rdlock will be used by the remaining functions
that are still called by coroutine and non-coroutine context. In the
future this annotation will go away, as we will split such mixed
functions.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20221207131838.239125-17-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||
|---|---|---|
| .. | ||
| ci | ||
| coccinelle | ||
| codeconverter | ||
| coverity-scan | ||
| kvm | ||
| modules | ||
| oss-fuzz | ||
| performance | ||
| qapi | ||
| qemu-guest-agent | ||
| qemugdb | ||
| qmp | ||
| simplebench | ||
| tracetool | ||
| analyse-9p-simpletrace.py | ||
| analyse-locks-simpletrace.py | ||
| analyze-inclusions | ||
| analyze-migration.py | ||
| archive-source.sh | ||
| block-coroutine-wrapper.py | ||
| check_sparse.py | ||
| checkpatch.pl | ||
| clean-header-guards.pl | ||
| clean-includes | ||
| cleanup-trace-events.pl | ||
| cocci-macro-file.h | ||
| cpu-x86-uarch-abi.py | ||
| decodetree.py | ||
| device-crash-test | ||
| disas-objdump.pl | ||
| dump-guest-memory.py | ||
| entitlement.sh | ||
| extract-vsssdk-headers | ||
| feature_to_c.sh | ||
| fix-multiline-comments.sh | ||
| gensyscalls.sh | ||
| get_maintainer.pl | ||
| git-submodule.sh | ||
| git.orderfile | ||
| hxtool | ||
| kernel-doc | ||
| main.c | ||
| make-config-poison.sh | ||
| make-release | ||
| meson-buildoptions.py | ||
| meson-buildoptions.sh | ||
| meson.build | ||
| minikconf.py | ||
| modinfo-collect.py | ||
| modinfo-generate.py | ||
| mtest2make.py | ||
| nsis.py | ||
| qapi-gen.py | ||
| qemu-binfmt-conf.sh | ||
| qemu-gdb.py | ||
| qemu-stamp.py | ||
| qemu-trace-stap | ||
| qemu-version.sh | ||
| refresh-pxe-roms.sh | ||
| render_block_graph.py | ||
| replay-dump.py | ||
| shaderinclude.pl | ||
| signrom.py | ||
| simpletrace.py | ||
| symlink-install-tree.py | ||
| test-driver.py | ||
| tracetool.py | ||
| u2f-setup-gen.py | ||
| undefsym.py | ||
| update-linux-headers.sh | ||
| update-mips-syscall-args.sh | ||
| update-syscalltbl.sh | ||
| userfaultfd-wrlat.py | ||
| vmstate-static-checker.py | ||
| xen-detect.c | ||