qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/5] monitor: use aio_co_reschedule_self()


From: Hanna Czenczek
Subject: Re: [PATCH 5/5] monitor: use aio_co_reschedule_self()
Date: Tue, 6 Feb 2024 16:11:55 +0100
User-agent: Mozilla Thunderbird

On 05.02.24 18:26, Stefan Hajnoczi wrote:
The aio_co_reschedule_self() API is designed to avoid the race
condition between scheduling the coroutine in another AioContext and
yielding.

The QMP dispatch code uses the open-coded version that appears
susceptible to the race condition at first glance:

   aio_co_schedule(qemu_get_aio_context(), qemu_coroutine_self());
   qemu_coroutine_yield();

The code is actually safe because the iohandler and qemu_aio_context
AioContext run under the Big QEMU Lock. Nevertheless, set a good example
and use aio_co_reschedule_self() so it's obvious that there is no race.

Suggested-by: Hanna Reitz <hreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
  qapi/qmp-dispatch.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)

Reviewed-by: Hanna Czenczek <hreitz@redhat.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]