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]; | |
d6cbeab4 NC |
43 | char *bssplit_str; |
44 | }; | |
45 | ||
2838f77a DLM |
46 | #ifdef FIO_HAVE_IOPRIO_CLASS |
47 | #define CMDPRIO_OPTIONS(opt_struct, opt_group) \ | |
48 | { \ | |
49 | .name = "cmdprio_percentage", \ | |
50 | .lname = "high priority percentage", \ | |
51 | .type = FIO_OPT_INT, \ | |
52 | .off1 = offsetof(opt_struct, \ | |
53 | cmdprio_options.percentage[DDIR_READ]), \ | |
54 | .off2 = offsetof(opt_struct, \ | |
55 | cmdprio_options.percentage[DDIR_WRITE]), \ | |
56 | .minval = 0, \ | |
57 | .maxval = 100, \ | |
58 | .help = "Send high priority I/O this percentage of the time", \ | |
59 | .category = FIO_OPT_C_ENGINE, \ | |
60 | .group = opt_group, \ | |
61 | }, \ | |
62 | { \ | |
63 | .name = "cmdprio_class", \ | |
64 | .lname = "Asynchronous I/O priority class", \ | |
65 | .type = FIO_OPT_INT, \ | |
66 | .off1 = offsetof(opt_struct, \ | |
67 | cmdprio_options.class[DDIR_READ]), \ | |
68 | .off2 = offsetof(opt_struct, \ | |
69 | cmdprio_options.class[DDIR_WRITE]), \ | |
70 | .help = "Set asynchronous IO priority class", \ | |
71 | .minval = IOPRIO_MIN_PRIO_CLASS + 1, \ | |
72 | .maxval = IOPRIO_MAX_PRIO_CLASS, \ | |
73 | .interval = 1, \ | |
74 | .category = FIO_OPT_C_ENGINE, \ | |
75 | .group = opt_group, \ | |
76 | }, \ | |
77 | { \ | |
78 | .name = "cmdprio", \ | |
79 | .lname = "Asynchronous I/O priority level", \ | |
80 | .type = FIO_OPT_INT, \ | |
81 | .off1 = offsetof(opt_struct, \ | |
82 | cmdprio_options.level[DDIR_READ]), \ | |
83 | .off2 = offsetof(opt_struct, \ | |
84 | cmdprio_options.level[DDIR_WRITE]), \ | |
85 | .help = "Set asynchronous IO priority level", \ | |
86 | .minval = IOPRIO_MIN_PRIO, \ | |
87 | .maxval = IOPRIO_MAX_PRIO, \ | |
88 | .interval = 1, \ | |
89 | .category = FIO_OPT_C_ENGINE, \ | |
90 | .group = opt_group, \ | |
91 | }, \ | |
92 | { \ | |
93 | .name = "cmdprio_bssplit", \ | |
94 | .lname = "Priority percentage block size split", \ | |
95 | .type = FIO_OPT_STR_STORE, \ | |
96 | .off1 = offsetof(opt_struct, cmdprio_options.bssplit_str), \ | |
97 | .help = "Set priority percentages for different block sizes", \ | |
98 | .category = FIO_OPT_C_ENGINE, \ | |
99 | .group = opt_group, \ | |
100 | } | |
101 | #else | |
102 | #define CMDPRIO_OPTIONS(opt_struct, opt_group) \ | |
103 | { \ | |
104 | .name = "cmdprio_percentage", \ | |
105 | .lname = "high priority percentage", \ | |
106 | .type = FIO_OPT_UNSUPPORTED, \ | |
107 | .help = "Platform does not support I/O priority classes", \ | |
108 | }, \ | |
109 | { \ | |
110 | .name = "cmdprio_class", \ | |
111 | .lname = "Asynchronous I/O priority class", \ | |
112 | .type = FIO_OPT_UNSUPPORTED, \ | |
113 | .help = "Platform does not support I/O priority classes", \ | |
114 | }, \ | |
115 | { \ | |
116 | .name = "cmdprio", \ | |
117 | .lname = "Asynchronous I/O priority level", \ | |
118 | .type = FIO_OPT_UNSUPPORTED, \ | |
119 | .help = "Platform does not support I/O priority classes", \ | |
120 | }, \ | |
121 | { \ | |
122 | .name = "cmdprio_bssplit", \ | |
123 | .lname = "Priority percentage block size split", \ | |
124 | .type = FIO_OPT_UNSUPPORTED, \ | |
125 | .help = "Platform does not support I/O priority classes", \ | |
126 | } | |
127 | #endif | |
128 | ||
d6cbeab4 NC |
129 | struct cmdprio { |
130 | struct cmdprio_options *options; | |
f0547200 NC |
131 | struct cmdprio_prio perc_entry[CMDPRIO_RWDIR_CNT]; |
132 | struct cmdprio_bsprio_desc bsprio_desc[CMDPRIO_RWDIR_CNT]; | |
97f2d484 | 133 | unsigned int mode; |
e9f6567a DLM |
134 | }; |
135 | ||
127715b6 NC |
136 | bool fio_cmdprio_set_ioprio(struct thread_data *td, struct cmdprio *cmdprio, |
137 | struct io_u *io_u); | |
a48f0cc7 | 138 | |
d6cbeab4 NC |
139 | void fio_cmdprio_cleanup(struct cmdprio *cmdprio); |
140 | ||
141 | int fio_cmdprio_init(struct thread_data *td, struct cmdprio *cmdprio, | |
142 | struct cmdprio_options *options); | |
e9f6567a DLM |
143 | |
144 | #endif |