All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/12] block: BLOCK_IO_DELAY event
@ 2026-10-19 18:20 Hanna Czenczek
  2026-10-19 18:20 ` [PATCH v2 01/12] qapi/common: Clarify what IoOperationType is for Hanna Czenczek
                   ` (11 more replies)
  0 siblings, 12 replies; 18+ messages in thread
From: Hanna Czenczek @ 2026-10-19 18:20 UTC (permalink / raw)
  To: qemu-block
  Cc: qemu-devel, Hanna Czenczek, Kevin Wolf, John Snow,
	Denis V . Lunev, Eric Blake, Markus Armbruster, Stefan Hajnoczi,
	Paolo Bonzini

Hi,

v1: https://lists.nongnu.org/archive/html/qemu-block/2026-08/msg00701.html

I’m told there are installations where storage is very slow, and some
would like the VM stack to report this proactively.  To do so, we should
(via QAPI events) report on extremely slow I/O requests.

We already have the latency histogram, but this is not deemed sufficient
because it is not proactively reporting and would require repeated
querying.  Therefore, this series introduces the event still.

In contrast to v1, this version adds the delay tracking to the
BlockBackend request code instead of using the existing cookies from
block/accounting.c.

As explained in the v1 cover letter, in order to be able to raise a
BLOCK_IO_DELAY event exactly when a request crosses the threshold, we
need to keep requests in a list, which requires trivially verifiable
resource management, i.e. trivially being able to see that every request
that is begun being tracked (and thus put into that list) is also
removed from that list once the request is done.  This was not possible
with the accounting cookies, so instead, as suggested by Stefan, this
version adds its own tracking directly into the BB-level requests.

The downside is that accounting and delay tracking thus track different
kinds of requests.  If that is unacceptable, the only alternatives would
be:
- To do it with cookies, which is basically impossible, as explained,
- To change the cookies to be tied to BB-level requests as well, which
  would (A) be an invasive code change, and (B) change the existing
  reporting in an incompatible way.

Personally, I found the divergence to be more acceptable than having a
go at said invasive change, and having to defend the incompatible
reporting change.


In addition to what v1 provides, with this threshold-level reporting, we
can now also have the VM stop on exceedingly delayed requests, so the
guest would not see that delay, as a last-ditch effort for guests that
find extreme latencies to be catastrophic.  (Which is to say Windows
does that: It throws a BSOD when exceeding a certain maximum latency.)


Note patches 3 and 4 that might not really fully fit into this series;
they fix a pre-existing bug around the runstate transitions between
IO_ERROR and SUSPENDED.  An AI review tool informed me that the
transition between SUSPENDED and IO_HANG was missing in patch 5, but
given that I had just copied what IO_ERROR does, I felt bad adding that
transition for IO_HANG, but leaving IO_ERROR as it was.


git-backport-diff against v1 is not so useful here, I’m afraid:

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch
[down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/12:[down] 'qapi/common: Clarify what IoOperationType is for'
002/12:[0004] [FC] 'qapi/block: Add IoAccountingOperation enum'
003/12:[down] 'runstate: Allow IO_ERROR/SUSPENDED transitions'
004/12:[down] 'iotests: PC-only test for I/O errors during suspend'
005/12:[down] 'qapi/run-state: Add io-hang state'
006/12:[0017] [FC] 'qapi/block: Add BLOCK_IO_DELAY event'
007/12:[down] 'qapi/block: Add BLOCK_IO_DONE event'
008/12:[----] [--] 'block-backend: Public blk_get_attached_dev_path()'
009/12:[down] 'host-utils: Add u{add,sub}{32,64}_saturate()'
010/12:[down] 'block: Per-request delay tracker'
011/12:[down] 'block: Add delay-report-ns and delay-stop-ns props'
012/12:[down] 'iotests: Add io-delay-reporting test'


Hanna Czenczek (12):
  qapi/common: Clarify what IoOperationType is for
  qapi/block: Add IoAccountingOperation enum
  runstate: Allow IO_ERROR/SUSPENDED transitions
  iotests: PC-only test for I/O errors during suspend
  qapi/run-state: Add io-hang state
  qapi/block: Add BLOCK_IO_DELAY event
  qapi/block: Add BLOCK_IO_DONE event
  block-backend: Public blk_get_attached_dev_path()
  host-utils: Add u{add,sub}{32,64}_saturate()
  block: Per-request delay tracker
  block: Add delay-report-ns and delay-stop-ns props
  iotests: Add io-delay-reporting test

 qapi/block.json                               |  90 +++++
 qapi/common.json                              |   5 +-
 qapi/run-state.json                           |   7 +-
 include/block/block-backend-delay.h           | 112 ++++++
 include/hw/block/block.h                      |   8 +-
 include/qemu/host-utils.h                     |  62 ++++
 include/system/block-backend-global-state.h   |  11 +
 include/system/block-backend-io.h             |   9 +
 block/block-backend-delay.c                   | 326 ++++++++++++++++++
 block/block-backend.c                         |  50 ++-
 blockdev.c                                    |  16 +
 hw/block/block.c                              |   7 +
 system/runstate.c                             |  27 +-
 block/meson.build                             |   1 +
 tests/qemu-iotests/172.out                    |  76 ++++
 tests/qemu-iotests/tests/io-delay-reporting   | 187 ++++++++++
 .../qemu-iotests/tests/io-delay-reporting.out |  90 +++++
 .../tests/io-error-during-suspend             | 155 +++++++++
 .../tests/io-error-during-suspend.out         |  22 ++
 19 files changed, 1244 insertions(+), 17 deletions(-)
 create mode 100644 include/block/block-backend-delay.h
 create mode 100644 block/block-backend-delay.c
 create mode 100755 tests/qemu-iotests/tests/io-delay-reporting
 create mode 100644 tests/qemu-iotests/tests/io-delay-reporting.out
 create mode 100755 tests/qemu-iotests/tests/io-error-during-suspend
 create mode 100644 tests/qemu-iotests/tests/io-error-during-suspend.out

-- 
2.55.0



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-10-20  6:56 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 18:20 [PATCH v2 00/12] block: BLOCK_IO_DELAY event Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 01/12] qapi/common: Clarify what IoOperationType is for Hanna Czenczek
2026-10-20  5:58   ` Markus Armbruster
2026-10-19 18:20 ` [PATCH v2 02/12] qapi/block: Add IoAccountingOperation enum Hanna Czenczek
2026-10-20  5:59   ` Markus Armbruster
2026-10-19 18:20 ` [PATCH v2 03/12] runstate: Allow IO_ERROR/SUSPENDED transitions Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 04/12] iotests: PC-only test for I/O errors during suspend Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 05/12] qapi/run-state: Add io-hang state Hanna Czenczek
2026-10-20  6:02   ` Markus Armbruster
2026-10-19 18:20 ` [PATCH v2 06/12] qapi/block: Add BLOCK_IO_DELAY event Hanna Czenczek
2026-10-20  6:49   ` Markus Armbruster
2026-10-19 18:20 ` [PATCH v2 07/12] qapi/block: Add BLOCK_IO_DONE event Hanna Czenczek
2026-10-20  6:55   ` Markus Armbruster
2026-10-19 18:20 ` [PATCH v2 08/12] block-backend: Public blk_get_attached_dev_path() Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 09/12] host-utils: Add u{add,sub}{32,64}_saturate() Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 10/12] block: Per-request delay tracker Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 11/12] block: Add delay-report-ns and delay-stop-ns props Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 12/12] iotests: Add io-delay-reporting test Hanna Czenczek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.