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