<feed xmlns='http://www.w3.org/2005/Atom'>
<title>bwlp/qemu.git/block/linux-aio.c, branch spice_video_codecs</title>
<subtitle>Experimental fork of QEMU with video encoding patches</subtitle>
<id>https://git.openslx.org/bwlp/qemu.git/atom/block/linux-aio.c?h=spice_video_codecs</id>
<link rel='self' href='https://git.openslx.org/bwlp/qemu.git/atom/block/linux-aio.c?h=spice_video_codecs'/>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/'/>
<updated>2022-08-01T09:58:02+00:00</updated>
<entry>
<title>misc: fix commonly doubled up words</title>
<updated>2022-08-01T09:58:02+00:00</updated>
<author>
<name>Daniel P. Berrangé</name>
</author>
<published>2022-07-07T16:37:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=7a21bee2aa52fc95b25e38372678986ee94f05f1'/>
<id>urn:sha1:7a21bee2aa52fc95b25e38372678986ee94f05f1</id>
<content type='text'>
Signed-off-by: Daniel P. Berrangé &lt;berrange@redhat.com&gt;
Message-Id: &lt;20220707163720.1421716-5-berrange@redhat.com&gt;
Reviewed-by: Peter Maydell &lt;peter.maydell@linaro.org&gt;
Signed-off-by: Thomas Huth &lt;thuth@redhat.com&gt;
</content>
</entry>
<entry>
<title>linux-aio: explain why max batch is checked in laio_io_unplug()</title>
<updated>2022-06-15T15:43:42+00:00</updated>
<author>
<name>Stefan Hajnoczi</name>
</author>
<published>2022-06-09T16:47:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=99b969fbe105117f5af6060d3afef40ca39cc9c1'/>
<id>urn:sha1:99b969fbe105117f5af6060d3afef40ca39cc9c1</id>
<content type='text'>
It may not be obvious why laio_io_unplug() checks max batch. I discussed
this with Stefano and have added a comment summarizing the reason.

Cc: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Cc: Kevin Wolf &lt;kwolf@redhat.com&gt;
Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
Reviewed-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Message-id: 20220609164712.1539045-3-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
</content>
</entry>
<entry>
<title>linux-aio: fix unbalanced plugged counter in laio_io_unplug()</title>
<updated>2022-06-15T15:43:42+00:00</updated>
<author>
<name>Stefan Hajnoczi</name>
</author>
<published>2022-06-09T16:47:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=f387cac5af030a58ac5a0dacf64cab5e5a4fe5c7'/>
<id>urn:sha1:f387cac5af030a58ac5a0dacf64cab5e5a4fe5c7</id>
<content type='text'>
Every laio_io_plug() call has a matching laio_io_unplug() call. There is
a plugged counter that tracks the number of levels of plugging and
allows for nesting.

The plugged counter must reflect the balance between laio_io_plug() and
laio_io_unplug() calls accurately. Otherwise I/O stalls occur since
io_submit(2) calls are skipped while plugged.

Reported-by: Nikolay Tenev &lt;nt@storpool.com&gt;
Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
Reviewed-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Message-id: 20220609164712.1539045-2-stefanha@redhat.com
Cc: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Fixes: 68d7946648 ("linux-aio: add `dev_max_batch` parameter to laio_io_unplug()")
[Stefano Garzarella suggested adding a Fixes tag.
--Stefan]
Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
</content>
</entry>
<entry>
<title>aio-posix: split poll check from ready handler</title>
<updated>2022-01-12T17:09:39+00:00</updated>
<author>
<name>Stefan Hajnoczi</name>
</author>
<published>2021-12-07T13:23:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=826cc32423db2a99d184dbf4f507c737d7e7a4ae'/>
<id>urn:sha1:826cc32423db2a99d184dbf4f507c737d7e7a4ae</id>
<content type='text'>
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 &lt;stefanha@redhat.com&gt;
Reviewed-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
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 &lt;stefanha@redhat.com&gt;
</content>
</entry>
<entry>
<title>linux-aio: add `dev_max_batch` parameter to laio_io_unplug()</title>
<updated>2021-11-02T12:03:35+00:00</updated>
<author>
<name>Stefano Garzarella</name>
</author>
<published>2021-10-26T16:23:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=68d7946648a5c364a4df187804d37f09a318b50f'/>
<id>urn:sha1:68d7946648a5c364a4df187804d37f09a318b50f</id>
<content type='text'>
Between the submission of a request and the unplug, other devices
with larger limits may have been queued new requests without flushing
the batch.

