All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: fio@vger.kernel.org, Vincent Fu <vincentfu@gmail.com>,
	Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 2/2] iolog: fix iolog_items_to_fetch()
Date: Wed,  2 Dec 2026 08:38:01 +0900	[thread overview]
Message-ID: <20261201233801.400379-3-dlemoal@kernel.org> (raw)
In-Reply-To: <20261201233801.400379-1-dlemoal@kernel.org>

When replaying an iolog with read_iolog_chunked=true, if the iolog
describes a workload ithat has very low IOPS intervals (IOPS < 1),
iolog_items_to_fetch() may return 0 due to the IOPS calculation it does
based on the last time the iolog file was read (td->io_log_highmark_time).
This causes read_iolog() to do nothing and the job to end, even if the
iolog file is not yet fully replayed.

Avoid this by returning the defualt 10 items (now defined as
IOLOG_DEFAULT_ITEMS_TO_FETCH) when the calculation leads to a value that
is 0 or less. When the iolog file is fully replayed, read_iolog() will
still do nothing and the job end normally after replaying the entire
iolog file.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 iolog.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/iolog.c b/iolog.c
index 54fb8283b766..824764bf34a6 100644
--- a/iolog.c
+++ b/iolog.c
@@ -418,6 +418,8 @@ void write_iolog_close(struct thread_data *td)
 	td->iolog_buf = NULL;
 }
 
+#define IOLOG_DEFAULT_ITEMS_TO_FETCH	10
+
 int64_t iolog_items_to_fetch(struct thread_data *td)
 {
 	struct timespec now;
@@ -426,18 +428,18 @@ int64_t iolog_items_to_fetch(struct thread_data *td)
 	int64_t items_to_fetch;
 
 	if (!td->io_log_highmark)
-		return 10;
-
+		return IOLOG_DEFAULT_ITEMS_TO_FETCH;
 
 	fio_gettime(&now, NULL);
 	elapsed = ntime_since(&td->io_log_highmark_time, &now);
 	if (elapsed) {
 		for_1s = (td->io_log_highmark - td->io_log_current) * 1000000000 / elapsed;
 		items_to_fetch = for_1s - td->io_log_current;
-		if (items_to_fetch < 0)
-			items_to_fetch = 0;
-	} else
+		if (items_to_fetch <= 0)
+			items_to_fetch = IOLOG_DEFAULT_ITEMS_TO_FETCH;
+	} else {
 		items_to_fetch = 0;
+	}
 
 	td->io_log_highmark = td->io_log_current + items_to_fetch;
 	td->io_log_checkmark = (td->io_log_highmark + 1) / 2;
-- 
2.56.1


  parent reply	other threads:[~2026-12-01 23:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 23:37 [PATCH 0/2] Cleanup and fix iolog replay Damien Le Moal
2026-12-01 23:38 ` [PATCH 1/2] iolog: refactor read_iolog() Damien Le Moal
2026-12-01 23:38 ` Damien Le Moal [this message]
2026-12-02  1:45   ` [PATCH 2/2] iolog: fix iolog_items_to_fetch() Vincent Fu

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=20261201233801.400379-3-dlemoal@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=fio@vger.kernel.org \
    --cc=vincentfu@gmail.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.