3 #define FIO_DU_NAME_SZ 64
7 #include "helper_thread.h"
11 * @ios: Number of I/O operations that have been completed successfully.
12 * @merges: Number of I/O operations that have been merged.
13 * @sectors: I/O size in 512-byte units.
14 * @ticks: Time spent on I/O in milliseconds.
15 * @io_ticks: CPU time spent on I/O in milliseconds.
16 * @time_in_queue: Weighted time spent doing I/O in milliseconds.
18 * For the array members, index 0 refers to reads and index 1 refers to writes.
20 struct disk_util_stats {
26 uint64_t time_in_queue;
31 * Disk utilization as read from /sys/block/<dev>/stat
33 struct disk_util_stat {
34 uint8_t name[FIO_DU_NAME_SZ];
35 struct disk_util_stats s;
38 struct disk_util_agg {
44 uint64_t time_in_queue;
51 * Per-device disk util management
54 struct flist_head list;
55 /* If this disk is a slave, hook it into the master's
56 * list using this head.
58 struct flist_head slavelist;
64 struct disk_util_stat dus;
65 struct disk_util_stat last_dus;
67 struct disk_util_agg agg;
69 /* For software raids, this entry maintains pointers to the
70 * entries for the slave devices. The disk_util entries for
71 * the slaves devices should primarily be maintained through
72 * the disk_list list, i.e. for memory allocation and
73 * de-allocation, etc. Whereas this list should be used only
74 * for aggregating a software RAID's disk util figures.
76 struct flist_head slaves;
84 static inline void disk_util_mod(struct disk_util *du, int val)
89 fio_sem_down(du->lock);
92 flist_for_each(n, &du->slavelist) {
93 struct disk_util *slave;
95 slave = flist_entry(n, struct disk_util, slavelist);
101 static inline void disk_util_inc(struct disk_util *du)
103 disk_util_mod(du, 1);
106 static inline void disk_util_dec(struct disk_util *du)
108 disk_util_mod(du, -1);
111 #define DISK_UTIL_MSEC (250)
113 extern struct flist_head disk_list;
118 #ifdef FIO_HAVE_DISK_UTIL
119 extern void init_disk_util(struct thread_data *);
120 extern int update_io_ticks(void);
121 extern void setup_disk_util(void);
122 extern void disk_util_prune_entries(void);
124 /* keep this as a function to avoid a warning in handle_du() */
125 #define disk_util_prune_entries()
126 #define init_disk_util(td)
127 #define setup_disk_util()
129 static inline int update_io_ticks(void)
131 return helper_should_exit();