From cfc4ad2ec90e98cc92f8ec911f6ae04e11cf2ba4 Mon Sep 17 00:00:00 2001 From: "suho.son" Date: Fri, 31 Mar 2023 16:10:09 +0900 Subject: [PATCH] thinktime: Fix missing re-init thinktime when using ramptime Prevent I/O bursts after ramptime due to thinktime. Each thread generates a certain amount of I/O requests, configured by thinktime_blocks. When ramptime ends, thinktime_blocks can't control I/O. Because thinktime_blocks are not reinitialized after ramptime. I fixed it by reinitializing last_thinktime and last_thinktime_blocks when ramptime ended. Signed-off by: Suho Son --- fio.h | 2 +- libfio.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fio.h b/fio.h index 32535517..7e90175a 100644 --- a/fio.h +++ b/fio.h @@ -376,7 +376,7 @@ struct thread_data { uint64_t *thinktime_blocks_counter; struct timespec last_thinktime; - uint64_t last_thinktime_blocks; + int64_t last_thinktime_blocks; /* * State for random io, a bitmap of blocks done vs not done diff --git a/libfio.c b/libfio.c index a52014ce..ddd49cd7 100644 --- a/libfio.c +++ b/libfio.c @@ -131,10 +131,14 @@ void clear_io_state(struct thread_data *td, int all) void reset_all_stats(struct thread_data *td) { + unsigned long long b; int i; reset_io_counters(td, 1); + b = ddir_rw_sum(td->thinktime_blocks_counter); + td->last_thinktime_blocks -= b; + for (i = 0; i < DDIR_RWDIR_CNT; i++) { td->io_bytes[i] = 0; td->io_blocks[i] = 0; @@ -149,6 +153,8 @@ void reset_all_stats(struct thread_data *td) memcpy(&td->bw_sample_time, &td->epoch, sizeof(td->epoch)); memcpy(&td->ss.prev_time, &td->epoch, sizeof(td->epoch)); + td->last_thinktime = td->epoch; + lat_target_reset(td); clear_rusage_stat(td); helper_reset(); -- 2.25.1