4 * Doesn't transfer any data, merely burns CPU cycles according to
11 struct thread_data *td;
13 unsigned int cpucycle;
16 static struct fio_option options[] = {
21 .off1 = offsetof(struct cpu_options, cpuload),
22 .help = "Use this percentage of CPU",
23 .category = FIO_OPT_C_GENERAL,
24 .group = FIO_OPT_G_INVALID,
30 .off1 = offsetof(struct cpu_options, cpucycle),
31 .help = "Length of the CPU burn cycles (usecs)",
35 .category = FIO_OPT_C_GENERAL,
36 .group = FIO_OPT_G_INVALID,
44 static int fio_cpuio_queue(struct thread_data *td, struct io_u fio_unused *io_u)
46 struct cpu_options *co = td->eo;
48 usec_spin(co->cpucycle);
49 return FIO_Q_COMPLETED;
52 static int fio_cpuio_init(struct thread_data *td)
54 struct thread_options *o = &td->o;
55 struct cpu_options *co = td->eo;
58 td_vmsg(td, EINVAL, "cpu thread needs rate (cpuload=)","cpuio");
62 if (co->cpuload > 100)
66 * set thinktime_sleep and thinktime_spin appropriately
68 o->thinktime_blocks = 1;
69 o->thinktime_spin = 0;
70 o->thinktime = (co->cpucycle * (100 - co->cpuload)) / co->cpuload;
72 o->nr_files = o->open_files = 1;
74 log_info("%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->o.name,
75 co->cpuload, co->cpucycle);
80 static int fio_cpuio_open(struct thread_data fio_unused *td,
81 struct fio_file fio_unused *f)
86 static struct ioengine_ops ioengine = {
88 .version = FIO_IOOPS_VERSION,
89 .queue = fio_cpuio_queue,
90 .init = fio_cpuio_init,
91 .open_file = fio_cpuio_open,
92 .flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_NOIO,
94 .option_struct_size = sizeof(struct cpu_options),
97 static void fio_init fio_cpuio_register(void)
99 register_ioengine(&ioengine);
102 static void fio_exit fio_cpuio_unregister(void)
104 unregister_ioengine(&ioengine);