qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] 826cc3: aio-posix: split poll check from read


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] 826cc3: aio-posix: split poll check from ready handler
Date: Fri, 14 Jan 2022 05:21:35 -0800

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 826cc32423db2a99d184dbf4f507c737d7e7a4ae
      
https://github.com/qemu/qemu/commit/826cc32423db2a99d184dbf4f507c737d7e7a4ae
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2022-01-12 (Wed, 12 Jan 2022)

  Changed paths:
    M block/curl.c
    M block/export/fuse.c
    M block/io_uring.c
    M block/iscsi.c
    M block/linux-aio.c
    M block/nfs.c
    M block/nvme.c
    M block/ssh.c
    M block/win32-aio.c
    M hw/virtio/virtio.c
    M hw/xen/xen-bus.c
    M include/block/aio.h
    M io/channel-command.c
    M io/channel-file.c
    M io/channel-socket.c
    M migration/rdma.c
    M tests/unit/test-aio.c
    M tests/unit/test-fdmon-epoll.c
    M util/aio-posix.c
    M util/aio-posix.h
    M util/aio-win32.c
    M util/async.c
    M util/main-loop.c
    M util/qemu-coroutine-io.c
    M util/vhost-user-server.c

  Log Message:
  -----------
  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.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20211207132336.36627-2-stefanha@redhat.com

[Fixed up aio_set_event_notifier() calls in
tests/unit/test-fdmon-epoll.c added after this series was queued.
--Stefan]

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


  Commit: d93d16c0450b3d0fe8e25568663531eb250d6aae
      
https://github.com/qemu/qemu/commit/d93d16c0450b3d0fe8e25568663531eb250d6aae
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2022-01-12 (Wed, 12 Jan 2022)

  Changed paths:
    M hw/block/dataplane/virtio-blk.c
    M hw/scsi/virtio-scsi-dataplane.c
    M hw/virtio/virtio.c
    M include/hw/virtio/virtio.h

  Log Message:
  -----------
  virtio: get rid of VirtIOHandleAIOOutput

The 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.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20211207132336.36627-3-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


  Commit: 186b9691730ca4d3d59fa135d7d24467a3254c9a
      
https://github.com/qemu/qemu/commit/186b9691730ca4d3d59fa135d7d24467a3254c9a
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2022-01-12 (Wed, 12 Jan 2022)

  Changed paths:
    M hw/block/virtio-blk.c
    M include/hw/virtio/virtio-blk.h

  Log Message:
  -----------
  virtio-blk: drop unused virtio_blk_handle_vq() return value

The 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.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20211207132336.36627-4-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


  Commit: f34e8d8b8d48d73f36a67b6d5e492ef9784b5012
      
https://github.com/qemu/qemu/commit/f34e8d8b8d48d73f36a67b6d5e492ef9784b5012
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2022-01-12 (Wed, 12 Jan 2022)

  Changed paths:
    M hw/scsi/virtio-scsi.c

  Log Message:
  -----------
  virtio-scsi: prepare virtio_scsi_handle_cmd for dataplane

Prepare 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.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20211207132336.36627-5-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


  Commit: d6fbfe2b83ca466e7618f1b6fef1544544ff2e43
      
https://github.com/qemu/qemu/commit/d6fbfe2b83ca466e7618f1b6fef1544544ff2e43
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2022-01-12 (Wed, 12 Jan 2022)

  Changed paths:
    M hw/virtio/virtio.c

  Log Message:
  -----------
  virtio: use ->handle_output() instead of ->handle_aio_output()

The 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.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20211207132336.36627-6-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


  Commit: db608fb78444c58896db69495729e4458eeaace1
      
https://github.com/qemu/qemu/commit/db608fb78444c58896db69495729e4458eeaace1
  Author: Stefan Hajnoczi <stefanha@redhat.com>
  Date:   2022-01-12 (Wed, 12 Jan 2022)

  Changed paths:
    M hw/block/dataplane/virtio-blk.c
    M hw/scsi/virtio-scsi-dataplane.c
    M hw/virtio/virtio.c
    M include/hw/virtio/virtio.h

  Log Message:
  -----------
  virtio: unify dataplane and non-dataplane ->handle_output()

Now that virtio-blk and virtio-scsi are ready, get rid of
the handle_aio_output() callback. It's no longer needed.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20211207132336.36627-7-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


  Commit: 1001c9d9c0c6c2ef0ae6cc27b8555e1a4e93dc30
      
https://github.com/qemu/qemu/commit/1001c9d9c0c6c2ef0ae6cc27b8555e1a4e93dc30
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2022-01-14 (Fri, 14 Jan 2022)

  Changed paths:
    M block/curl.c
    M block/export/fuse.c
    M block/io_uring.c
    M block/iscsi.c
    M block/linux-aio.c
    M block/nfs.c
    M block/nvme.c
    M block/ssh.c
    M block/win32-aio.c
    M hw/block/dataplane/virtio-blk.c
    M hw/block/virtio-blk.c
    M hw/scsi/virtio-scsi-dataplane.c
    M hw/scsi/virtio-scsi.c
    M hw/virtio/virtio.c
    M hw/xen/xen-bus.c
    M include/block/aio.h
    M include/hw/virtio/virtio-blk.h
    M include/hw/virtio/virtio.h
    M io/channel-command.c
    M io/channel-file.c
    M io/channel-socket.c
    M migration/rdma.c
    M tests/unit/test-aio.c
    M tests/unit/test-fdmon-epoll.c
    M util/aio-posix.c
    M util/aio-posix.h
    M util/aio-win32.c
    M util/async.c
    M util/main-loop.c
    M util/qemu-coroutine-io.c
    M util/vhost-user-server.c

  Log Message:
  -----------
  Merge remote-tracking branch 
'remotes/stefanha-gitlab/tags/block-pull-request' into staging

Pull request

# gpg: Signature made Wed 12 Jan 2022 17:13:54 GMT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full]
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha-gitlab/tags/block-pull-request:
  virtio: unify dataplane and non-dataplane ->handle_output()
  virtio: use ->handle_output() instead of ->handle_aio_output()
  virtio-scsi: prepare virtio_scsi_handle_cmd for dataplane
  virtio-blk: drop unused virtio_blk_handle_vq() return value
  virtio: get rid of VirtIOHandleAIOOutput
  aio-posix: split poll check from ready handler

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/67b6526cf042...1001c9d9c0c6



reply via email to

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