From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: "Denis V. Lunev" <den@openvz.org>,
qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Denis Plotnikov <dplotnikov@virtuozzo.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH 1/2] aio: allow to wait for coroutine pool from different coroutine
Date: Wed, 10 Jun 2020 18:10:33 +0300 [thread overview]
Message-ID: <e2208bb0-fc7d-b97f-a4ae-d8e4b265db4d@virtuozzo.com> (raw)
In-Reply-To: <20200610144129.27659-2-den@openvz.org>
10.06.2020 17:41, Denis V. Lunev wrote:
> The patch preserves the constraint that the only waiter is allowed.
>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Max Reitz <mreitz@redhat.com>
> CC: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> CC: Denis Plotnikov <dplotnikov@virtuozzo.com>
> ---
> block/aio_task.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/block/aio_task.c b/block/aio_task.c
> index 88989fa248..f338049147 100644
> --- a/block/aio_task.c
> +++ b/block/aio_task.c
> @@ -27,7 +27,7 @@
> #include "block/aio_task.h"
>
> struct AioTaskPool {
> - Coroutine *main_co;
> + Coroutine *wake_co;
> int status;
> int max_busy_tasks;
> int busy_tasks;
> @@ -54,15 +54,15 @@ static void coroutine_fn aio_task_co(void *opaque)
>
> if (pool->waiting) {
> pool->waiting = false;
> - aio_co_wake(pool->main_co);
> + aio_co_wake(pool->wake_co);
> }
> }
>
> void coroutine_fn aio_task_pool_wait_one(AioTaskPool *pool)
> {
> assert(pool->busy_tasks > 0);
> - assert(qemu_coroutine_self() == pool->main_co);
>
> + pool->wake_co = qemu_coroutine_self();
> pool->waiting = true;
> qemu_coroutine_yield();
>
> @@ -98,7 +98,7 @@ AioTaskPool *coroutine_fn aio_task_pool_new(int max_busy_tasks)
> {
> AioTaskPool *pool = g_new0(AioTaskPool, 1);
>
> - pool->main_co = qemu_coroutine_self();
> + pool->wake_co = NULL;
> pool->max_busy_tasks = max_busy_tasks;
>
> return pool;
>
With such approach, if several coroutines will wait simultaneously, the only one will be finally woken and other will hang.
I think, we should use CoQueue here: CoQueue instead of wake_co, qemu_co_queue_wait in wait_one, and qemu_co_queue_next instead of aio_co_wake.
--
Best regards,
Vladimir
next prev parent reply other threads:[~2020-06-10 15:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-10 14:41 [PATCH 0/2] qcow2: seriously improve savevm performance Denis V. Lunev
2020-06-10 14:41 ` [PATCH 1/2] aio: allow to wait for coroutine pool from different coroutine Denis V. Lunev
2020-06-10 15:10 ` Vladimir Sementsov-Ogievskiy [this message]
2020-06-10 16:52 ` Denis V. Lunev
2020-06-10 14:41 ` [PATCH 2/2] qcow2: improve savevm performance Denis V. Lunev
2020-06-10 18:19 ` [PATCH 0/2] qcow2: seriously " no-reply
2020-06-10 18:24 ` no-reply
2020-06-10 18:24 ` no-reply
-- strict thread matches above, loose matches on Subject: below --
2020-06-10 18:58 [PATCH 1/2] aio: allow to wait for coroutine pool from different coroutine Denis V. Lunev
2020-06-10 19:00 [PATCH v2 0/2] qcow2: seriously improve savevm performance Denis V. Lunev
2020-06-10 19:00 ` [PATCH 1/2] aio: allow to wait for coroutine pool from different coroutine Denis V. Lunev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e2208bb0-fc7d-b97f-a4ae-d8e4b265db4d@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=den@openvz.org \
--cc=dplotnikov@virtuozzo.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).