From: Hanna Czenczek <hreitz@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: 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>,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH 6/9] block/accounting: Emit BLOCK_IO_DELAY event
Date: Wed, 23 Sep 2026 12:45:47 +0200 [thread overview]
Message-ID: <d4f10160-a355-4232-9f72-eda0c6a0148d@redhat.com> (raw)
In-Reply-To: <20260921204850.GE115897@fedora>
On 21.09.26 22:48, Stefan Hajnoczi wrote:
> On Wed, Sep 16, 2026 at 02:04:58PM +0200, Hanna Czenczek wrote:
>> On 16.09.26 10:14, Hanna Czenczek wrote:
>>> On 03.09.26 16:23, Stefan Hajnoczi wrote:
>>>> On Mon, Aug 31, 2026 at 03:52:02PM +0200, Hanna Czenczek wrote:
>>>>> When a request finishes with a higher latency than a predefined
>>>>> threshold, emit the BLOCK_IO_DELAY event.
>>>>>
>>>>> Note there would be an alternative, more precise solution: We
>>>>> could keep
>>>>> all active cookies per BlockBackend in a list and repeatedly iterate
>>>>> over it in a background coroutine (woken on a timer so it would wake
>>>>> always exactly when the next request would time out, so it generally
>>>>> stays asleep until there is actually a timeout). This way, we
>>>>> could emit
>>>>> the event exactly when a request crosses the delay threshold, while it
>>>>> is still running; and we could hypothetically even take actions like
>>>>> pausing the VM until the request is done so the guest operating system
>>>>> is shielded from extreme latency spikes.
>>>>>
>>>>> In practice, this is very complicated because latency cookies are
>>>>> created and finalized all over the place, so it is very hard to
>>>>> guarantee that every `block_acct_start()` is matched by the right
>>>>> finalization to ensure that cookies are properly removed from the list
>>>>> when they are done. Even if we fix all non-matching places now,
>>>>> there is
>>>>> hardly a guarantee this will be kept in order in the future.
>>>> I think this patch series already couples the accounting so closely with
>>>> BlockBackend (i.e. adding the offset field into the cookie struct and
>>>> adding a BB pointer into the stats struct) that we might as well fully
>>>> integrate the two. Then callers don't need to manually manage cookies
>>>> because BlockBackend does that internally and the concerns about
>>>> lifetimes go away.
>>> I don’t follow how integrating them into BlockBackend automatically
>>> solves the problem.
>>>
>>> Are you suggesting that blk_* I/O functions should do the accounting
>>> instead of the device emulation code?
> Yes.
OK, I see.
>> The thing is, AFAIU, doing that would cause changes in behavior, because the
>> hardware device requests don’t always line up with the BB requests.
> Did you find a fundamental incompatibility that rules out letting the
> block layer handles stats for blk_aio_*()?
I mean, a simple thing is that reset requests are currently just not
accounted, but they would be accounted then. Or repeated requests after
VM stop/cont.
There is also the fact that rerror/werror set to IGNORE means errors are
currently accounted as 'done', not 'failed'. That makes… a little sense
in the device models, but not really much sense in BB, I feel like.
So I am not sure what you mean by “fundamental incompatibility”. I’m
sure if we make it sufficiently ugly, we could reproduce all current
peculiarities. We could use the chance to make it cleaner, but that
would change the interface, and “cleaner” is always in the eye of the
beholder. (Besides the fact that I feel like you are trying to have me
open a can of worms, I feel like. :) )
>> What I could do would be to abandon the cookie-based approach altogether, of
>> course; instead creating a completely different tracking object in those BB
>> functions and put those into a list. And then we could decide at a later
>> point if we want to integrate cookies with that. The only downside I see is
>> that this would mean the latency reporting would not line up with the
>> requests reported in the stats, or the histogram.
> The tracking object could be a timer! :)
The problem is not timer or sleep, the problem is the lifecycle.
Hanna
next prev parent reply other threads:[~2026-09-23 10:46 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 13:51 [PATCH 0/9] block: BLOCK_IO_DELAY event Hanna Czenczek
2026-08-31 13:51 ` [PATCH 1/9] block/accounting: Add offset to BlockAcctCookie Hanna Czenczek
2026-09-07 10:05 ` Jesper Wendel Devantier
2026-08-31 13:51 ` [PATCH 2/9] qapi/block: Add IoAccountingOperation enum Hanna Czenczek
2026-09-03 14:32 ` Markus Armbruster
2026-09-16 8:09 ` Hanna Czenczek
2026-08-31 13:51 ` [PATCH 3/9] qapi/block: Add BLOCK_IO_DELAY event Hanna Czenczek
2026-09-03 14:36 ` Markus Armbruster
2026-09-16 8:08 ` Hanna Czenczek
2026-09-16 9:57 ` Markus Armbruster
2026-08-31 13:52 ` [PATCH 4/9] block-backend: Public blk_get_attached_dev_path() Hanna Czenczek
2026-08-31 13:52 ` [PATCH 5/9] block/accounting: Add BB field to latency checker Hanna Czenczek
2026-09-22 12:14 ` Kevin Wolf
2026-09-23 11:05 ` Hanna Czenczek
2026-08-31 13:52 ` [PATCH 6/9] block/accounting: Emit BLOCK_IO_DELAY event Hanna Czenczek
2026-09-03 14:23 ` Stefan Hajnoczi
2026-09-16 8:14 ` Hanna Czenczek
2026-09-16 12:04 ` Hanna Czenczek
2026-09-21 20:48 ` Stefan Hajnoczi
2026-09-23 10:45 ` Hanna Czenczek [this message]
2026-09-22 12:44 ` Kevin Wolf
2026-09-23 11:11 ` Hanna Czenczek
2026-08-31 13:52 ` [PATCH 7/9] block: Add delay-alert-ms property Hanna Czenczek
2026-09-03 14:30 ` Stefan Hajnoczi
2026-09-16 8:17 ` Hanna Czenczek
2026-09-22 12:51 ` Kevin Wolf
2026-08-31 13:52 ` [PATCH 8/9] block/accounting: Move latency_ns override down Hanna Czenczek
2026-09-03 15:08 ` Stefan Hajnoczi
2026-09-16 8:21 ` Hanna Czenczek
2026-09-21 20:42 ` Stefan Hajnoczi
2026-09-22 13:03 ` Kevin Wolf
2026-09-22 13:44 ` Alberto Garcia
2026-09-22 13:52 ` Kevin Wolf
2026-09-23 10:50 ` Hanna Czenczek
2026-08-31 13:52 ` [PATCH 9/9] iotests: Add delay-alert test Hanna Czenczek
2026-09-03 15:16 ` Stefan Hajnoczi
2026-09-03 14:08 ` [PATCH 0/9] block: BLOCK_IO_DELAY event Stefan Hajnoczi
2026-09-16 8:04 ` Hanna Czenczek
2026-09-21 20:41 ` Stefan Hajnoczi
2026-09-22 13:31 ` Kevin Wolf
2026-09-22 17:18 ` Stefan Hajnoczi
2026-09-23 10:52 ` Hanna Czenczek
2026-09-24 14:51 ` Stefan Hajnoczi
2026-09-23 10:48 ` Hanna Czenczek
2026-09-23 14:50 ` Kevin Wolf
2026-09-24 15:17 ` Stefan Hajnoczi
2026-09-24 18:31 ` Kevin Wolf
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=d4f10160-a355-4232-9f72-eda0c6a0148d@redhat.com \
--to=hreitz@redhat.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@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.