[PATCH v2 0/1] coroutine: avoid inserting duplicate coroutine to co_queue_wakeup

Zhu Yangyang via posted 1 patch 4 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240401123342.3947762-1-zhuyangyang14@huawei.com
Maintainers: Eric Blake <eblake@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
nbd/client.c       |  7 ++++---
nbd/common.c       | 19 ++++++++++++++++---
nbd/nbd-internal.h |  6 +++---
nbd/server.c       | 10 +++++-----
4 files changed, 28 insertions(+), 14 deletions(-)
[PATCH v2 0/1] coroutine: avoid inserting duplicate coroutine to co_queue_wakeup
Posted by Zhu Yangyang via 4 weeks, 1 day ago
The problem that inserting duplicate coroutine to co_queue_wakeu has been
resolved by 7c1f51bf38 ("nbd/server: Fix drained_poll to wake coroutine
in right AioContext") that avoids repeatedly waking up the same coroutine.

The key modifications are as follows:

static void qio_channel_restart_read(void *opaque)
{
    QIOChannel *ioc = opaque;
-   Coroutine *co = ioc->read_coroutine;
+   Coroutine *co = qatomic_xchg(&ioc->read_coroutine, NULL);
+
+   if (!co) {
+       return;
+   }

    /* Assert that aio_co_wake() reenters the coroutine directly */
    assert(qemu_get_current_aio_context() ==
           qemu_coroutine_get_aio_context(co));
    aio_co_wake(co);
}

The root cause is that poll() is invoked in coroutine context, so fix it.

Changes in v2:
Drop the changes to aio_co_enter and instead fix the poll() call in the nbd/server.

Zhu Yangyang (1):
  nbd/server: do not poll within a coroutine context

 nbd/client.c       |  7 ++++---
 nbd/common.c       | 19 ++++++++++++++++---
 nbd/nbd-internal.h |  6 +++---
 nbd/server.c       | 10 +++++-----
 4 files changed, 28 insertions(+), 14 deletions(-)

-- 
2.33.0