libaio: add support for polled IO
authorJens Axboe <axboe@kernel.dk>
Tue, 6 Nov 2018 21:53:52 +0000 (14:53 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 6 Nov 2018 21:53:52 +0000 (14:53 -0700)
The support isn't in mainline yet, but it's being developed.
Currently the kernel support resides in the 'mq-perf' branch
of the block repo:

git://git.kernel.dk/linux-block mq-perf

Also see:

http://git.kernel.dk/cgit/linux-block/log/?h=mq-perf

Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/libaio.c

index 7ac36b236cdf91a33f31ff738176d0fadd8c4235..39f338a970b8df7d0e2336402643237ae9d32c35 100644 (file)
@@ -13,6 +13,9 @@
 #include "../lib/pow2.h"
 #include "../optgroup.h"
 
+#define IOCB_CMD_PREAD_POLL 9
+#define IOCB_CMD_PWRITE_POLL 10
+
 static int fio_libaio_commit(struct thread_data *td);
 
 struct libaio_data {
@@ -39,6 +42,7 @@ struct libaio_data {
 struct libaio_options {
        void *pad;
        unsigned int userspace_reap;
+       unsigned int hipri;
 };
 
 static struct fio_option options[] = {
@@ -51,6 +55,15 @@ static struct fio_option options[] = {
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_LIBAIO,
        },
+       {
+               .name   = "hipri",
+               .lname  = "RWF_HIPRI",
+               .type   = FIO_OPT_STR_SET,
+               .off1   = offsetof(struct libaio_options, hipri),
+               .help   = "Set RWF_HIPRI for pwritev2/preadv2",
+               .category = FIO_OPT_C_ENGINE,
+               .group  = FIO_OPT_G_LIBAIO,
+       },
        {
                .name   = NULL,
        },
@@ -68,12 +81,17 @@ static inline void ring_inc(struct libaio_data *ld, unsigned int *val,
 static int fio_libaio_prep(struct thread_data fio_unused *td, struct io_u *io_u)
 {
        struct fio_file *f = io_u->file;
+       struct libaio_options *o = td->eo;
 
-       if (io_u->ddir == DDIR_READ)
+       if (io_u->ddir == DDIR_READ) {
                io_prep_pread(&io_u->iocb, f->fd, io_u->xfer_buf, io_u->xfer_buflen, io_u->offset);
-       else if (io_u->ddir == DDIR_WRITE)
+               if (o->hipri)
+                       io_u->iocb.aio_lio_opcode = IOCB_CMD_PREAD_POLL;
+       } else if (io_u->ddir == DDIR_WRITE) {
                io_prep_pwrite(&io_u->iocb, f->fd, io_u->xfer_buf, io_u->xfer_buflen, io_u->offset);
-       else if (ddir_sync(io_u->ddir))
+               if (o->hipri)
+                       io_u->iocb.aio_lio_opcode = IOCB_CMD_PWRITE_POLL;
+       } else if (ddir_sync(io_u->ddir))
                io_prep_fsync(&io_u->iocb, f->fd);
 
        return 0;