From a391d73d569568d2fd70bf6df3c8f3f7e8c56485 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 6 Nov 2018 14:53:52 -0700 Subject: [PATCH] libaio: add support for polled IO 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 --- engines/libaio.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/engines/libaio.c b/engines/libaio.c index 7ac36b23..39f338a9 100644 --- a/engines/libaio.c +++ b/engines/libaio.c @@ -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; -- 2.25.1