[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 1/4] main-loop.h: introduce qemu_in_main_thread()
From: |
Stefan Hajnoczi |
Subject: |
Re: [RFC PATCH 1/4] main-loop.h: introduce qemu_in_main_thread() |
Date: |
Mon, 13 Sep 2021 14:15:40 +0100 |
On Wed, Sep 08, 2021 at 09:10:18AM -0400, Emanuele Giuseppe Esposito wrote:
> When invoked from the main loop, this function is the same
> as qemu_mutex_iothread_locked, and returns true if the BQL is held.
> When invoked from iothreads or tests, it returns true only
> if the current AioContext is the Main Loop.
>
> This essentially just extends qemu_mutex_iothread_locked to work
> also in unit tests or other users like storage-daemon, that run
> in the Main Loop but end up using the implementation in
> stubs/iothread-lock.c.
>
> Using qemu_mutex_iothread_locked in unit tests defaults to false
> because they use the implementation in stubs/iothread-lock,
> making all assertions added in next patches fail despite the
> AioContext is still the main loop.
>
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
> include/qemu/main-loop.h | 13 +++++++++++++
> softmmu/cpus.c | 5 +++++
> stubs/iothread-lock.c | 5 +++++
> 3 files changed, 23 insertions(+)
>
> diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h
> index 8dbc6fcb89..c6547207f7 100644
> --- a/include/qemu/main-loop.h
> +++ b/include/qemu/main-loop.h
> @@ -245,6 +245,19 @@ AioContext *iohandler_get_aio_context(void);
> */
> bool qemu_mutex_iothread_locked(void);
>
> +/**
> + * qemu_in_main_thread: Return true if the function runs with BQL
> + * or in the main loop AioContext.
> + *
> + * This function falls back to qemu_mutex_iothread_locked() if
> + * called from the main loop, otherwise it checks if the current
> + * AioContext is the main loop. This is useful to check that the BQL
> + * is held, and not make it return false when invoked by unit
> + * tests or other users like storage-daemon that end up using
> + * stubs/iothread-lock.c implementation.
> + */
> +bool qemu_in_main_thread(void);
This description doesn't match the behavior because the "or in the main
loop AioContext" part only applies to non softmmu builds (e.g. tests).
Please phrase it so it's clear that this function is the same as
qemu_mutex_iothread_locked() when softmmu/cpus.c is linked into the
program. Otherwise it checks that the current AioContext is the global
AioContext.
signature.asc
Description: PGP signature
- [RFC PATCH 0/4] block layer: split block APIs in graph and I/O, Emanuele Giuseppe Esposito, 2021/09/08
- [RFC PATCH 2/4] migration: block-dirty-bitmap: add missing qemu_mutex_lock_iothread, Emanuele Giuseppe Esposito, 2021/09/08
- [RFC PATCH 1/4] main-loop.h: introduce qemu_in_main_thread(), Emanuele Giuseppe Esposito, 2021/09/08
- Re: [RFC PATCH 1/4] main-loop.h: introduce qemu_in_main_thread(),
Stefan Hajnoczi <=
- [RFC PATCH 4/4] block/block-backend.c: assertions for block-backend, Emanuele Giuseppe Esposito, 2021/09/08
- [RFC PATCH 3/4] include/sysemu/block-backend: split header into I/O and graph API, Emanuele Giuseppe Esposito, 2021/09/08
- Re: [RFC PATCH 3/4] include/sysemu/block-backend: split header into I/O and graph API, Stefan Hajnoczi, 2021/09/13
- Re: [RFC PATCH 0/4] block layer: split block APIs in graph and I/O, Stefan Hajnoczi, 2021/09/13