Using the new `dev_max_batch` parameter, laio_io_unplug() can check
if the batch exceeds the device limit to flush the current batch.

Reviewed-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
Reviewed-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
Signed-off-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Message-Id: &lt;20211026162346.253081-4-sgarzare@redhat.com&gt;
Signed-off-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
</content>
</entry>
<entry>
<title>linux-aio: add `dev_max_batch` parameter to laio_co_submit()</title>
<updated>2021-11-02T12:03:35+00:00</updated>
<author>
<name>Stefano Garzarella</name>
</author>
<published>2021-10-26T16:23:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=512da211010700cdbfaab45c8980ca88958a4ab8'/>
<id>urn:sha1:512da211010700cdbfaab45c8980ca88958a4ab8</id>
<content type='text'>
This new parameter can be used by block devices to limit the
Linux AIO batch size more than the limit set by the AIO context.

file-posix backend supports this, passing its `aio-max-batch` option
previously added.

Add an helper function to calculate the maximum batch size.

Reviewed-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
Reviewed-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
Signed-off-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Message-Id: &lt;20211026162346.253081-3-sgarzare@redhat.com&gt;
Signed-off-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
</content>
</entry>
<entry>
<title>linux-aio: limit the batch size using `aio-max-batch` parameter</title>
<updated>2021-07-21T12:47:50+00:00</updated>
<author>
<name>Stefano Garzarella</name>
</author>
<published>2021-07-21T09:42:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=d7ddd0a1618a75b31dc308bb37365ce1da972154'/>
<id>urn:sha1:d7ddd0a1618a75b31dc308bb37365ce1da972154</id>
<content type='text'>
When there are multiple queues attached to the same AIO context,
some requests may experience high latency, since in the worst case
the AIO engine queue is only flushed when it is full (MAX_EVENTS) or
there are no more queues plugged.

