int queued;
int cq_ring_off;
unsigned iodepth;
- bool ioprio_class_set;
- bool ioprio_set;
int prepped;
struct ioring_mmap mmap[3];
};
struct ioring_options {
- void *pad;
+ struct thread_data *td;
unsigned int hipri;
struct cmdprio cmdprio;
unsigned int fixedbufs;
return 0;
}
+static int str_cmdprio_bssplit_cb(void *data, const char *input)
+{
+ struct ioring_options *o = data;
+ struct thread_data *td = o->td;
+ struct cmdprio *cmdprio = &o->cmdprio;
+
+ return fio_cmdprio_bssplit_parse(td, input, cmdprio);
+}
+
static struct fio_option options[] = {
{
.name = "hipri",
.category = FIO_OPT_C_ENGINE,
.group = FIO_OPT_G_IOURING,
},
+ {
+ .name = "cmdprio_class",
+ .lname = "Asynchronous I/O priority class",
+ .type = FIO_OPT_INT,
+ .off1 = offsetof(struct ioring_options,
+ cmdprio.class[DDIR_READ]),
+ .off2 = offsetof(struct ioring_options,
+ cmdprio.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 = FIO_OPT_G_IOURING,
+ },
+ {
+ .name = "cmdprio",
+ .lname = "Asynchronous I/O priority level",
+ .type = FIO_OPT_INT,
+ .off1 = offsetof(struct ioring_options,
+ cmdprio.level[DDIR_READ]),
+ .off2 = offsetof(struct ioring_options,
+ cmdprio.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 = FIO_OPT_G_IOURING,
+ },
+ {
+ .name = "cmdprio_bssplit",
+ .lname = "Priority percentage block size split",
+ .type = FIO_OPT_STR_ULL,
+ .cb = str_cmdprio_bssplit_cb,
+ .off1 = offsetof(struct ioring_options, cmdprio.bssplit),
+ .help = "Set priority percentages for different block sizes",
+ .category = FIO_OPT_C_ENGINE,
+ .group = FIO_OPT_G_IOURING,
+ },
#else
{
.name = "cmdprio_percentage",
.type = FIO_OPT_UNSUPPORTED,
.help = "Your platform does not support I/O priority classes",
},
+ {
+ .name = "cmdprio_class",
+ .lname = "Asynchronous I/O priority class",
+ .type = FIO_OPT_UNSUPPORTED,
+ .help = "Your platform does not support I/O priority classes",
+ },
+ {
+ .name = "cmdprio",
+ .lname = "Asynchronous I/O priority level",
+ .type = FIO_OPT_UNSUPPORTED,
+ .help = "Your platform does not support I/O priority classes",
+ },
+ {
+ .name = "cmdprio_bssplit",
+ .lname = "Priority percentage block size split",
+ .type = FIO_OPT_UNSUPPORTED,
+ .help = "Your platform does not support I/O priority classes",
+ },
#endif
{
.name = "fixedbufs",
sqe->rw_flags |= RWF_UNCACHED;
if (o->nowait)
sqe->rw_flags |= RWF_NOWAIT;
- if (ld->ioprio_class_set)
- sqe->ioprio = td->o.ioprio_class << 13;
- if (ld->ioprio_set)
- sqe->ioprio |= td->o.ioprio;
+
+ /*
+ * Since io_uring can have a submission context (sqthread_poll)
+ * that is different from the process context, we cannot rely on
+ * the IO priority set by ioprio_set() (option prio/prioclass)
+ * to be inherited.
+ * td->ioprio will have the value of the "default prio", so set
+ * this unconditionally. This value might get overridden by
+ * fio_ioring_prio_prep() if the option cmdprio_percentage or
+ * cmdprio_bssplit is used.
+ */
+ sqe->ioprio = td->ioprio;
sqe->off = io_u->offset;
} else if (ddir_sync(io_u->ddir)) {
sqe->ioprio = 0;
struct ioring_data *ld = td->io_ops_data;
struct io_uring_sqe *sqe = &ld->sqes[io_u->index];
struct cmdprio *cmdprio = &o->cmdprio;
- unsigned int p = cmdprio->percentage[io_u->ddir];
+ enum fio_ddir ddir = io_u->ddir;
+ unsigned int p = fio_cmdprio_percentage(cmdprio, io_u);
+ unsigned int cmdprio_value =
+ ioprio_value(cmdprio->class[ddir], cmdprio->level[ddir]);
if (p && rand_between(&td->prio_state, 0, 99) < p) {
- sqe->ioprio = ioprio_value(IOPRIO_CLASS_RT, 0);
- io_u->flags |= IO_U_F_PRIORITY;
- } else {
- sqe->ioprio = 0;
+ io_u->ioprio = cmdprio_value;
+ sqe->ioprio = cmdprio_value;
+ if (!td->ioprio || cmdprio_value < td->ioprio) {
+ /*
+ * The async IO priority is higher (has a lower value)
+ * than the default priority (which is either 0 or the
+ * value set by "prio" and "prioclass" options).
+ */
+ io_u->flags |= IO_U_F_HIGH_PRIO;
+ }
+ } else if (td->ioprio && td->ioprio < cmdprio_value) {
+ /*
+ * The IO will be executed with the default priority (which is
+ * either 0 or the value set by "prio" and "prioclass options),
+ * and this priority is higher (has a lower value) than the
+ * async IO priority.
+ */
+ io_u->flags |= IO_U_F_HIGH_PRIO;
}
}
return 1;
}
- if (fio_option_is_set(&td->o, ioprio_class))
- ld->ioprio_class_set = true;
- if (fio_option_is_set(&td->o, ioprio))
- ld->ioprio_set = true;
-
return 0;
}