From: Jens Axboe Date: Fri, 6 Dec 2019 15:35:28 +0000 (-0700) Subject: io_uring: add support for RWF_UNCACHED X-Git-Tag: fio-3.17~14 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=4a87b5840d35584fd872571d37c69d7544b1b00f io_uring: add support for RWF_UNCACHED 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 --- diff --git a/engines/io_uring.c b/engines/io_uring.c index ef56345b..9ba126d8 100644 --- a/engines/io_uring.c +++ b/engines/io_uring.c @@ -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) { diff --git a/os/os-linux.h b/os/os-linux.h index 36339ef3..dbcde242 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -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)