2 * IO priority handling declarations and helper functions common to the
3 * libaio and io_uring engines.
10 #include "../optgroup.h"
12 /* read and writes only, no trim */
13 #define CMDPRIO_RWDIR_CNT 2
24 uint16_t clat_prio_index;
27 struct cmdprio_bsprio {
30 unsigned int nr_prios;
31 struct cmdprio_prio *prios;
34 struct cmdprio_bsprio_desc {
35 struct cmdprio_bsprio *bsprios;
36 unsigned int nr_bsprios;
39 struct cmdprio_options {
40 unsigned int percentage[CMDPRIO_RWDIR_CNT];
41 unsigned int class[CMDPRIO_RWDIR_CNT];
42 unsigned int level[CMDPRIO_RWDIR_CNT];
43 unsigned int hint[CMDPRIO_RWDIR_CNT];
47 #ifdef FIO_HAVE_IOPRIO_CLASS
48 #define CMDPRIO_OPTIONS(opt_struct, opt_group) \
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]), \
59 .help = "Send high priority I/O this percentage of the time", \
60 .category = FIO_OPT_C_ENGINE, \
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, \
75 .category = FIO_OPT_C_ENGINE, \
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, \
90 .category = FIO_OPT_C_ENGINE, \
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, \
105 .category = FIO_OPT_C_ENGINE, \
106 .group = opt_group, \
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, \
118 #define CMDPRIO_OPTIONS(opt_struct, opt_group) \
120 .name = "cmdprio_percentage", \
121 .lname = "high priority percentage", \
122 .type = FIO_OPT_UNSUPPORTED, \
123 .help = "Platform does not support I/O priority classes", \
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", \
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", \
139 .lname = "Asynchronous I/O priority level", \
140 .type = FIO_OPT_UNSUPPORTED, \
141 .help = "Platform does not support I/O priority classes", \
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", \
152 struct cmdprio_options *options;
153 struct cmdprio_prio perc_entry[CMDPRIO_RWDIR_CNT];
154 struct cmdprio_bsprio_desc bsprio_desc[CMDPRIO_RWDIR_CNT];
158 bool fio_cmdprio_set_ioprio(struct thread_data *td, struct cmdprio *cmdprio,
161 void fio_cmdprio_cleanup(struct cmdprio *cmdprio);
163 int fio_cmdprio_init(struct thread_data *td, struct cmdprio *cmdprio,
164 struct cmdprio_options *options);