Commit 2558cb8dd4 ("linux-aio: increasing MAX_EVENTS to a larger
hardcoded value") changed MAX_EVENTS from 128 to 1024, to increase
the number of in-flight requests. But this change also increased
the potential maximum batch to 1024 elements.

When there is a single queue attached to the AIO context, the issue
is mitigated from laio_io_unplug() that will flush the queue every
time is invoked since there can't be others queue plugged.

Let's use the new `aio-max-batch` IOThread parameter to mitigate
this issue, limiting the number of requests in a batch.

We also define a default value (32): this value is obtained running
some benchmarks and it represents a good tradeoff between the latency
increase while a request is queued and the cost of the io_submit(2)
system call.

Signed-off-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Message-id: 20210721094211.69853-4-sgarzare@redhat.com
Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
</content>
</entry>
<entry>
<title>misc: Replace zero-length arrays with flexible array member (automatic)</title>
<updated>2020-03-16T21:07:42+00:00</updated>
<author>
<name>Philippe Mathieu-Daudé</name>
</author>
<published>2020-03-04T15:38:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=f7795e4096d8bd1c767c5ddb450fa859ff20490e'/>
<id>urn:sha1:f7795e4096d8bd1c767c5ddb450fa859ff20490e</id>
<content type='text'>
Description copied from Linux kernel commit from Gustavo A. R. Silva
(see [3]):

--v-- description start --v--

  The current codebase makes use of the zero-length array language
  extension to the C90 standard, but the preferred mechanism to
  declare variable-length types such as these ones is a flexible
  array member [1], introduced in C99:

  struct foo {
      int stuff;
      struct boo array[];
  };

  By making use of the mechanism above, we will get a compiler
  warning in case the flexible array does not occur last in the
  structure, which will help us prevent some kind of undefined
  behavior bugs from being unadvertenly introduced [2] to the
  Linux codebase from now on.

--^-- description end --^--

Do the similar housekeeping in the QEMU codebase (which uses
C99 since commit 7be41675f7cb).

All these instances of code were found with the help of the
following Coccinelle script:

  @@
  identifier s, m, a;
  type t, T;
  @@
   struct s {
      ...
      t m;
  -   T a[0];
  +   T a[];
  };
  @@
  identifier s, m, a;
  type t, T;
  @@
   struct s {
      ...
      t m;
  -   T a[0];
  +   T a[];
   } QEMU_PACKED;

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=76497732932f
[3] https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/commit/?id=17642a2fbd2c1

Inspired-by: Gustavo A. R. Silva &lt;gustavo@embeddedor.com&gt;
Reviewed-by: David Hildenbrand &lt;david@redhat.com&gt;
Signed-off-by: Philippe Mathieu-Daudé &lt;philmd@redhat.com&gt;
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
</content>
</entry>
<entry>
<title>linux-aio: increasing MAX_EVENTS to a larger hardcoded value</title>
<updated>2020-01-13T16:41:45+00:00</updated>
<author>
<name>Wangyong</name>
</author>
<published>2020-01-07T06:01:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=2558cb8dd4150512bc8ae6d505cdcd10d0cc46bb'/>
<id>urn:sha1:2558cb8dd4150512bc8ae6d505cdcd10d0cc46bb</id>
<content type='text'>
Since commit 6040aedddb5f474a9c2304b6a432a652d82b3d3c "virtio-blk:
make queue size configurable",if the user set the queue size to
more than 128 ,it will not take effect. That's because linux aio's
maximum outstanding requests at a time is always less than or equal
to 128.

This patch simply increase MAX_EVENTS to a larger hardcoded value of
1024 as a shortterm fix.

Signed-off-by: wangyong &lt;wang.yongD@h3c.com&gt;
Message-id: faa5781afd354a96a0be152b288f636f@h3c.com
Message-Id: &lt;faa5781afd354a96a0be152b288f636f@h3c.com&gt;
Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
</content>
</entry>
<entry>
<title>Include qemu-common.h exactly where needed</title>
<updated>2019-06-12T11:20:20+00:00</updated>
<author>
<name>Markus Armbruster</name>
</author>
<published>2019-05-23T14:35:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=a8d2532645cf5ce4f75981f81dfe363efc35d05c'/>
<id>urn:sha1:a8d2532645cf5ce4f75981f81dfe363efc35d05c</id>
<content type='text'>
No header includes qemu-common.h after this commit, as prescribed by
qemu-common.h's file comment.

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Message-Id: &lt;20190523143508.25387-5-armbru@redhat.com&gt;
[Rebased with conflicts resolved automatically, except for
include/hw/arm/xlnx-zynqmp.h hw/arm/nrf51_soc.c hw/arm/msf2-soc.c
block/qcow2-refcount.c block/qcow2-cluster.c block/qcow2-cache.c
target/arm/cpu.h target/lm32/cpu.h target/m68k/cpu.h target/mips/cpu.h
target/moxie/cpu.h target/nios2/cpu.h target/openrisc/cpu.h
target/riscv/cpu.h target/tilegx/cpu.h target/tricore/cpu.h
target/unicore32/cpu.h target/xtensa/cpu.h; bsd-user/main.c and
net/tap-bsd.c fixed up]
</content>
</entry>
</feed>
