Skip to content

block: BLOCK_IO_DELAY event

Hanna Czenczek qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest12 patches 18 repliesIn review
  2. v19 patches 37 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12qapi/common: Clarify what IoOperationType is forqapi/common.json+4 -12 replies
2/12qapi/block: Add IoAccountingOperation enumqapi/block.json+20 -05 replies
3/12runstate: Allow IO_ERROR/SUSPENDED transitionssystem/runstate.c+2 -00 replies
4/12iotests: PC-only test for I/O errors during suspendtests/qemu-iotests/tests/io-error-during-suspend tests/qemu-iotests/tests/io-error-during-suspend.out+177 -00 replies
5/12qapi/run-state: Add io-hang stateqapi/run-state.json system/runstate.c+24 -81 reply
6/12qapi/block: Add BLOCK_IO_DELAY eventqapi/block.json+37 -05 replies
7/12qapi/block: Add BLOCK_IO_DONE eventqapi/block.json+33 -05 replies
8/12block-backend: Public blk_get_attached_dev_path()block/block-backend.c include/system/block-backend-io.h+10 -50 replies
9/12host-utils: Add u{add,sub}{32,64}_saturate()include/qemu/host-utils.h+62 -00 replies
10/12block: Per-request delay trackerblock/block-backend-delay.c block/block-backend.c block/meson.build +2 more+492 -20 replies
11/12block: Add delay-report-ns and delay-stop-ns propsblockdev.c hw/block/block.c include/hw/block/block.h +1 more+106 -10 replies
12/12iotests: Add io-delay-reporting testtests/qemu-iotests/tests/io-delay-reporting tests/qemu-iotests/tests/io-delay-reporting.out+277 -00 replies

Reviews trailers per patch

1 of 12 patches has a Reviewed-by or Acked-by.

PatchMarkus Armbruster
1/12
2/12
3/12
4/12
5/12A-b
6/12
7/12
8/12
9/12
10/12
11/12
12/12

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/12] block: BLOCK_IO_DELAY event

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
Signature · 1 line
2.55.0