[PATCH] Add verify_meta verification type
[fio.git] / engines / cpu.c
1 /*
2  * CPU engine
3  *
4  * Doesn't transfer any data, merely burns CPU cycles according to
5  * the settings.
6  *
7  */
8 #include "../fio.h"
9
10 static int fio_cpuio_queue(struct thread_data *td, struct io_u fio_unused *io_u)
11 {
12         __usec_sleep(td->o.cpucycle);
13         return FIO_Q_COMPLETED;
14 }
15
16 static int fio_cpuio_init(struct thread_data *td)
17 {
18         struct thread_options *o = &td->o;
19
20         if (!o->cpuload) {
21                 td_vmsg(td, EINVAL, "cpu thread needs rate (cpuload=)","cpuio");
22                 return 1;
23         }
24
25         if (o->cpuload > 100)
26                 o->cpuload = 100;
27
28         /*
29          * set thinktime_sleep and thinktime_spin appropriately
30          */
31         o->thinktime_blocks = 1;
32         o->thinktime_spin = 0;
33         o->thinktime = (o->cpucycle * (100 - o->cpuload)) / o->cpuload;
34
35         o->nr_files = o->open_files = 1;
36         return 0;
37 }
38
39 static int fio_cpuio_open(struct thread_data fio_unused *td,
40                           struct fio_file fio_unused *f)
41 {
42         return 0;
43 }
44
45 static struct ioengine_ops ioengine = {
46         .name           = "cpuio",
47         .version        = FIO_IOOPS_VERSION,
48         .queue          = fio_cpuio_queue,
49         .init           = fio_cpuio_init,
50         .open_file      = fio_cpuio_open,
51         .flags          = FIO_SYNCIO | FIO_DISKLESSIO,
52 };
53
54 static void fio_init fio_cpuio_register(void)
55 {
56         register_ioengine(&ioengine);
57 }
58
59 static void fio_exit fio_cpuio_unregister(void)
60 {
61         unregister_ioengine(&ioengine);
62 }