[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 3/6] block: convert bdrv_graph_wrlock() to AIO_WAIT_WHILE_
From: |
Wilfred Mallawa |
Subject: |
Re: [PATCH v2 3/6] block: convert bdrv_graph_wrlock() to AIO_WAIT_WHILE_UNLOCKED() |
Date: |
Sun, 12 Mar 2023 23:57:53 +0000 |
On Thu, 2023-03-09 at 14:08 -0500, Stefan Hajnoczi wrote:
> The following conversion is safe and does not change behavior:
>
> GLOBAL_STATE_CODE();
> ...
> - AIO_WAIT_WHILE(qemu_get_aio_context(), ...);
> + AIO_WAIT_WHILE_UNLOCKED(NULL, ...);
>
> Since we're in GLOBAL_STATE_CODE(), qemu_get_aio_context() is our
> home
> thread's AioContext. Thus AIO_WAIT_WHILE() does not unlock the
> AioContext:
>
> if (ctx_ && in_aio_context_home_thread(ctx_)) { \
> while ((cond)) { \
> aio_poll(ctx_, true); \
> waited_ = true; \
> } \
>
> And that means AIO_WAIT_WHILE_UNLOCKED(NULL, ...) can be substituted.
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> block/graph-lock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
>
> diff --git a/block/graph-lock.c b/block/graph-lock.c
> index 454c31e691..639526608f 100644
> --- a/block/graph-lock.c
> +++ b/block/graph-lock.c
> @@ -127,7 +127,7 @@ void bdrv_graph_wrlock(void)
> * reader lock.
> */
> qatomic_set(&has_writer, 0);
> - AIO_WAIT_WHILE(qemu_get_aio_context(), reader_count() >= 1);
> + AIO_WAIT_WHILE_UNLOCKED(NULL, reader_count() >= 1);
> qatomic_set(&has_writer, 1);
>
> /*
- [PATCH v2 0/6] block: switch to AIO_WAIT_WHILE_UNLOCKED() where possible, Stefan Hajnoczi, 2023/03/09
- [PATCH v2 2/6] block: convert blk_exp_close_all_type() to AIO_WAIT_WHILE_UNLOCKED(), Stefan Hajnoczi, 2023/03/09
- [PATCH v2 1/6] block: don't acquire AioContext lock in bdrv_drain_all(), Stefan Hajnoczi, 2023/03/09
- [PATCH v2 3/6] block: convert bdrv_graph_wrlock() to AIO_WAIT_WHILE_UNLOCKED(), Stefan Hajnoczi, 2023/03/09
- Re: [PATCH v2 3/6] block: convert bdrv_graph_wrlock() to AIO_WAIT_WHILE_UNLOCKED(),
Wilfred Mallawa <=
- [PATCH v2 4/6] block: convert bdrv_drain_all_begin() to AIO_WAIT_WHILE_UNLOCKED(), Stefan Hajnoczi, 2023/03/09
- [PATCH v2 5/6] hmp: convert handle_hmp_command() to AIO_WAIT_WHILE_UNLOCKED(), Stefan Hajnoczi, 2023/03/09
- [PATCH v2 6/6] monitor: convert monitor_cleanup() to AIO_WAIT_WHILE_UNLOCKED(), Stefan Hajnoczi, 2023/03/09
- Re: [PATCH v2 0/6] block: switch to AIO_WAIT_WHILE_UNLOCKED() where possible, Kevin Wolf, 2023/03/14