cmdprio: Add support for per I/O priority hint
[fio.git] / engines / io_uring.c
index 5021239e147d2cf1dcd851a6dcffe2335307114a..e1abf6888fd50c886b87ecc29cf25519c8bbba9d 100644 (file)
@@ -127,87 +127,6 @@ static struct fio_option options[] = {
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_IOURING,
        },
-#ifdef FIO_HAVE_IOPRIO_CLASS
-       {
-               .name   = "cmdprio_percentage",
-               .lname  = "high priority percentage",
-               .type   = FIO_OPT_INT,
-               .off1   = offsetof(struct ioring_options,
-                                  cmdprio_options.percentage[DDIR_READ]),
-               .off2   = offsetof(struct ioring_options,
-                                  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  = FIO_OPT_G_IOURING,
-       },
-       {
-               .name   = "cmdprio_class",
-               .lname  = "Asynchronous I/O priority class",
-               .type   = FIO_OPT_INT,
-               .off1   = offsetof(struct ioring_options,
-                                  cmdprio_options.class[DDIR_READ]),
-               .off2   = offsetof(struct ioring_options,
-                                  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  = FIO_OPT_G_IOURING,
-       },
-       {
-               .name   = "cmdprio",
-               .lname  = "Asynchronous I/O priority level",
-               .type   = FIO_OPT_INT,
-               .off1   = offsetof(struct ioring_options,
-                                  cmdprio_options.level[DDIR_READ]),
-               .off2   = offsetof(struct ioring_options,
-                                  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  = FIO_OPT_G_IOURING,
-       },
-       {
-               .name   = "cmdprio_bssplit",
-               .lname  = "Priority percentage block size split",
-               .type   = FIO_OPT_STR_STORE,
-               .off1   = offsetof(struct ioring_options,
-                                  cmdprio_options.bssplit_str),
-               .help   = "Set priority percentages for different block sizes",
-               .category = FIO_OPT_C_ENGINE,
-               .group  = FIO_OPT_G_IOURING,
-       },
-#else
-       {
-               .name   = "cmdprio_percentage",
-               .lname  = "high priority 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",
                .lname  = "Fixed (pre-mapped) IO buffers",
@@ -297,6 +216,7 @@ static struct fio_option options[] = {
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_IOURING,
        },
+       CMDPRIO_OPTIONS(struct ioring_options, FIO_OPT_G_IOURING),
        {
                .name   = NULL,
        },
@@ -365,8 +285,8 @@ static int fio_ioring_prep(struct thread_data *td, struct io_u *io_u)
                /*
                 * 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.
+                * the IO priority set by ioprio_set() (options prio, prioclass,
+                * and priohint) 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_cmdprio_prep() if the option cmdprio_percentage or
@@ -646,7 +566,7 @@ static int fio_ioring_commit(struct thread_data *td)
         */
        if (o->sqpoll_thread) {
                struct io_sq_ring *ring = &ld->sq_ring;
-               unsigned start = *ld->sq_ring.head;
+               unsigned start = *ld->sq_ring.tail - ld->queued;
                unsigned flags;
 
                flags = atomic_load_acquire(ring->flags);
@@ -1310,7 +1230,7 @@ static int fio_ioring_cmd_fetch_ruhs(struct thread_data *td, struct fio_file *f,
        struct nvme_fdp_ruh_status *ruhs;
        int bytes, ret, i;
 
-       bytes = sizeof(*ruhs) + 128 * sizeof(struct nvme_fdp_ruh_status_desc);
+       bytes = sizeof(*ruhs) + FDP_MAX_RUHS * sizeof(struct nvme_fdp_ruh_status_desc);
        ruhs = scalloc(1, bytes);
        if (!ruhs)
                return -ENOMEM;