Skip to content
Snippets Groups Projects
  1. May 30, 2023
    • Stefan Hajnoczi's avatar
      aio: remove aio_disable_external() API · 60f782b6
      Stefan Hajnoczi authored
      All callers now pass is_external=false to aio_set_fd_handler() and
      aio_set_event_notifier(). The aio_disable_external() API that
      temporarily disables fd handlers that were registered is_external=true
      is therefore dead code.
      
      Remove aio_disable_external(), aio_enable_external(), and the
      is_external arguments to aio_set_fd_handler() and
      aio_set_event_notifier().
      
      The entire test-fdmon-epoll test is removed because its sole purpose was
      testing aio_disable_external().
      
      Parts of this patch were generated using the following coccinelle
      (https://coccinelle.lip6.fr/
      
      ) semantic patch:
      
        @@
        expression ctx, fd, is_external, io_read, io_write, io_poll, io_poll_ready, opaque;
        @@
        - aio_set_fd_handler(ctx, fd, is_external, io_read, io_write, io_poll, io_poll_ready, opaque)
        + aio_set_fd_handler(ctx, fd, io_read, io_write, io_poll, io_poll_ready, opaque)
      
        @@
        expression ctx, notifier, is_external, io_read, io_poll, io_poll_ready;
        @@
        - aio_set_event_notifier(ctx, notifier, is_external, io_read, io_poll, io_poll_ready)
        + aio_set_event_notifier(ctx, notifier, io_read, io_poll, io_poll_ready)
      
      Reviewed-by: default avatarJuan Quintela <quintela@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Message-Id: <20230516190238.8401-21-stefanha@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      60f782b6
  2. Apr 06, 2022
  3. Jan 12, 2022
    • Stefan Hajnoczi's avatar
      aio-posix: split poll check from ready handler · 826cc324
      Stefan Hajnoczi authored
      
      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: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarStefano 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: default avatarStefan Hajnoczi <stefanha@redhat.com>
      826cc324
  4. Oct 25, 2019
  5. Jul 13, 2016
    • Paolo Bonzini's avatar
      coroutine: move entry argument to qemu_coroutine_create · 0b8b8753
      Paolo Bonzini authored
      
      In practice the entry argument is always known at creation time, and
      it is confusing that sometimes qemu_coroutine_enter is used with a
      non-NULL argument to re-enter a coroutine (this happens in
      block/sheepdog.c and tests/test-coroutine.c).  So pass the opaque value
      at creation time, for consistency with e.g. aio_bh_new.
      
      Mostly done with the following semantic patch:
      
      @ entry1 @
      expression entry, arg, co;
      @@
      - co = qemu_coroutine_create(entry);
      + co = qemu_coroutine_create(entry, arg);
        ...
      - qemu_coroutine_enter(co, arg);
      + qemu_coroutine_enter(co);
      
      @ entry2 @
      expression entry, arg;
      identifier co;
      @@
      - Coroutine *co = qemu_coroutine_create(entry);
      + Coroutine *co = qemu_coroutine_create(entry, arg);
        ...
      - qemu_coroutine_enter(co, arg);
      + qemu_coroutine_enter(co);
      
      @ entry3 @
      expression entry, arg;
      @@
      - qemu_coroutine_enter(qemu_coroutine_create(entry), arg);
      + qemu_coroutine_enter(qemu_coroutine_create(entry, arg));
      
      @ reentry @
      expression co;
      @@
      - qemu_coroutine_enter(co, NULL);
      + qemu_coroutine_enter(co);
      
      except for the aforementioned few places where the semantic patch
      stumbled (as expected) and for test_co_queue, which would otherwise
      produce an uninitialized variable warning.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarFam Zheng <famz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      0b8b8753
  6. Mar 10, 2016
  7. Feb 04, 2016
  8. Oct 20, 2015
    • Daniel P. Berrangé's avatar
      coroutine: move into libqemuutil.a library · 10817bf0
      Daniel P. Berrangé authored
      
      The coroutine files are currently referenced by the block-obj-y
      variable. The coroutine functionality though is already used by
      more than just the block code. eg migration code uses coroutine
      yield. In the future the I/O channel code will also use the
      coroutine yield functionality. Since the coroutine code is nicely
      self-contained it can be easily built as part of the libqemuutil.a
      library, making it widely available.
      
      The headers are also moved into include/qemu, instead of the
      include/block directory, since they are now part of the util
      codebase, and the impl was never in the block/ directory
      either.
      
      Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
      10817bf0
  9. Mar 18, 2015
  10. Aug 29, 2014
  11. Aug 22, 2013
  12. Jun 27, 2013
  13. Dec 19, 2012
  14. Jun 11, 2012
    • Michael Tokarev's avatar
      rewrite iov_send_recv() and move it to iov.c · 25e5e4c7
      Michael Tokarev authored
      
      Make it much more understandable, add a missing
      iov_cnt argument (number of iovs in the iov), and
      add comments to it.
      
      The new implementation has been extensively tested
      by splitting a large buffer into many small
      randomly-sized chunks, sending it over socket to
      another, slow process and verifying the receiving
      data is the same.
      
      Also add a unit test for iov_send_recv(), sending/
      receiving data between two processes over a socketpair
      using random vectors and random sizes.
      
      Signed-off-by: default avatarMichael Tokarev <mjt@tls.msk.ru>
      25e5e4c7
    • Michael Tokarev's avatar
      cleanup qemu_co_sendv(), qemu_co_recvv() and friends · 2fc8ae1d
      Michael Tokarev authored
      
      The same as for non-coroutine versions in previous
      patches: rename arguments to be more obvious, change
      type of arguments from int to size_t where appropriate,
      and use common code for send and receive paths (with
      one extra argument) since these are exactly the same.
      Use common iov_send_recv() directly.
      
      qemu_co_sendv(), qemu_co_recvv(), and qemu_co_recv()
      are now trivial #define's merely adding one extra arg.
      
      qemu_co_sendv() and qemu_co_recvv() callers are
      converted to different argument order and extra
      `iov_cnt' argument.
      
      Signed-off-by: default avatarMichael Tokarev <mjt@tls.msk.ru>
      2fc8ae1d
    • Michael Tokarev's avatar
      rename qemu_sendv to iov_send, change proto and move declarations to iov.h · 3e80bf93
      Michael Tokarev authored
      
      Rename arguments and use size_t for sizes instead of int,
      from
       int
       qemu_sendv(int sockfd, struct iovec *iov,
                  int len, int iov_offset)
      to
       ssize_t
       iov_send(int sockfd, struct iovec *iov,
                size_t offset, size_t bytes)
      
      The main motivation was to make it clear that length
      and offset are in _bytes_, not in iov elements: it was
      very confusing before, because all standard functions
      which deals with iovecs expects number of iovs, not
      bytes, even the fact that struct iovec has iov_len and
      iov_ prefix does not help.  With "bytes" and "offset",
      especially since they're now size_t, it is much more
      explicit.  Also change the return type to be ssize_t
      instead of int.
      
      This also changes it to match other iov-related functons,
      but not _quite_: there's still no argument indicating
      where iovec ends, ie, no iov_cnt parameter as used
      in iov_size() and friends.  If will be added in subsequent
      patch/rewrite.
      
      All callers of qemu_sendv() and qemu_recvv() and
      related, like qemu_co_sendv() and qemu_co_recvv(),
      were checked to verify that it is safe to use unsigned
      datatype instead of int.
      
      Note that the order of arguments is changed to: offset
      and bytes (len and iov_offset) are swapped with each
      other.  This is to make them consistent with very similar
      functions from qemu_iovec family, where offset always
      follows qiov, to mean the place in it to start from.
      
      Signed-off-by: default avatarMichael Tokarev <mjt@tls.msk.ru>
      3e80bf93
  15. Dec 22, 2011
Loading