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 10 enum { 11 IDLE_PROF_OPT_NONE, 12 IDLE_PROF_OPT_CALI, /* calibration only */ 13 IDLE_PROF_OPT_SYSTEM, 14 IDLE_PROF_OPT_PERCPU 15 }; 16 17 enum { 18 IDLE_PROF_STATUS_OK, 19 IDLE_PROF_STATUS_CALI_STOP, 20 IDLE_PROF_STATUS_PROF_STOP, 21 IDLE_PROF_STATUS_ABORT 22 }; 23 24 struct 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 os_cpu_mask_t cpu_mask; 39 }; 40 41 struct idle_prof_common { 42 struct idle_prof_thread *ipts; 43 int nr_cpus; 44 int status; 45 int opt; 46 double cali_mean; 47 double cali_stddev; 48 void *buf; /* single data allocation for all threads */ 49 }; 50 51 extern int fio_idle_prof_parse_opt(const char *); 52 53 extern void fio_idle_prof_init(void); 54 extern void fio_idle_prof_start(void); 55 extern void fio_idle_prof_stop(void); 56 57 extern void show_idle_prof_stats(int, struct json_object *); 58 59 #endif 60