-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmdprio.h
166 lines (152 loc) · 4.79 KB
/
cmdprio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* IO priority handling declarations and helper functions common to the
* libaio and io_uring engines.
*/
#ifndef FIO_CMDPRIO_H
#define FIO_CMDPRIO_H
#include "../fio.h"
#include "../optgroup.h"
/* read and writes only, no trim */
#define CMDPRIO_RWDIR_CNT 2
enum {
CMDPRIO_MODE_NONE,
CMDPRIO_MODE_PERC,
CMDPRIO_MODE_BSSPLIT,
};
struct cmdprio_prio {
int32_t prio;
uint32_t perc;
uint16_t clat_prio_index;
};
struct cmdprio_bsprio {
uint64_t bs;
uint32_t tot_perc;
unsigned int nr_prios;
struct cmdprio_prio *prios;
};
struct cmdprio_bsprio_desc {
struct cmdprio_bsprio *bsprios;
unsigned int nr_bsprios;
};
struct cmdprio_options {
unsigned int percentage[CMDPRIO_RWDIR_CNT];
unsigned int class[CMDPRIO_RWDIR_CNT];
unsigned int level[CMDPRIO_RWDIR_CNT];
unsigned int hint[CMDPRIO_RWDIR_CNT];
char *bssplit_str;
};
#ifdef FIO_HAVE_IOPRIO_CLASS
#define CMDPRIO_OPTIONS(opt_struct, opt_group) \
{ \
.name = "cmdprio_percentage", \
.lname = "high priority percentage", \
.type = FIO_OPT_INT, \
.off1 = offsetof(opt_struct, \
cmdprio_options.percentage[DDIR_READ]), \
.off2 = offsetof(opt_struct, \
cmdprio_options.percentage[DDIR_WRITE]), \
.minval = 0, \
.maxval = 100, \
.help = "Send high priority I/O this percentage of the time", \
.category = FIO_OPT_C_ENGINE, \
.group = opt_group, \
}, \
{ \
.name = "cmdprio_class", \
.lname = "Asynchronous I/O priority class", \
.type = FIO_OPT_INT, \
.off1 = offsetof(opt_struct, \
cmdprio_options.class[DDIR_READ]), \
.off2 = offsetof(opt_struct, \
cmdprio_options.class[DDIR_WRITE]), \
.help = "Set asynchronous IO priority class", \
.minval = IOPRIO_MIN_PRIO_CLASS + 1, \
.maxval = IOPRIO_MAX_PRIO_CLASS, \
.interval = 1, \
.category = FIO_OPT_C_ENGINE, \
.group = opt_group, \
}, \
{ \
.name = "cmdprio_hint", \
.lname = "Asynchronous I/O priority hint", \
.type = FIO_OPT_INT, \
.off1 = offsetof(opt_struct, \
cmdprio_options.hint[DDIR_READ]), \
.off2 = offsetof(opt_struct, \
cmdprio_options.hint[DDIR_WRITE]), \
.help = "Set asynchronous IO priority hint", \
.minval = IOPRIO_MIN_PRIO_HINT, \
.maxval = IOPRIO_MAX_PRIO_HINT, \
.interval = 1, \
.category = FIO_OPT_C_ENGINE, \
.group = opt_group, \
}, \
{ \
.name = "cmdprio", \
.lname = "Asynchronous I/O priority level", \
.type = FIO_OPT_INT, \
.off1 = offsetof(opt_struct, \
cmdprio_options.level[DDIR_READ]), \
.off2 = offsetof(opt_struct, \
cmdprio_options.level[DDIR_WRITE]), \
.help = "Set asynchronous IO priority level", \
.minval = IOPRIO_MIN_PRIO, \
.maxval = IOPRIO_MAX_PRIO, \
.interval = 1, \
.category = FIO_OPT_C_ENGINE, \
.group = opt_group, \
}, \
{ \
.name = "cmdprio_bssplit", \
.lname = "Priority percentage block size split", \
.type = FIO_OPT_STR_STORE, \
.off1 = offsetof(opt_struct, cmdprio_options.bssplit_str), \
.help = "Set priority percentages for different block sizes", \
.category = FIO_OPT_C_ENGINE, \
.group = opt_group, \
}
#else
#define CMDPRIO_OPTIONS(opt_struct, opt_group) \
{ \
.name = "cmdprio_percentage", \
.lname = "high priority percentage", \
.type = FIO_OPT_UNSUPPORTED, \
.help = "Platform does not support I/O priority classes", \
}, \
{ \
.name = "cmdprio_class", \
.lname = "Asynchronous I/O priority class", \
.type = FIO_OPT_UNSUPPORTED, \
.help = "Platform does not support I/O priority classes", \
}, \
{ \
.name = "cmdprio_hint", \
.lname = "Asynchronous I/O priority hint", \
.type = FIO_OPT_UNSUPPORTED, \
.help = "Platform does not support I/O priority classes", \
}, \
{ \
.name = "cmdprio", \
.lname = "Asynchronous I/O priority level", \
.type = FIO_OPT_UNSUPPORTED, \
.help = "Platform does not support I/O priority classes", \
}, \
{ \
.name = "cmdprio_bssplit", \
.lname = "Priority percentage block size split", \
.type = FIO_OPT_UNSUPPORTED, \
.help = "Platform does not support I/O priority classes", \
}
#endif
struct cmdprio {
struct cmdprio_options *options;
struct cmdprio_prio perc_entry[CMDPRIO_RWDIR_CNT];
struct cmdprio_bsprio_desc bsprio_desc[CMDPRIO_RWDIR_CNT];
unsigned int mode;
};
bool fio_cmdprio_set_ioprio(struct thread_data *td, struct cmdprio *cmdprio,
struct io_u *io_u);
void fio_cmdprio_cleanup(struct cmdprio *cmdprio);
int fio_cmdprio_init(struct thread_data *td, struct cmdprio *cmdprio,
struct cmdprio_options *options);
#endif