thinktime: Fix missing re-init thinktime when using ramptime
authorsuho.son <suho.son@samsung.com>
Fri, 31 Mar 2023 07:10:09 +0000 (16:10 +0900)
committersuho.son <suho.son@samsung.com>
Fri, 31 Mar 2023 07:10:09 +0000 (16:10 +0900)
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 <suho.son@samsung.com>

fio.h
libfio.c

diff --git a/fio.h b/fio.h
index 325355174bd37c1134bb3d492a3f4aecee5e10c7..7e90175af8d1e1fbcdf65b4dc220857f19bed128 100644 (file)
--- 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
index a52014ce6bd3afebcf8e5bc4adecea1fcc0794cd..ddd49cd76da2e6062cbd4c0a246fe603f5d75cde 100644 (file)
--- 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();