All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@pond.sub.org>
To: Hanna Czenczek <hreitz@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>,
	 qemu-block@nongnu.org, qemu-devel@nongnu.org,
	 Kevin Wolf <kwolf@redhat.com>,  John Snow <jsnow@redhat.com>,
	 "Denis V . Lunev" <den@openvz.org>,
	 Eric Blake <eblake@redhat.com>,
	 Stefan Hajnoczi <stefanha@redhat.com>,
	 Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v2 07/12] qapi/block: Add BLOCK_IO_DONE event
Date: Wed, 02 Dec 2026 10:24:24 +0100	[thread overview]
Message-ID: <87ik1cdohj.fsf@pond.sub.org> (raw)
In-Reply-To: <5464dd6a-d7fe-4b1e-a284-9f18c263ba3a@redhat.com> (Hanna Czenczek's message of "Tue, 1 Dec 2026 15:19:45 +0100")

Hanna Czenczek <hreitz@redhat.com> writes:

> On 26.10.26 07:40, Markus Armbruster wrote:
>> Hanna Czenczek <hreitz@redhat.com> writes:
>>
>>> On 23.10.26 08:18, Markus Armbruster wrote:
>>>> Hanna Czenczek <hreitz@redhat.com> writes:
>>>>
>>>>> On 20.10.26 08:55, Markus Armbruster wrote:
>>>>>> Hanna Czenczek <hreitz@redhat.com> writes:
>>>>>>
>>>>>>> This event is emitted when an operation completes, for which a
>>>>>>> BLOCK_IO_DELAY event has previously been emitted.
>>>>>>>
>>>>>>> Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
>>>>>>> ---
>>>>>>>     qapi/block.json | 33 +++++++++++++++++++++++++++++++++
>>>>>>>     1 file changed, 33 insertions(+)
>>>>>>>
>>>>>>> diff --git a/qapi/block.json b/qapi/block.json
>>>>>>> index 5f9f5c28050..38f293dd32d 100644
>>>>>>> --- a/qapi/block.json
>>>>>>> +++ b/qapi/block.json
>> [...]
>>
>>>>>>> @@ -686,3 +689,33 @@
>>>>>>>         'action': 'BlockErrorAction',
>>>>>>>         '*offset': 'uint64',
>>>>>>>         'bytes': 'uint64' } }
>>>>>>> +
>>>>>>> +##
>>>>>>> +# @BLOCK_IO_DONE:
>>>>>>> +#
>>>>>>> +# Emitted on completion for disk operations that previously emitted a
>>>>>>> +# `BLOCK_IO_DELAY` event.
>>>>>>
>>>>>> Can we have multiple operations in flight that previously emitted
>>>>>> BLOCK_IO_DELAY?
>>>>>>
>>>>>> If yes, might a management application need to connect the BLOCK_IO_DONE
>>>>>> back to the BLOCK_IO_DELAY?
>>>>>>
>>>>>> If yes, how could it do that?
>>>>>
>>>>> Well, the combination of device, operation, offset, bytes.
>>>>>
>>>>> Do you think there should be an ID like a u64 counter per
>>>>> BlockBackend?
>>>>
>>>> I'm not overly particular on how exactly the connection can be made.  If
>>>> the quadruple you suggested always suffices, that's good enough for me.
>>>> Documentation should point it out, though.
>>>>
>>>> Can multiple operations with the same (device, operation, offset, bytes)
>>>> be in flight?
>>>
>>> Technically, sure.
>>>
>>> Adding an ID is quite ugly, I feel like, which is why I would need your input in how it would be least intrusive in QAPI.
>>
>> First step is to get a clearer idea on what exactly management
>> applications need here.
>
> I see two use cases:
> 1. To find when it is OK to resume the VM after auto-stop. That, I assumed, would require correlating DELAY action=stop events with their DONE events.

Let's see whether I understand.

Certain guests handle very slow I/O in undesirable ways.  We want to let
management applications hide such I/O from them, as follows.

The management application uses block device model property
"delay-stop-ns" [PATCH 11] to stop the VM when an I/O operation takes
too long for this guest.

When this happens, event BLOCK_IO_DELAY is emitted, and the VM stops if
it isn't stopped already.

The I/O operation eventually completes, and event BLOCK_IO_DONE is
emitted.

