blob: 84c1fbbe79a8a293103ce19f1450c9f17847a743 [file] [log] [blame]
Huadong Liuf2a2ce02013-01-30 13:22:24 +01001#ifndef FIO_IDLETIME_H
2#define FIO_IDLETIME_H
3
4#include "fio.h"
Elliott Hugheseda3a602017-05-19 18:53:02 -07005#include "lib/output_buffer.h"
Huadong Liuf2a2ce02013-01-30 13:22:24 +01006
7#define CALIBRATE_RUNS 10
8#define CALIBRATE_SCALE 1000
9#define MAX_CPU_STR_LEN 32
10
11enum {
12 IDLE_PROF_OPT_NONE,
13 IDLE_PROF_OPT_CALI, /* calibration only */
14 IDLE_PROF_OPT_SYSTEM,
15 IDLE_PROF_OPT_PERCPU
16};
17
18enum {
19 IDLE_PROF_STATUS_OK,
20 IDLE_PROF_STATUS_CALI_STOP,
21 IDLE_PROF_STATUS_PROF_STOP,
22 IDLE_PROF_STATUS_ABORT
23};
24
25struct idle_prof_thread {
26 pthread_t thread;
27 int cpu;
28 int state;
29 struct timeval tps;
30 struct timeval tpe;
Anatol Pomozovde8f6de2013-09-26 16:31:34 -070031 double cali_time; /* microseconds to finish a unit work */
Huadong Liuf2a2ce02013-01-30 13:22:24 +010032 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;
Jens Axboe3c9c4702015-01-28 14:47:48 -070038
39 os_cpu_mask_t cpu_mask;
Huadong Liuf2a2ce02013-01-30 13:22:24 +010040};
41
42struct 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
52extern int fio_idle_prof_parse_opt(const char *);
53
54extern void fio_idle_prof_init(void);
55extern void fio_idle_prof_start(void);
56extern void fio_idle_prof_stop(void);
57
Elliott Hugheseda3a602017-05-19 18:53:02 -070058extern void show_idle_prof_stats(int, struct json_object *, struct buf_output *);
Huadong Liuf2a2ce02013-01-30 13:22:24 +010059
60#endif