monitor: remove more unnecessary atomics
PATCH 1/1 monitor: remove more unnecessary atomics
Simplify monitor_cleanup by:
- using main_loop_wait() to poll both the block layer AioContext and the I/O handlers
- using a bottom half to clear qmp_dispatcher_co; this removes the atomics but also forces an exit out of main_loop_wait.
Signed-off-by Paolo Bonzini <[email protected]>
--- monitor/monitor.c | 7 ++++--- monitor/qmp.c | 7 ++++++- 2 files changed, 10 insertions(+), 4 deletions(-)
monitor/monitor.c +4 -3
@@ -666,9 +666,10 @@ void monitor_cleanup(void) }qmp_dispatcher_co_wake (); -AIO_WAIT_WHILE_UNLOCKED (NULL , - (aio_poll (iohandler_get_aio_context (), false), -qatomic_read (&qmp_dispatcher_co))); +/* Loop until sync_with_main_loop_bh runs. */ +while (qmp_dispatcher_co) { +main_loop_wait (false); + }/* * We need to explicitly stop the I/O thread (but not destroy it),
monitor/qmp.c +6 -1
@@ -271,6 +271,11 @@ static QMPRequest *monitor_qmp_dispatcher_pop_any(void) } } +static void sync_with_main_loop_bh (void *opaque) +{ + qmp_dispatcher_co =NULL ; +} + void coroutine_fn monitor_qmp_dispatcher_co(void *data) {QMPRequest *req_obj;
@@ -365,7 +370,7 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)aio_co_schedule (iohandler_get_aio_context (), qmp_dispatcher_co);qemu_coroutine_yield (); } -qatomic_set (&qmp_dispatcher_co,NULL ); +aio_bh_schedule_oneshot (qemu_get_aio_context (), sync_with_main_loop_bh,NULL ); }void qmp_dispatcher_co_wake (void )
Signature · 1 line
2.40.1