client: use temp buffer for single output flush for json/disk util
[fio.git] / idletime.h
CommitLineData
f2a2ce0e
HL
1#ifndef FIO_IDLETIME_H
2#define FIO_IDLETIME_H
3
3d2d14bc
SW
4#include <sys/time.h>
5#include <sys/types.h>
6#include "os/os.h"
f2a2ce0e
HL
7
8#define CALIBRATE_RUNS 10
9#define CALIBRATE_SCALE 1000
10#define MAX_CPU_STR_LEN 32
11
12enum {
13 IDLE_PROF_OPT_NONE,
14 IDLE_PROF_OPT_CALI, /* calibration only */
15 IDLE_PROF_OPT_SYSTEM,
16 IDLE_PROF_OPT_PERCPU
17};
18
19enum {
20 IDLE_PROF_STATUS_OK,
21 IDLE_PROF_STATUS_CALI_STOP,
22 IDLE_PROF_STATUS_PROF_STOP,
23 IDLE_PROF_STATUS_ABORT
24};
25
26struct idle_prof_thread {
27 pthread_t thread;
28 int cpu;
29 int state;
8b6a404c
VF
30 struct timespec tps;
31 struct timespec tpe;
de8f6de9 32 double cali_time; /* microseconds to finish a unit work */
f2a2ce0e
HL
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;
54ed125b
JA
39
40 os_cpu_mask_t cpu_mask;
f2a2ce0e
HL
41};
42
43struct 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
53extern int fio_idle_prof_parse_opt(const char *);
54
55extern void fio_idle_prof_init(void);
56extern void fio_idle_prof_start(void);
57extern void fio_idle_prof_stop(void);
58
a666cab8 59extern void show_idle_prof_stats(int, struct json_object *, struct buf_output *);
f2a2ce0e 60
7ceefc09
FS
61extern void fio_idle_prof_cleanup(void);
62
f2a2ce0e 63#endif