On Mon, Aug 31, 2026 at 03:52:04PM +0200, Hanna Czenczek wrote:
> I am not quite sure why `latency_ns` is overridden by a fixed value in
> qtest mode because personally, I find it much better if I can
> individually change requests' latency by modifying the qtest clock.

It looks like tests/qemu-iotests/136 relies on a hardcoded constant so
it can check min/max/avg against known values.

> 
> But I'm not going to change existing behavior for the histogram and
> such, so I will just move this override after the latency has been
> evaluated regarding a potential BLOCK_IO_DELAY event.

That's fine if you aren't taking the same testing approach as
tests/qemu-iotests/136. I think the benefit of hardcoding the value for
testing is that it would become possible to trigger the latency
threshold without worrying about timing in the test environment.

> 
> Signed-off-by: Hanna Czenczek <[email protected]>
> ---
>  block/accounting.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/block/accounting.c b/block/accounting.c
> index debf1924455..223becd2e04 100644
> --- a/block/accounting.c
> +++ b/block/accounting.c
> @@ -271,10 +271,6 @@ static void block_account_one_io(BlockAcctStats *stats, 
> BlockAcctCookie *cookie,
>      int64_t time_ns = qemu_clock_get_ns(clock_type);
>      int64_t latency_ns = time_ns - cookie->start_time_ns;
>  
> -    if (qtest_enabled()) {
> -        latency_ns = qtest_latency_ns;
> -    }
> -
>      assert(cookie->type < BLOCK_MAX_IOTYPE);
>  
>      if (cookie->type == BLOCK_ACCT_NONE) {
> @@ -292,6 +288,10 @@ static void block_account_one_io(BlockAcctStats *stats, 
> BlockAcctCookie *cookie,
>                                         cookie->bytes);
>      }
>  
> +    if (qtest_enabled()) {
> +        latency_ns = qtest_latency_ns;
> +    }
> +
>      WITH_QEMU_LOCK_GUARD(&stats->lock) {
>          if (failed) {
>              stats->failed_ops[cookie->type]++;
> -- 
> 2.55.0
> 

Attachment: signature.asc
Description: PGP signature

Reply via email to