The management application wants to resume the VM only when all
outstanding slow I/O operations completed, i.e. when it received a
BLOCK_IO_DONE for each prior BLOCK_IO_DELAY.

Correct?

If yes, counting the events might suffice here.

> 2. Accounting, in general. One hard case: See what delayed requests are in flight, mark them off.

But counting is useless here.

> The first we could instead just solve by adding an `action` field to DONE events that shows `report` when the request was only reported at `action=report` level; and `stop` when, at any point, it was reported at `action=stop` level (i.e. causing the VM to stop if not already stopped). Then the client can count how many `action=stop` DELAY events happened, against the resolving `action=stop` DONE events, and resume the VM when the counts are equal.

Yes, you need a way to tell whether a BLOCK_IO_DONE matches a
BLOCK_IO_DELAY with action "stop" to make the counting work.

> (This would go well with requiring that `delay-stop-ns > delay-report-ns`, so that this will also always be the same `action` value as in the last DELAY event.)

If property "delay-report-ns" is set in addition to "delay-stop-ns":

1. Neither threshold is passed: no events.

2. Only delay-stop-ns is passed: BLOCK_IO_DELAY with action "report",
   BLOCK_IO_DONE.

3. delay-report-ns is passed, and then delay-stop-ns, too:
   BLOCK_IO_DELAY with action "report", BLOCK_IO_DELAY with action
   "stop", BLOCK_IO_DONE.

4. Two BLOCK_IO_DELAY events in the other order is not supposed to
   happen.

> The second, just reporting delays (which is the use case requested), we don’t need correlation. But if we want to allow a list of what delayed requests are actually in flight, including their start time (can be derived from the DELAY event time minus the reported duration), then that would require an ID so between two requests that look the same (e.g. two flushes), you can still scratch off the right one. But, first of all, if someone ever does need that, we could add this ID then in a compatible manner, and, second, we probably just should not require clients to keep this state, because:
>
> I am not sure whether such “stateful” events are even a good idea, on their own, or whether we need a query command that can list all delayed and not-yet-done requests. For example, when you reconnect a client, the counting up of events laid out above will not work, as it is unclear how many in-flight requests there are that hit `action=stop` DELAY. And this could also supersede the ID requirement for “see what delayed requests are in flight”, and also give an alternative to counting up the DELAY vs. DONE events to consider resuming.

Management applications can miss events, say because the QMP connection
temporarily drops.  They commonly want a way to recover from missing
events.  That's why events commonly come with a matching query command.

> (Small problem: If a request finishes simultaneously to querying, it could be missing from the list, but the DONE event only comes later. That would lead to undercounting for the “count DELAY - DONE” strategy. So that strategy really can only be used for counting up *events*, not the result from that list.)
>
> So I would lean towards (for now):
> 1. Adding `action` field to DONE (and document that counting up `action=stop` DELAY vs. DONE *events* may be used to ensure there are no more requests in flight that have been delayed to the `action=stop` point),
> 2. Requiring `delay-stop-ns > delay-report-ns` (If both are given. Either would remain optional.),
> 3. Probably also makes sense to document that DELAY and DONE are not rate-limited, to ensure they will not be,
> 4. Adding a query command to list all in-flight requests that reported delay.

Feels reasonable.

I think we want some guidance for management applications on how to use
this feature.  Not necessarily in QAPI schema doc comments.

[...]


  reply	other threads:[~2026-12-02  9:25 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-22 13:54     ` Hanna Czenczek
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-22 15:48     ` Hanna Czenczek
2026-10-23  6:04       ` Markus Armbruster
2026-10-23 14:30         ` Hanna Czenczek
2026-10-26  6:24           ` 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-22 15:55     ` Hanna Czenczek
2026-10-23  6:14       ` Markus Armbruster
2026-10-23 14:33         ` Hanna Czenczek
2026-10-26  6:28           ` 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-22 15:59     ` Hanna Czenczek
2026-10-23  6:18       ` Markus Armbruster
2026-10-23 14:38         ` Hanna Czenczek
2026-10-26  6:40           ` Markus Armbruster
2026-12-01 14:19             ` Hanna Czenczek
2026-12-02  9:24               ` Markus Armbruster [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ik1cdohj.fsf@pond.sub.org \
    --to=armbru@pond.sub.org \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.