io_uring: add support for RWF_UNCACHED
authorJens Axboe <axboe@kernel.dk>
Fri, 6 Dec 2019 15:35:28 +0000 (08:35 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 6 Dec 2019 15:36:38 +0000 (08:36 -0700)
If this is set, and the kernel supports it, buffered IO will be
uncached. This means that reads are dropped from the cache if we
are the ones instantiating the pages, and writes are sync and
dropped from the page cache on IO completion.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/io_uring.c
os/os-linux.h

index ef56345..9ba126d 100644 (file)
@@ -75,6 +75,7 @@ struct ioring_options {
        unsigned int sqpoll_thread;
        unsigned int sqpoll_set;
        unsigned int sqpoll_cpu;
+       unsigned int uncached;
 };
 
 static int fio_ioring_sqpoll_cb(void *data, unsigned long long *val)
@@ -132,6 +133,15 @@ static struct fio_option options[] = {
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_IOURING,
        },
+       {
+               .name   = "uncached",
+               .lname  = "Uncached",
+               .type   = FIO_OPT_INT,
+               .off1   = offsetof(struct ioring_options, uncached),
+               .help   = "Use RWF_UNCACHED for buffered read/writes",
+               .category = FIO_OPT_C_ENGINE,
+               .group  = FIO_OPT_G_IOURING,
+       },
        {
                .name   = NULL,
        },
@@ -180,6 +190,8 @@ static int fio_ioring_prep(struct thread_data *td, struct io_u *io_u)
                        sqe->addr = (unsigned long) &ld->iovecs[io_u->index];
                        sqe->len = 1;
                }
+               if (!td->o.odirect && o->uncached)
+                       sqe->rw_flags = RWF_UNCACHED;
                sqe->off = io_u->offset;
        } else if (ddir_sync(io_u->ddir)) {
                if (io_u->ddir == DDIR_SYNC_FILE_RANGE) {
index 36339ef..dbcde24 100644 (file)
@@ -326,6 +326,10 @@ static inline int fio_set_sched_idle(void)
 #define RWF_SYNC       0x00000004
 #endif
 
+#ifndef RWF_UNCACHED
+#define RWF_UNCACHED   0x00000020
+#endif
+
 #ifndef RWF_WRITE_LIFE_SHIFT
 #define RWF_WRITE_LIFE_SHIFT           4
 #define RWF_WRITE_LIFE_SHORT           (1 << RWF_WRITE_LIFE_SHIFT)