From 48097d5c61aa1718e6dd4b3b647ea2eb6f00fcfb Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Sat, 17 Feb 2007 06:30:44 +0100 Subject: [PATCH] [PATCH] Add thinktime_spin parameter If you specify thinktime currently, fio will sleep for the duration. Apps will typically do some data processing before sleeping, so add a thinktime_spin parameter to control how much CPU to burn before sleeping. Signed-off-by: Jens Axboe --- HOWTO | 9 ++++++++- fio.c | 12 ++++++++++-- fio.h | 1 + init.c | 13 +++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/HOWTO b/HOWTO index f61b4c1d..8e6e29bb 100644 --- a/HOWTO +++ b/HOWTO @@ -343,7 +343,14 @@ prioclass=int Set the io priority class. See man ionice(1). thinktime=int Stall the job x microseconds after an io has completed before issuing the next. May be used to simulate processing being - done by an application. See thinktime_blocks. + done by an application. See thinktime_blocks and + thinktime_spin. + +thinktime_spin=int + Only valid if thinktime is set - pretend to spend CPU time + doing something with the data received, before falling back + to sleeping for the rest of the period specified by + thinktime. thinktime_blocks Only valid if thinktime is set - control how many blocks diff --git a/fio.c b/fio.c index 78dca9a0..ff169f86 100644 --- a/fio.c +++ b/fio.c @@ -466,8 +466,16 @@ requeue: unsigned long long b; b = td->io_blocks[0] + td->io_blocks[1]; - if (!(b % td->thinktime_blocks)) - usec_sleep(td, td->thinktime); + if (!(b % td->thinktime_blocks)) { + int left; + + if (td->thinktime_spin) + __usec_sleep(td->thinktime_spin); + + left = td->thinktime - td->thinktime_spin; + if (left) + usec_sleep(td, left); + } } } diff --git a/fio.h b/fio.h index 67cc0652..934d897f 100644 --- a/fio.h +++ b/fio.h @@ -274,6 +274,7 @@ struct thread_data { unsigned int hugepage_size; unsigned int rw_min_bs; unsigned int thinktime; + unsigned int thinktime_spin; unsigned int thinktime_blocks; unsigned int fsync_blocks; unsigned int start_delay; diff --git a/init.c b/init.c index 1dec2bbd..9e7fb2c0 100644 --- a/init.c +++ b/init.c @@ -330,6 +330,13 @@ static struct fio_option options[] = { .help = "Idle time between IO buffers (usec)", .def = "0", }, + { + .name = "thinktime_spin", + .type = FIO_OPT_INT, + .off1 = td_var_offset(thinktime_spin), + .help = "Start thinktime by spinning this amount (usec)", + .def = "0", + }, { .name = "thinktime_blocks", .type = FIO_OPT_INT, @@ -631,6 +638,12 @@ static void fixup_options(struct thread_data *td) */ if (td->filetype == FIO_TYPE_CHAR && td->odirect) td->odirect = 0; + + /* + * thinktime_spin must be less than thinktime + */ + if (td->thinktime_spin > td->thinktime) + td->thinktime_spin = td->thinktime; } /* -- 2.25.1