X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Fcpu.c;h=b6f9075d365be76fe944a33101cf6eff3b195b88;hp=27ec6da1f261575bdd98999cacb81184e2c78d77;hb=af52b3455ad892322aab2791282b6bd4efdfdbf3;hpb=4d9345ae968ca92ace3dab06c25a9b73159cb329 diff --git a/engines/cpu.c b/engines/cpu.c index 27ec6da1..b6f9075d 100644 --- a/engines/cpu.c +++ b/engines/cpu.c @@ -1,30 +1,64 @@ #include "../fio.h" #include "../os.h" +static int fio_cpuio_queue(struct thread_data *td, struct io_u fio_unused *io_u) +{ + __usec_sleep(td->cpucycle); + return FIO_Q_COMPLETED; +} + static int fio_cpuio_setup(struct thread_data fio_unused *td) { + struct fio_file *f; + unsigned int i; + + td->total_file_size = -1; + td->io_size = td->total_file_size; + td->total_io_size = td->io_size; + + for_each_file(td, f, i) { + f->real_file_size = -1; + f->file_size = -1; + } + return 0; } static int fio_cpuio_init(struct thread_data *td) { if (!td->cpuload) { - td_vmsg(td, EINVAL, "cpu thread needs rate"); + td_vmsg(td, EINVAL, "cpu thread needs rate (cpuload=)","cpuio"); return 1; - } else if (td->cpuload > 100) + } + + if (td->cpuload > 100) td->cpuload = 100; - td->nr_files = 0; + /* + * set thinktime_sleep and thinktime_spin appropriately + */ + td->thinktime_blocks = 1; + td->thinktime_spin = 0; + td->thinktime = (td->cpucycle * (100 - td->cpuload)) / td->cpuload; + td->nr_files = td->open_files = 1; + return 0; +} + +static int fio_cpuio_open(struct thread_data fio_unused *td, struct fio_file *f) +{ + f->fd = 0; 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)