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 ef56345b15be3ed3252acbb1243e97fc28a5fb8f..9ba126d86c77ac821265bb18a8dbf323fd0ef2ca 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 36339ef3e94250200c909e4fbad2fcf8dffcd7f4..dbcde242c6ef33dd16996efade9a452df71890d0 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)