X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Fcpu.c;h=14ad9717aa5fbd024a7e9f286a36fd79542c6365;hp=6ad547b60ad597cf2e06c27c08e05960692914ef;hb=67f5b27ed25e87102455e9a49eadabb00e873b0e;hpb=e1161c325f7866bae879e686d1c673ca32ab09ae diff --git a/engines/cpu.c b/engines/cpu.c index 6ad547b6..14ad9717 100644 --- a/engines/cpu.c +++ b/engines/cpu.c @@ -1,30 +1,54 @@ +/* + * CPU engine + * + * Doesn't transfer any data, merely burns CPU cycles according to + * the settings. + * + */ #include "../fio.h" -#include "../os.h" -static int fio_cpuio_setup(struct thread_data fio_unused *td) +static int fio_cpuio_queue(struct thread_data *td, struct io_u fio_unused *io_u) { - return 0; + __usec_sleep(td->o.cpucycle); + return FIO_Q_COMPLETED; } static int fio_cpuio_init(struct thread_data *td) { - if (!td->cpuload) { - td_vmsg(td, EINVAL, "cpu thread needs rate", "cpu_load"); + struct thread_options *o = &td->o; + + if (!o->cpuload) { + td_vmsg(td, EINVAL, "cpu thread needs rate (cpuload=)","cpuio"); return 1; - } else if (td->cpuload > 100) - td->cpuload = 100; + } - td->nr_files = 0; + if (o->cpuload > 100) + o->cpuload = 100; + /* + * set thinktime_sleep and thinktime_spin appropriately + */ + o->thinktime_blocks = 1; + o->thinktime_spin = 0; + o->thinktime = (o->cpucycle * (100 - o->cpuload)) / o->cpuload; + + o->nr_files = o->open_files = 1; + return 0; +} + +static int fio_cpuio_open(struct thread_data fio_unused *td, + struct fio_file fio_unused *f) +{ return 0; } static struct ioengine_ops ioengine = { .name = "cpuio", .version = FIO_IOOPS_VERSION, + .queue = fio_cpuio_queue, .init = fio_cpuio_init, - .setup = fio_cpuio_setup, - .flags = FIO_CPUIO | FIO_NULLIO, + .open_file = fio_cpuio_open, + .flags = FIO_SYNCIO | FIO_DISKLESSIO, }; static void fio_init fio_cpuio_register(void)