aio-posix: split poll check from ready handler
v3 cover aio-posix: split poll check from ready handler
v3:
- Fixed FUSE export aio_set_fd_handler() call that I missed and double-checked for any other missing call sites using Coccinelle [Rich]
v2:
- Cleaned up unused return values in nvme and virtio-blk [Stefano]
- Documented try_poll_mode() ready_list argument [Stefano]
- Unified virtio-blk/scsi dataplane and non-dataplane virtqueue handlers [Stefano]
The first patch improves AioContext's adaptive polling execution time measurement. This can result in better performance because the algorithm makes better decisions about when to poll versus when to fall back to file descriptor monitoring.
The remaining patches unify the virtio-blk and virtio-scsi dataplane and non-dataplane virtqueue handlers. This became possible because the dataplane handler function now has the same function signature as the non-dataplane handler function. Stefano Garzarella prompted me to make this refactoring.
Stefan Hajnoczi (6):
aio-posix: split poll check from ready handler
virtio: get rid of VirtIOHandleAIOOutput
virtio-blk: drop unused virtio_blk_handle_vq() return value
virtio-scsi: prepare virtio_scsi_handle_cmd for dataplane
virtio: use ->handle_output() instead of ->handle_aio_output()
virtio: unify dataplane and non-dataplane ->handle_output()
include/block/aio.h | 4 +- include/hw/virtio/virtio-blk.h | 2 +- include/hw/virtio/virtio.h | 5 +- util/aio-posix.h | 1 + block/curl.c | 11 ++-- block/export/fuse.c | 4 +- block/io_uring.c | 19 ++++--- block/iscsi.c | 4 +- block/linux-aio.c | 16 +++--- block/nfs.c | 6 +-- block/nvme.c | 51 ++++++++++++------- block/ssh.c | 4 +- block/win32-aio.c | 4 +- hw/block/dataplane/virtio-blk.c | 16 +----- hw/block/virtio-blk.c | 14 ++---- hw/scsi/virtio-scsi-dataplane.c | 60 +++------------------- hw/scsi/virtio-scsi.c | 2 +- hw/virtio/virtio.c | 73 +++++++++------------------ hw/xen/xen-bus.c | 6 +-- io/channel-command.c | 6 ++- io/channel-file.c | 3 +- io/channel-socket.c | 3 +- migration/rdma.c | 8 +-- tests/unit/test-aio.c | 4 +- util/aio-posix.c | 89 +++++++++++++++++++++++++-------- util/aio-win32.c | 4 +- util/async.c | 10 +++- util/main-loop.c | 4 +- util/qemu-coroutine-io.c | 5 +- util/vhost-user-server.c | 11 ++-- 30 files changed, 219 insertions(+), 230 deletions(-)
Signature · 1 line
2.33.1
PATCH v3 1/6 aio-posix: split poll check from ready handler
Adaptive polling measures the execution time of the polling check plus handlers called when a polled event becomes ready. Handlers can take a significant amount of time, making it look like polling was running for a long time when in fact the event handler was running for a long time.
For example, on Linux the io_submit(2) syscall invoked when a virtio-blk device's virtqueue becomes ready can take 10s of microseconds. This can exceed the default polling interval (32 microseconds) and cause adaptive polling to stop polling.
By excluding the handler's execution time from the polling check we make the adaptive polling calculation more accurate. As a result, the event loop now stays in polling mode where previously it would have fallen back to file descriptor monitoring.
The following data was collected with virtio-blk num-queues=2 event_idx=off using an IOThread. Before:
168k IOPS, IOThread syscalls:
9837.115 ( 0.020 ms): IO iothread1/620155 io_submit(ctx_id: 140512552468480, nr: 16, iocbpp: 0x7fcb9f937db0) = 16 9837.158 ( 0.002 ms): IO iothread1/620155 write(fd: 103, buf: 0x556a2ef71b88, count: 8) = 8 9837.161 ( 0.001 ms): IO iothread1/620155 write(fd: 104, buf: 0x556a2ef71b88, count: 8) = 8 9837.163 ( 0.001 ms): IO iothread1/620155 ppoll(ufds: 0x7fcb90002800, nfds: 4, tsp: 0x7fcb9f1342d0, sigsetsize: 8) = 3 9837.164 ( 0.001 ms): IO iothread1/620155 read(fd: 107, buf: 0x7fcb9f939cc0, count: 512) = 8 9837.174 ( 0.001 ms): IO iothread1/620155 read(fd: 105, buf: 0x7fcb9f939cc0, count: 512) = 8 9837.176 ( 0.001 ms): IO iothread1/620155 read(fd: 106, buf: 0x7fcb9f939cc0, count: 512) = 8 9837.209 ( 0.035 ms): IO iothread1/620155 io_submit(ctx_id: 140512552468480, nr: 32, iocbpp: 0x7fca7d0cebe0) = 32
174k IOPS (+3.6%), IOThread syscalls:
9809.566 ( 0.036 ms): IO iothread1/623061 io_submit(ctx_id: 140539805028352, nr: 32, iocbpp: 0x7fd0cdd62be0) = 32 9809.625 ( 0.001 ms): IO iothread1/623061 write(fd: 103, buf: 0x5647cfba5f58, count: 8) = 8 9809.627 ( 0.002 ms): IO iothread1/623061 write(fd: 104, buf: 0x5647cfba5f58, count: 8) = 8 9809.663 ( 0.036 ms): IO iothread1/623061 io_submit(ctx_id: 140539805028352, nr: 32, iocbpp: 0x7fd0d0388b50) = 32
Notice that ppoll(2) and eventfd read(2) syscalls are eliminated because the IOThread stays in polling mode instead of falling back to file descriptor monitoring.
As usual, polling is not implemented on Windows so this patch ignores the new io_poll_read() callback in aio-win32.c.
--- include/block/aio.h | 4 +- util/aio-posix.h | 1 + block/curl.c | 11 ++--- block/export/fuse.c | 4 +- block/io_uring.c | 19 +++++---- block/iscsi.c | 4 +- block/linux-aio.c | 16 +++++--- block/nfs.c | 6 +-- block/nvme.c | 51 +++++++++++++++-------- block/ssh.c | 4 +- block/win32-aio.c | 4 +- hw/virtio/virtio.c | 16 +++++--- hw/xen/xen-bus.c | 6 +-- io/channel-command.c | 6 ++- io/channel-file.c | 3 +- io/channel-socket.c | 3 +- migration/rdma.c | 8 ++-- tests/unit/test-aio.c | 4 +- util/aio-posix.c | 89 ++++++++++++++++++++++++++++++---------- util/aio-win32.c | 4 +- util/async.c | 10 ++++- util/main-loop.c | 4 +- util/qemu-coroutine-io.c | 5 ++- util/vhost-user-server.c | 11 ++--- 24 files changed, 191 insertions(+), 102 deletions(-)
include/block/aio.h +3 -1
@@ -469,6 +469,7 @@ void aio_set_fd_handler(AioContext *ctx, IOHandler *io_read, IOHandler *io_write, AioPollFn *io_poll, + IOHandler *io_poll_ready, void *opaque);/* Set polling begin/end callbacks for a file descriptor that has already been
@@ -490,7 +491,8 @@ void aio_set_event_notifier(AioContext *ctx,EventNotifier *notifier, bool is_external, EventNotifierHandler *io_read, - AioPollFn *io_poll); + AioPollFn *io_poll, + EventNotifierHandler *io_poll_ready);/* Set polling begin/end callbacks for an event notifier that has already been * registered with aio_set_event_notifier. Do nothing if the event notifier is
util/aio-posix.h +1 -0
@@ -24,6 +24,7 @@ struct AioHandler {IOHandler *io_read;IOHandler *io_write;AioPollFn *io_poll; +IOHandler *io_poll_ready;IOHandler *io_poll_begin;IOHandler *io_poll_end;void *opaque;
block/curl.c +6 -5
@@ -125,7 +125,7 @@ static gboolean curl_drop_socket(void *key, void *value, void *opaque)BDRVCURLState *s = socket->s;aio_set_fd_handler (s->aio_context, socket->fd, false, -NULL ,NULL ,NULL ,NULL ); +NULL ,NULL ,NULL ,NULL ,NULL );return true; }
@@ -173,19 +173,20 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,switch (action) {case CURL_POLL_IN :aio_set_fd_handler (s->aio_context, fd, false, - curl_multi_do,NULL ,NULL , socket); + curl_multi_do,NULL ,NULL ,NULL , socket);break ;case CURL_POLL_OUT :aio_set_fd_handler (s->aio_context, fd, false, -NULL , curl_multi_do,NULL , socket); +NULL , curl_multi_do,NULL ,NULL , socket);break ;case CURL_POLL_INOUT :aio_set_fd_handler (s->aio_context, fd, false, - curl_multi_do, curl_multi_do,NULL , socket); + curl_multi_do, curl_multi_do, +NULL ,NULL , socket);break ;case CURL_POLL_REMOVE :aio_set_fd_handler (s->aio_context, fd, false, -NULL ,NULL ,NULL ,NULL ); +NULL ,NULL ,NULL ,NULL ,NULL );break ; }
block/export/fuse.c +2 -2
@@ -223,7 +223,7 @@ static int setup_fuse_export(FuseExport *exp, const char *mountpoint,aio_set_fd_handler (exp->common.ctx,fuse_session_fd (exp->fuse_session), true, - read_from_fuse_export,NULL ,NULL , exp); + read_from_fuse_export,NULL ,NULL ,NULL , exp); exp->fd_handler_set_up = true;return 0 ;
@@ -267,7 +267,7 @@ static void fuse_export_shutdown(BlockExport *blk_exp)if (exp->fd_handler_set_up) {aio_set_fd_handler (exp->common.ctx,fuse_session_fd (exp->fuse_session), true, -NULL ,NULL ,NULL ,NULL ); +NULL ,NULL ,NULL ,NULL ,NULL ); exp->fd_handler_set_up = false; } }
block/io_uring.c +11 -8
@@ -292,12 +292,14 @@ static bool qemu_luring_poll_cb(void *opaque) {LuringState *s = opaque; -if (io_uring_cq_ready (&s->ring)) { -luring_process_completions_and_submit (s); -return true; - } +return io_uring_cq_ready (&s->ring); +} -return false; +static void qemu_luring_poll_ready (void *opaque) +{ +LuringState *s = opaque; + +luring_process_completions_and_submit (s); }static void ioq_init (LuringQueue *io_q)
@@ -402,8 +404,8 @@ int coroutine_fn luring_co_submit(BlockDriverState *bs, LuringState *s, int fd,void luring_detach_aio_context (LuringState *s,AioContext *old_context) { -aio_set_fd_handler (old_context, s->ring.ring_fd, false,NULL ,NULL ,NULL , - s); +aio_set_fd_handler (old_context, s->ring.ring_fd, false, +NULL ,NULL ,NULL ,NULL , s);qemu_bh_delete (s->completion_bh); s->aio_context =NULL ; }
@@ -413,7 +415,8 @@ void luring_attach_aio_context(LuringState *s, AioContext *new_context) s->aio_context = new_context; s->completion_bh =aio_bh_new (new_context, qemu_luring_completion_bh, s);aio_set_fd_handler (s->aio_context, s->ring.ring_fd, false, - qemu_luring_completion_cb,NULL , qemu_luring_poll_cb, s); + qemu_luring_completion_cb,NULL , + qemu_luring_poll_cb, qemu_luring_poll_ready, s); }LuringState *luring_init (Error **errp)
block/iscsi.c +2 -2
@@ -363,7 +363,7 @@ iscsi_set_events(IscsiLun *iscsilun) false, (ev &POLLIN ) ? iscsi_process_read :NULL , (ev &POLLOUT ) ? iscsi_process_write :NULL , -NULL , +NULL ,NULL , iscsilun); iscsilun->events = ev; }
@@ -1534,7 +1534,7 @@ static void iscsi_detach_aio_context(BlockDriverState *bs)IscsiLun *iscsilun = bs->opaque;aio_set_fd_handler (iscsilun->aio_context,iscsi_get_fd (iscsilun->iscsi), - false,NULL ,NULL ,NULL ,NULL ); + false,NULL ,NULL ,NULL ,NULL ,NULL ); iscsilun->events =0 ;if (iscsilun->nop_timer) {
block/linux-aio.c +10 -6
@@ -263,12 +263,15 @@ static bool qemu_laio_poll_cb(void *opaque)LinuxAioState *s =container_of (e, LinuxAioState, e);struct io_event *events; -if (!io_getevents_peek (s->ctx, &events)) { -return false; - } +return io_getevents_peek (s->ctx, &events); +} + +static void qemu_laio_poll_ready (EventNotifier *opaque) +{ +EventNotifier *e = opaque; +LinuxAioState *s =container_of (e, LinuxAioState, e);qemu_laio_process_completions_and_submit (s); -return true; }static void ioq_init (LaioQueue *io_q)
@@ -427,7 +430,7 @@ int coroutine_fn laio_co_submit(BlockDriverState *bs, LinuxAioState *s, int fd,void laio_detach_aio_context (LinuxAioState *s,AioContext *old_context) { -aio_set_event_notifier (old_context, &s->e, false,NULL ,NULL ); +aio_set_event_notifier (old_context, &s->e, false,NULL ,NULL ,NULL );qemu_bh_delete (s->completion_bh); s->aio_context =NULL ; }
@@ -438,7 +441,8 @@ void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context) s->completion_bh =aio_bh_new (new_context, qemu_laio_completion_bh, s);aio_set_event_notifier (new_context, &s->e, false, qemu_laio_completion_cb, - qemu_laio_poll_cb); + qemu_laio_poll_cb, + qemu_laio_poll_ready); }LinuxAioState *laio_init (Error **errp)
block/nfs.c +3 -3
@@ -197,7 +197,7 @@ static void nfs_set_events(NFSClient *client) false, (ev &POLLIN ) ? nfs_process_read :NULL , (ev &POLLOUT ) ? nfs_process_write :NULL , - NULL, client); + NULL, NULL, client); } client->events = ev;
@@ -372,7 +372,7 @@ static void nfs_detach_aio_context(BlockDriverState *bs)NFSClient *client = bs->opaque;aio_set_fd_handler (client->aio_context,nfs_get_fd (client->context), - false,NULL ,NULL ,NULL ,NULL ); + false,NULL ,NULL ,NULL ,NULL ,NULL ); client->events =0 ; }
@@ -390,7 +390,7 @@ static void nfs_client_close(NFSClient *client)if (client->context) {qemu_mutex_lock (&client->mutex);aio_set_fd_handler (client->aio_context,nfs_get_fd (client->context), - false,NULL ,NULL ,NULL ,NULL ); + false,NULL ,NULL ,NULL ,NULL ,NULL );qemu_mutex_unlock (&client->mutex);if (client->fh) {nfs_close (client->context, client->fh);
block/nvme.c +33 -18
109 lines not on this page · raw message
block/ssh.c +2 -2
@@ -990,7 +990,7 @@ static void restart_coroutine(void *opaque)AioContext *ctx =bdrv_get_aio_context (bs);trace_ssh_restart_coroutine (restart->co); -aio_set_fd_handler (ctx, s->sock, false,NULL ,NULL ,NULL ,NULL ); +aio_set_fd_handler (ctx, s->sock, false,NULL ,NULL ,NULL ,NULL ,NULL );aio_co_wake (restart->co); }
@@ -1020,7 +1020,7 @@ static coroutine_fn void co_yield(BDRVSSHState *s, BlockDriverState *bs)trace_ssh_co_yield (s->sock, rd_handler, wr_handler);aio_set_fd_handler (bdrv_get_aio_context (bs), s->sock, - false, rd_handler, wr_handler,NULL , &restart); + false, rd_handler, wr_handler,NULL ,NULL , &restart);qemu_coroutine_yield ();trace_ssh_co_yield_back (s->sock); }
block/win32-aio.c +2 -2
@@ -172,7 +172,7 @@ int win32_aio_attach(QEMUWin32AIOState *aio, HANDLE hfile)void win32_aio_detach_aio_context (QEMUWin32AIOState *aio,AioContext *old_context) { -aio_set_event_notifier (old_context, &aio->e, false,NULL ,NULL ); +aio_set_event_notifier (old_context, &aio->e, false,NULL ,NULL ,NULL ); aio->aio_ctx =NULL ; }
@@ -181,7 +181,7 @@ void win32_aio_attach_aio_context(QEMUWin32AIOState *aio, { aio->aio_ctx = new_context;aio_set_event_notifier (new_context, &aio->e, false, - win32_aio_completion_cb,NULL ); + win32_aio_completion_cb,NULL ,NULL ); }QEMUWin32AIOState *win32_aio_init (void )
hw/virtio/virtio.c +10 -6
@@ -3533,11 +3533,14 @@ static bool virtio_queue_host_notifier_aio_poll(void *opaque)EventNotifier *n = opaque;VirtQueue *vq =container_of (n, VirtQueue, host_notifier); -if (!vq->vring.desc ||virtio_queue_empty (vq)) { -return false; - } +return vq->vring.desc && !virtio_queue_empty (vq); +} -return virtio_queue_notify_aio_vq (vq); +static void virtio_queue_host_notifier_aio_poll_ready (EventNotifier *n) +{ +VirtQueue *vq =container_of (n, VirtQueue, host_notifier); + +virtio_queue_notify_aio_vq (vq); }static void virtio_queue_host_notifier_aio_poll_end (EventNotifier *n)
@@ -3555,12 +3558,13 @@ void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx, vq->handle_aio_output = handle_output;aio_set_event_notifier (ctx, &vq->host_notifier, true, virtio_queue_host_notifier_aio_read, - virtio_queue_host_notifier_aio_poll); + virtio_queue_host_notifier_aio_poll, + virtio_queue_host_notifier_aio_poll_ready);aio_set_event_notifier_poll (ctx, &vq->host_notifier, virtio_queue_host_notifier_aio_poll_begin, virtio_queue_host_notifier_aio_poll_end); }else { -aio_set_event_notifier (ctx, &vq->host_notifier, true,NULL ,NULL ); +aio_set_event_notifier (ctx, &vq->host_notifier, true,NULL ,NULL ,NULL );/* Test and clear notifier before after disabling event, * in case poll callback didn't have time to run. */ virtio_queue_host_notifier_aio_read (&vq->host_notifier);
hw/xen/xen-bus.c +3 -3
@@ -1115,11 +1115,11 @@ void xen_device_set_event_channel_context(XenDevice *xendev,if (channel->ctx)aio_set_fd_handler (channel->ctx,xenevtchn_fd (channel->xeh), true, -NULL ,NULL ,NULL ,NULL ); +NULL ,NULL ,NULL ,NULL ,NULL ); channel->ctx = ctx;aio_set_fd_handler (channel->ctx,xenevtchn_fd (channel->xeh), true, - xen_device_event,NULL , xen_device_poll, channel); + xen_device_event,NULL , xen_device_poll,NULL , channel); } XenEventChannel *xen_device_bind_event_channel(XenDevice *xendev,
@@ -1193,7 +1193,7 @@ void xen_device_unbind_event_channel(XenDevice *xendev,QLIST_REMOVE (channel, list);aio_set_fd_handler (channel->ctx,xenevtchn_fd (channel->xeh), true, -NULL ,NULL ,NULL ,NULL ); +NULL ,NULL ,NULL ,NULL ,NULL );if (xenevtchn_unbind (channel->xeh, channel->local_port) <0 ) {error_setg_errno (errp, errno,"xenevtchn_unbind failed" );
io/channel-command.c +4 -2
@@ -346,8 +346,10 @@ static void qio_channel_command_set_aio_fd_handler(QIOChannel *ioc, void *opaque) {QIOChannelCommand *cioc =QIO_CHANNEL_COMMAND (ioc); -aio_set_fd_handler (ctx, cioc->readfd, false, io_read,NULL ,NULL , opaque); -aio_set_fd_handler (ctx, cioc->writefd, false,NULL , io_write,NULL , opaque); +aio_set_fd_handler (ctx, cioc->readfd, false, + io_read,NULL ,NULL ,NULL , opaque); +aio_set_fd_handler (ctx, cioc->writefd, false, +NULL , io_write,NULL ,NULL , opaque); }
io/channel-file.c +2 -1
@@ -191,7 +191,8 @@ static void qio_channel_file_set_aio_fd_handler(QIOChannel *ioc, void *opaque) {QIOChannelFile *fioc =QIO_CHANNEL_FILE (ioc); -aio_set_fd_handler (ctx, fioc->fd, false, io_read, io_write,NULL , opaque); +aio_set_fd_handler (ctx, fioc->fd, false, io_read, io_write, +NULL ,NULL , opaque); } static GSource *qio_channel_file_create_watch(QIOChannel *ioc,
io/channel-socket.c +2 -1
@@ -761,7 +761,8 @@ static void qio_channel_socket_set_aio_fd_handler(QIOChannel *ioc, void *opaque) {QIOChannelSocket *sioc =QIO_CHANNEL_SOCKET (ioc); -aio_set_fd_handler (ctx, sioc->fd, false, io_read, io_write,NULL , opaque); +aio_set_fd_handler (ctx, sioc->fd, false, + io_read, io_write,NULL ,NULL , opaque); } static GSource *qio_channel_socket_create_watch(QIOChannel *ioc,
migration/rdma.c +4 -4
@@ -3161,14 +3161,14 @@ static void qio_channel_rdma_set_aio_fd_handler(QIOChannel *ioc,QIOChannelRDMA *rioc =QIO_CHANNEL_RDMA (ioc);if (io_read) {aio_set_fd_handler (ctx, rioc->rdmain->recv_comp_channel->fd, - false, io_read, io_write,NULL , opaque); + false, io_read, io_write,NULL ,NULL , opaque);aio_set_fd_handler (ctx, rioc->rdmain->send_comp_channel->fd, - false, io_read, io_write,NULL , opaque); + false, io_read, io_write,NULL ,NULL , opaque); }else {aio_set_fd_handler (ctx, rioc->rdmaout->recv_comp_channel->fd, - false, io_read, io_write,NULL , opaque); + false, io_read, io_write,NULL ,NULL , opaque);aio_set_fd_handler (ctx, rioc->rdmaout->send_comp_channel->fd, - false, io_read, io_write,NULL , opaque); + false, io_read, io_write,NULL ,NULL , opaque); } }
tests/unit/test-aio.c +2 -2
@@ -130,7 +130,7 @@ static void *test_acquire_thread(void *opaque)static void set_event_notifier (AioContext *ctx,EventNotifier *notifier,EventNotifierHandler *handler) { -aio_set_event_notifier (ctx, notifier, false, handler,NULL ); +aio_set_event_notifier (ctx, notifier, false, handler,NULL ,NULL ); }static void dummy_notifier_read (EventNotifier *n)
@@ -390,7 +390,7 @@ static void test_aio_external_client(void)for (i =1 ; i <3 ; i++) {EventNotifierTestData data = { .n =0 , .active =10 , .auto_set = true };event_notifier_init (&data.e, false); -aio_set_event_notifier (ctx, &data.e, true, event_ready_cb,NULL ); +aio_set_event_notifier (ctx, &data.e, true, event_ready_cb,NULL ,NULL );event_notifier_set (&data.e);for (j =0 ; j < i; j++) {aio_disable_external (ctx);
util/aio-posix.c +67 -22
240 lines not on this page · raw message
util/aio-win32.c +3 -1
@@ -68,6 +68,7 @@ void aio_set_fd_handler(AioContext *ctx, IOHandler *io_read, IOHandler *io_write, AioPollFn *io_poll, + IOHandler *io_poll_ready, void *opaque) {/* fd is a SOCKET in our case */
@@ -136,7 +137,8 @@ void aio_set_event_notifier(AioContext *ctx,EventNotifier *e, bool is_external, EventNotifierHandler *io_notify, - AioPollFn *io_poll) + AioPollFn *io_poll, + EventNotifierHandler *io_poll_ready) { AioHandler *node;
util/async.c +8 -2
@@ -362,7 +362,7 @@ aio_ctx_finalize(GSource *source)g_free (bh); } -aio_set_event_notifier (ctx, &ctx->notifier, false,NULL ,NULL ); +aio_set_event_notifier (ctx, &ctx->notifier, false,NULL ,NULL ,NULL );event_notifier_cleanup (&ctx->notifier);qemu_rec_mutex_destroy (&ctx->lock);qemu_lockcnt_destroy (&ctx->list_lock);
@@ -485,6 +485,11 @@ static bool aio_context_notifier_poll(void *opaque)return qatomic_read (&ctx->notified); } +static void aio_context_notifier_poll_ready (EventNotifier *e) +{ +/* Do nothing, we just wanted to kick the event loop */ +} +static void co_schedule_bh_cb (void *opaque) {AioContext *ctx = opaque;
@@ -536,7 +541,8 @@ AioContext *aio_context_new(Error **errp)aio_set_event_notifier (ctx, &ctx->notifier, false, aio_context_notifier_cb, - aio_context_notifier_poll); + aio_context_notifier_poll, + aio_context_notifier_poll_ready);#ifdef CONFIG_LINUX_AIO ctx->linux_aio =NULL ;#endif
util/main-loop.c +2 -2
@@ -582,7 +582,7 @@ void qemu_set_fd_handler(int fd, {iohandler_init ();aio_set_fd_handler (iohandler_ctx, fd, false, - fd_read, fd_write,NULL , opaque); + fd_read, fd_write,NULL ,NULL , opaque); } void event_notifier_set_handler(EventNotifier *e,
@@ -590,5 +590,5 @@ void event_notifier_set_handler(EventNotifier *e, {iohandler_init ();aio_set_event_notifier (iohandler_ctx, e, false, - handler,NULL ); + handler,NULL ,NULL ); }
util/qemu-coroutine-io.c +3 -2
@@ -75,7 +75,8 @@ typedef struct {static void fd_coroutine_enter (void *opaque) {FDYieldUntilData *data = opaque; -aio_set_fd_handler (data->ctx, data->fd, false,NULL ,NULL ,NULL ,NULL ); +aio_set_fd_handler (data->ctx, data->fd, false, +NULL ,NULL ,NULL ,NULL ,NULL );qemu_coroutine_enter (data->co); }
@@ -88,6 +89,6 @@ void coroutine_fn yield_until_fd_readable(int fd) data.co =qemu_coroutine_self (); data.fd = fd;aio_set_fd_handler ( - data.ctx, fd, false, fd_coroutine_enter,NULL ,NULL , &data); + data.ctx, fd, false, fd_coroutine_enter,NULL ,NULL ,NULL , &data);qemu_coroutine_yield (); }
util/vhost-user-server.c +6 -5
@@ -250,7 +250,7 @@ set_watch(VuDev *vu_dev, int fd, int vu_evt, vu_fd_watch->cb = cb;qemu_set_nonblock (fd);aio_set_fd_handler (server->ioc->ctx, fd, true, kick_handler, -NULL ,NULL , vu_fd_watch); +NULL ,NULL ,NULL , vu_fd_watch); vu_fd_watch->vu_dev = vu_dev; vu_fd_watch->pvt = pvt; }
@@ -270,7 +270,8 @@ static void remove_watch(VuDev *vu_dev, int fd)if (!vu_fd_watch) {return ; } -aio_set_fd_handler (server->ioc->ctx, fd, true,NULL ,NULL ,NULL ,NULL ); +aio_set_fd_handler (server->ioc->ctx, fd, true, +NULL ,NULL ,NULL ,NULL ,NULL );QTAILQ_REMOVE (&server->vu_fd_watches, vu_fd_watch, next);g_free (vu_fd_watch);
@@ -334,7 +335,7 @@ void vhost_user_server_stop(VuServer *server) QTAILQ_FOREACH(vu_fd_watch, &server->vu_fd_watches, next) {aio_set_fd_handler (server->ctx, vu_fd_watch->fd, true, -NULL ,NULL ,NULL , vu_fd_watch); +NULL ,NULL ,NULL ,NULL , vu_fd_watch); }qio_channel_shutdown (server->ioc,QIO_CHANNEL_SHUTDOWN_BOTH ,NULL );
@@ -377,7 +378,7 @@ void vhost_user_server_attach_aio_context(VuServer *server, AioContext *ctx) QTAILQ_FOREACH(vu_fd_watch, &server->vu_fd_watches, next) {aio_set_fd_handler (ctx, vu_fd_watch->fd, true, kick_handler,NULL , -NULL , vu_fd_watch); +NULL ,NULL , vu_fd_watch); }aio_co_schedule (ctx, server->co_trip);
@@ -391,7 +392,7 @@ void vhost_user_server_detach_aio_context(VuServer *server) QTAILQ_FOREACH(vu_fd_watch, &server->vu_fd_watches, next) {aio_set_fd_handler (server->ctx, vu_fd_watch->fd, true, -NULL ,NULL ,NULL , vu_fd_watch); +NULL ,NULL ,NULL ,NULL , vu_fd_watch); }qio_channel_detach_aio_context (server->ioc);
Signature · 1 line
2.33.1
PATCH v3 2/6 virtio: get rid of VirtIOHandleAIOOutput
In reply to Stefan HajnocziThe virtqueue host notifier API virtio_queue_aio_set_host_notifier_handler() polls the virtqueue for new buffers. AioContext previously required a bool progress return value indicating whether an event was handled or not. This is no longer necessary because the AioContext polling API has been split into a poll check function and an event handler function. The event handler is only run when we know there is work to do, so it doesn't return bool.
The VirtIOHandleAIOOutput function signature is now the same as VirtIOHandleOutput. Get rid of the bool return value.
Further simplifications will be made for virtio-blk and virtio-scsi in the next patch.
--- include/hw/virtio/virtio.h | 3 +-- hw/block/dataplane/virtio-blk.c | 4 ++-- hw/scsi/virtio-scsi-dataplane.c | 18 ++++++------------ hw/virtio/virtio.c | 12 ++++-------- 4 files changed, 13 insertions(+), 24 deletions(-)
include/hw/virtio/virtio.h +1 -2
@@ -175,7 +175,6 @@ void virtio_error(VirtIODevice *vdev, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void virtio_device_set_child_bus_name (VirtIODevice *vdev,char *bus_name);typedef void (*VirtIOHandleOutput )(VirtIODevice *,VirtQueue *); -typedef bool (*VirtIOHandleAIOOutput )(VirtIODevice *,VirtQueue *);VirtQueue *virtio_add_queue (VirtIODevice *vdev,int queue_size,VirtIOHandleOutput handle_output);
@@ -318,7 +317,7 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);void virtio_queue_set_host_notifier_enabled (VirtQueue *vq,bool enabled);void virtio_queue_host_notifier_read (EventNotifier *n);void virtio_queue_aio_set_host_notifier_handler (VirtQueue *vq,AioContext *ctx, -VirtIOHandleAIOOutput handle_output); +VirtIOHandleOutput handle_output);VirtQueue *virtio_vector_first_queue (VirtIODevice *vdev,uint16_t vector);VirtQueue *virtio_vector_next_queue (VirtQueue *vq);
hw/block/dataplane/virtio-blk.c +2 -2
@@ -154,7 +154,7 @@ void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s)g_free (s); } -static bool virtio_blk_data_plane_handle_output (VirtIODevice *vdev, +static void virtio_blk_data_plane_handle_output (VirtIODevice *vdev,VirtQueue *vq) {VirtIOBlock *s = (VirtIOBlock *)vdev;
@@ -162,7 +162,7 @@ static bool virtio_blk_data_plane_handle_output(VirtIODevice *vdev,assert (s->dataplane);assert (s->dataplane_started); -return virtio_blk_handle_vq (s, vq); +virtio_blk_handle_vq (s, vq); }/* Context: QEMU global mutex held */
hw/scsi/virtio-scsi-dataplane.c +6 -12
@@ -49,49 +49,43 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp) } } -static bool virtio_scsi_data_plane_handle_cmd (VirtIODevice *vdev, +static void virtio_scsi_data_plane_handle_cmd (VirtIODevice *vdev,VirtQueue *vq) { -bool progress = false;VirtIOSCSI *s =VIRTIO_SCSI (vdev);virtio_scsi_acquire (s);if (!s->dataplane_fenced) {assert (s->ctx && s->dataplane_started); - progress =virtio_scsi_handle_cmd_vq (s, vq); +virtio_scsi_handle_cmd_vq (s, vq); }virtio_scsi_release (s); -return progress; } -static bool virtio_scsi_data_plane_handle_ctrl (VirtIODevice *vdev, +static void virtio_scsi_data_plane_handle_ctrl (VirtIODevice *vdev,VirtQueue *vq) { -bool progress = false;VirtIOSCSI *s =VIRTIO_SCSI (vdev);virtio_scsi_acquire (s);if (!s->dataplane_fenced) {assert (s->ctx && s->dataplane_started); - progress =virtio_scsi_handle_ctrl_vq (s, vq); +virtio_scsi_handle_ctrl_vq (s, vq); }virtio_scsi_release (s); -return progress; } -static bool virtio_scsi_data_plane_handle_event (VirtIODevice *vdev, +static void virtio_scsi_data_plane_handle_event (VirtIODevice *vdev,VirtQueue *vq) { -bool progress = false;VirtIOSCSI *s =VIRTIO_SCSI (vdev);virtio_scsi_acquire (s);if (!s->dataplane_fenced) {assert (s->ctx && s->dataplane_started); - progress =virtio_scsi_handle_event_vq (s, vq); +virtio_scsi_handle_event_vq (s, vq); }virtio_scsi_release (s); -return progress; }static int virtio_scsi_set_host_notifier (VirtIOSCSI *s,VirtQueue *vq,int n)
hw/virtio/virtio.c +4 -8
@@ -125,7 +125,7 @@ struct VirtQueueuint16_t vector;VirtIOHandleOutput handle_output; -VirtIOHandleAIOOutput handle_aio_output; +VirtIOHandleOutput handle_aio_output;VirtIODevice *vdev;EventNotifier guest_notifier;EventNotifier host_notifier;
@@ -2300,22 +2300,18 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) } } -static bool virtio_queue_notify_aio_vq (VirtQueue *vq) +static void virtio_queue_notify_aio_vq (VirtQueue *vq) { -bool ret = false; -if (vq->vring.desc && vq->handle_aio_output) {VirtIODevice *vdev = vq->vdev;trace_virtio_queue_notify (vdev, vq - vdev->vq, vq); - ret = vq->handle_aio_output (vdev, vq); + vq->handle_aio_output (vdev, vq);if (unlikely (vdev->start_on_kick)) {virtio_set_started (vdev, true); } } - -return ret; }static void virtio_queue_notify_vq (VirtQueue *vq)
@@ -3552,7 +3548,7 @@ static void virtio_queue_host_notifier_aio_poll_end(EventNotifier *n) }void virtio_queue_aio_set_host_notifier_handler (VirtQueue *vq,AioContext *ctx, -VirtIOHandleAIOOutput handle_output) +VirtIOHandleOutput handle_output) {if (handle_output) { vq->handle_aio_output = handle_output;
Signature · 1 line
2.33.1
PATCH v3 3/6 virtio-blk: drop unused virtio_blk_handle_vq() return value
In reply to Stefan HajnocziThe return value of virtio_blk_handle_vq() is no longer used. Get rid of it. This is a step towards unifying the dataplane and non-dataplane virtqueue handler functions.
Prepare virtio_blk_handle_output() to be used by both dataplane and non-dataplane by making the condition for starting ioeventfd more specific. This way it won't trigger when dataplane has already been started.
--- include/hw/virtio/virtio-blk.h | 2 +- hw/block/virtio-blk.c | 14 +++----------- 2 files changed, 4 insertions(+), 12 deletions(-)
include/hw/virtio/virtio-blk.h +1 -1
@@ -90,7 +90,7 @@ typedef struct MultiReqBuffer { bool is_write; } MultiReqBuffer; -bool virtio_blk_handle_vq (VirtIOBlock *s,VirtQueue *vq); +void virtio_blk_handle_vq (VirtIOBlock *s,VirtQueue *vq);void virtio_blk_process_queued_requests (VirtIOBlock *s,bool is_bh);#endif
hw/block/virtio-blk.c +3 -11
@@ -767,12 +767,11 @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)return 0 ; } -bool virtio_blk_handle_vq (VirtIOBlock *s,VirtQueue *vq) +void virtio_blk_handle_vq (VirtIOBlock *s,VirtQueue *vq) {VirtIOBlockReq *req;MultiReqBuffer mrb = {};bool suppress_notifications =virtio_queue_get_notification (vq); -bool progress = false;aio_context_acquire (blk_get_aio_context (s->blk));blk_io_plug (s->blk);
@@ -783,7 +782,6 @@ bool virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *vq) }while ((req =virtio_blk_get_request (s, vq))) { - progress = true;if (virtio_blk_handle_request (req, &mrb)) {virtqueue_detach_element (req->vq, &req->elem,0 );virtio_blk_free_request (req);
@@ -802,19 +800,13 @@ bool virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *vq)blk_io_unplug (s->blk);aio_context_release (blk_get_aio_context (s->blk)); -return progress; -} - -static void virtio_blk_handle_output_do (VirtIOBlock *s,VirtQueue *vq) -{ -virtio_blk_handle_vq (s, vq); }static void virtio_blk_handle_output (VirtIODevice *vdev,VirtQueue *vq) {VirtIOBlock *s = (VirtIOBlock *)vdev; -if (s->dataplane) { +if (s->dataplane && !s->dataplane_started) {/* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start * dataplane here instead of waiting for .set_status(). */
@@ -823,7 +815,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)return ; } } -virtio_blk_handle_output_do (s, vq); +virtio_blk_handle_vq (s, vq); }void virtio_blk_process_queued_requests (VirtIOBlock *s,bool is_bh)
Signature · 1 line
2.33.1
PATCH v3 4/6 virtio-scsi: prepare virtio_scsi_handle_cmd for dataplane
In reply to Stefan HajnocziPrepare virtio_scsi_handle_cmd() to be used by both dataplane and non-dataplane by making the condition for starting ioeventfd more specific. This way it won't trigger when dataplane has already been started.
--- hw/scsi/virtio-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/virtio-scsi.c +1 -1
@@ -720,7 +720,7 @@ static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq)/* use non-QOM casts in the data path */ VirtIOSCSI *s = (VirtIOSCSI *)vdev; -if (s->ctx) { +if (s->ctx && !s->dataplane_started) {virtio_device_start_ioeventfd (vdev);if (!s->dataplane_fenced) {return ;
Signature · 1 line
2.33.1
PATCH v3 5/6 virtio: use ->handle_output() instead of ->handle_aio_output()
In reply to Stefan HajnocziThe difference between ->handle_output() and ->handle_aio_output() was that ->handle_aio_output() returned a bool return value indicating progress. This was needed by the old polling API but now that the bool return value is gone, the two functions can be unified.
--- hw/virtio/virtio.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-)
hw/virtio/virtio.c +3 -30
@@ -125,7 +125,6 @@ struct VirtQueueuint16_t vector;VirtIOHandleOutput handle_output; -VirtIOHandleOutput handle_aio_output;VirtIODevice *vdev;EventNotifier guest_notifier;EventNotifier host_notifier;
@@ -2300,20 +2299,6 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) } } -static void virtio_queue_notify_aio_vq (VirtQueue *vq) -{ -if (vq->vring.desc && vq->handle_aio_output) { -VirtIODevice *vdev = vq->vdev; - -trace_virtio_queue_notify (vdev, vq - vdev->vq, vq); - vq->handle_aio_output (vdev, vq); - -if (unlikely (vdev->start_on_kick)) { -virtio_set_started (vdev, true); - } - } -} -static void virtio_queue_notify_vq (VirtQueue *vq) {if (vq->vring.desc && vq->handle_output) {
@@ -2392,7 +2377,6 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size, vdev->vq[i].vring.num_default = queue_size; vdev->vq[i].vring.align =VIRTIO_PCI_VRING_ALIGN ; vdev->vq[i].handle_output = handle_output; - vdev->vq[i].handle_aio_output =NULL ; vdev->vq[i].used_elems =g_malloc0 (sizeof (VirtQueueElement) * queue_size);
@@ -2404,7 +2388,6 @@ void virtio_delete_queue(VirtQueue *vq) vq->vring.num =0 ; vq->vring.num_default =0 ; vq->handle_output =NULL ; - vq->handle_aio_output =NULL ;g_free (vq->used_elems); vq->used_elems =NULL ;virtio_virtqueue_reset_region_cache (vq);
@@ -3509,14 +3492,6 @@ EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq)return &vq->guest_notifier; } -static void virtio_queue_host_notifier_aio_read (EventNotifier *n) -{ -VirtQueue *vq =container_of (n, VirtQueue, host_notifier); -if (event_notifier_test_and_clear (n)) { -virtio_queue_notify_aio_vq (vq); - } -} -static void virtio_queue_host_notifier_aio_poll_begin (EventNotifier *n) {VirtQueue *vq =container_of (n, VirtQueue, host_notifier);
@@ -3536,7 +3511,7 @@ static void virtio_queue_host_notifier_aio_poll_ready(EventNotifier *n) {VirtQueue *vq =container_of (n, VirtQueue, host_notifier); -virtio_queue_notify_aio_vq (vq); +virtio_queue_notify_vq (vq); }static void virtio_queue_host_notifier_aio_poll_end (EventNotifier *n)
@@ -3551,9 +3526,8 @@ void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx, VirtIOHandleOutput handle_output) {if (handle_output) { - vq->handle_aio_output = handle_output;aio_set_event_notifier (ctx, &vq->host_notifier, true, - virtio_queue_host_notifier_aio_read, + virtio_queue_host_notifier_read, virtio_queue_host_notifier_aio_poll, virtio_queue_host_notifier_aio_poll_ready); aio_set_event_notifier_poll(ctx, &vq->host_notifier,
@@ -3563,8 +3537,7 @@ void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,aio_set_event_notifier (ctx, &vq->host_notifier, true,NULL ,NULL ,NULL );/* Test and clear notifier before after disabling event, * in case poll callback didn't have time to run. */ -virtio_queue_host_notifier_aio_read (&vq->host_notifier); - vq->handle_aio_output =NULL ; +virtio_queue_host_notifier_read (&vq->host_notifier); } }
Signature · 1 line
2.33.1
PATCH v3 6/6 virtio: unify dataplane and non-dataplane ->handle_output()
In reply to Stefan HajnocziNow that virtio-blk and virtio-scsi are ready, get rid of the handle_aio_output() callback. It's no longer needed.
--- include/hw/virtio/virtio.h | 4 +-- hw/block/dataplane/virtio-blk.c | 16 ++-------- hw/scsi/virtio-scsi-dataplane.c | 54 ++++----------------------------- hw/virtio/virtio.c | 32 +++++++++---------- 4 files changed, 26 insertions(+), 80 deletions(-)
include/hw/virtio/virtio.h +2 -2
@@ -316,8 +316,8 @@ bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev);EventNotifier *virtio_queue_get_host_notifier (VirtQueue *vq);void virtio_queue_set_host_notifier_enabled (VirtQueue *vq,bool enabled);void virtio_queue_host_notifier_read (EventNotifier *n); -void virtio_queue_aio_set_host_notifier_handler (VirtQueue *vq,AioContext *ctx, -VirtIOHandleOutput handle_output); +void virtio_queue_aio_attach_host_notifier (VirtQueue *vq,AioContext *ctx); +void virtio_queue_aio_detach_host_notifier (VirtQueue *vq,AioContext *ctx);VirtQueue *virtio_vector_first_queue (VirtIODevice *vdev,uint16_t vector);VirtQueue *virtio_vector_next_queue (VirtQueue *vq);
hw/block/dataplane/virtio-blk.c +2 -14
@@ -154,17 +154,6 @@ void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s)g_free (s); } -static void virtio_blk_data_plane_handle_output (VirtIODevice *vdev, -VirtQueue *vq) -{ -VirtIOBlock *s = (VirtIOBlock *)vdev; - -assert (s->dataplane); -assert (s->dataplane_started); - -virtio_blk_handle_vq (s, vq); -} -/* Context: QEMU global mutex held */ int virtio_blk_data_plane_start (VirtIODevice *vdev) {
@@ -258,8 +247,7 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)for (i =0 ; i < nvqs; i++) {VirtQueue *vq =virtio_get_queue (s->vdev, i); -virtio_queue_aio_set_host_notifier_handler (vq, s->ctx, - virtio_blk_data_plane_handle_output); +virtio_queue_aio_attach_host_notifier (vq, s->ctx); }aio_context_release (s->ctx);return 0 ;
@@ -302,7 +290,7 @@ static void virtio_blk_data_plane_stop_bh(void *opaque)for (i =0 ; i < s->conf->num_queues; i++) {VirtQueue *vq =virtio_get_queue (s->vdev, i); -virtio_queue_aio_set_host_notifier_handler (vq, s->ctx,NULL ); +virtio_queue_aio_detach_host_notifier (vq, s->ctx); } }
hw/scsi/virtio-scsi-dataplane.c +6 -48
75 lines not on this page · raw message
hw/virtio/virtio.c +16 -16
@@ -3522,23 +3522,23 @@ static void virtio_queue_host_notifier_aio_poll_end(EventNotifier *n)virtio_queue_set_notification (vq,1 ); } -void virtio_queue_aio_set_host_notifier_handler (VirtQueue *vq,AioContext *ctx, -VirtIOHandleOutput handle_output) +void virtio_queue_aio_attach_host_notifier (VirtQueue *vq,AioContext *ctx) { -if (handle_output) { -aio_set_event_notifier (ctx, &vq->host_notifier, true, - virtio_queue_host_notifier_read, - virtio_queue_host_notifier_aio_poll, - virtio_queue_host_notifier_aio_poll_ready); -aio_set_event_notifier_poll (ctx, &vq->host_notifier, - virtio_queue_host_notifier_aio_poll_begin, - virtio_queue_host_notifier_aio_poll_end); - }else { -aio_set_event_notifier (ctx, &vq->host_notifier, true,NULL ,NULL ,NULL ); -/* Test and clear notifier before after disabling event, -* in case poll callback didn't have time to run. */ -virtio_queue_host_notifier_read (&vq->host_notifier); - } +aio_set_event_notifier (ctx, &vq->host_notifier, true, + virtio_queue_host_notifier_read, + virtio_queue_host_notifier_aio_poll, + virtio_queue_host_notifier_aio_poll_ready); +aio_set_event_notifier_poll (ctx, &vq->host_notifier, + virtio_queue_host_notifier_aio_poll_begin, + virtio_queue_host_notifier_aio_poll_end); +} + +void virtio_queue_aio_detach_host_notifier (VirtQueue *vq,AioContext *ctx) +{ +aio_set_event_notifier (ctx, &vq->host_notifier, true,NULL ,NULL ,NULL ); +/* Test and clear notifier before after disabling event, +* in case poll callback didn't have time to run. */ +virtio_queue_host_notifier_read (&vq->host_notifier); }void virtio_queue_host_notifier_read (EventNotifier *n)
Signature · 1 line
2.33.1
Quoted 13 lines · Stefan Hajnoczi
v3:
- Fixed FUSE exportaio_set_fd_handler()call that I missed and double-checked for any other missing call sites using Coccinelle [Rich]
v2:
- Cleaned up unused return values in nvme and virtio-blk [Stefano]
- Documentedtry_poll_mode()ready_listargument [Stefano]
- Unified virtio-blk/scsi dataplane and non-dataplane virtqueue handlers [Stefano]The first patch improves AioContext's adaptive polling execution time measurement. This can result in better performance because the algorithm makes better decisions about when to poll versus when to fall back to file descriptor monitoring.
Quoted 4 lines
The remaining patches unify the virtio-blk and virtio-scsi dataplane and non-dataplane virtqueue handlers. This became possible because the dataplane handler function now has the same function signature as the non-dataplane handler function. Stefano Garzarella prompted me to make this refactoring.
Great clean up! Thanks for doing this, everything LGTM:
Stefan Hajnoczi
AppliedQuoted 49 lines · Stefan Hajnoczi
v3:
- Fixed FUSE exportaio_set_fd_handler()call that I missed and double-checked for any other missing call sites using Coccinelle [Rich]
v2:
- Cleaned up unused return values in nvme and virtio-blk [Stefano]
- Documentedtry_poll_mode()ready_listargument [Stefano]
- Unified virtio-blk/scsi dataplane and non-dataplane virtqueue handlers [Stefano]The first patch improves AioContext's adaptive polling execution time measurement. This can result in better performance because the algorithm makes better decisions about when to poll versus when to fall back to file descriptor monitoring.
The remaining patches unify the virtio-blk and virtio-scsi dataplane and non-dataplane virtqueue handlers. This became possible because the dataplane handler function now has the same function signature as the non-dataplane handler function. Stefano Garzarella prompted me to make this refactoring.
Stefan Hajnoczi (6):
aio-posix: split poll check from ready handler
virtio: get rid of VirtIOHandleAIOOutput
virtio-blk: drop unusedvirtio_blk_handle_vq()return value
virtio-scsi: preparevirtio_scsi_handle_cmdfor dataplane
virtio: use ->handle_output() instead of ->handle_aio_output()
virtio: unify dataplane and non-dataplane ->handle_output()include/block/aio.h | 4 +- include/hw/virtio/virtio-blk.h | 2 +- include/hw/virtio/virtio.h | 5 +- util/aio-posix.h | 1 + block/curl.c | 11 ++-- block/export/fuse.c | 4 +- block/io_uring.c | 19 ++++--- block/iscsi.c | 4 +- block/linux-aio.c | 16 +++--- block/nfs.c | 6 +-- block/nvme.c | 51 ++++++++++++------- block/ssh.c | 4 +- block/win32-aio.c | 4 +- hw/block/dataplane/virtio-blk.c | 16 +----- hw/block/virtio-blk.c | 14 ++---- hw/scsi/virtio-scsi-dataplane.c | 60 +++------------------- hw/scsi/virtio-scsi.c | 2 +- hw/virtio/virtio.c | 73 +++++++++------------------ hw/xen/xen-bus.c | 6 +-- io/channel-command.c | 6 ++- io/channel-file.c | 3 +- io/channel-socket.c | 3 +- migration/rdma.c | 8 +--
Quoted 13 lines
tests/unit/test-aio.c | 4 +- util/aio-posix.c | 89 +++++++++++++++++++++++++-------- util/aio-win32.c | 4 +- util/async.c | 10 +++- util/main-loop.c | 4 +- util/qemu-coroutine-io.c | 5 +- util/vhost-user-server.c | 11 ++-- 30 files changed, 219 insertions(+), 230 deletions(-)Signature · 1 line
2.33.1
Thanks, applied to my block-next tree:
https://gitlab.com/stefanha/qemu/commits/block-next
Stefan