backend: tweaks to missed rate thinktime
[fio.git] / idletime.h
1 #ifndef FIO_IDLETIME_H
2 #define FIO_IDLETIME_H
3
4 #include "fio.h"
5 #include "lib/output_buffer.h"
6
7 #define CALIBRATE_RUNS  10
8 #define CALIBRATE_SCALE 1000
9 #define MAX_CPU_STR_LEN 32
10
11 enum {
12         IDLE_PROF_OPT_NONE,
13         IDLE_PROF_OPT_CALI,                /* calibration only */
14         IDLE_PROF_OPT_SYSTEM,
15         IDLE_PROF_OPT_PERCPU
16 };
17
18 enum {
19          IDLE_PROF_STATUS_OK,
20          IDLE_PROF_STATUS_CALI_STOP,
21          IDLE_PROF_STATUS_PROF_STOP,
22          IDLE_PROF_STATUS_ABORT
23 };
24
25 struct idle_prof_thread {
26         pthread_t thread;
27         int cpu;
28         int state;
29         struct timespec tps;
30         struct timespec tpe;
31         double cali_time; /* microseconds to finish a unit work */
32         double loops;
33         double idleness;
34         unsigned char *data;             /* bytes to be touched */
35         pthread_cond_t  cond;
36         pthread_mutex_t init_lock;
37         pthread_mutex_t start_lock;
38
39         os_cpu_mask_t cpu_mask;
40 };
41
42 struct idle_prof_common {
43         struct idle_prof_thread *ipts;
44         int nr_cpus;
45         int status;
46         int opt;
47         double cali_mean;
48         double cali_stddev;
49         void *buf;    /* single data allocation for all threads */
50 };
51
52 extern int fio_idle_prof_parse_opt(const char *);
53
54 extern void fio_idle_prof_init(void);
55 extern void fio_idle_prof_start(void);
56 extern void fio_idle_prof_stop(void);
57
58 extern void show_idle_prof_stats(int, struct json_object *, struct buf_output *);
59
60 #endif