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