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