Re-introduce RWF_DONTCACHE
authorJens Axboe <axboe@kernel.dk>
Thu, 20 Feb 2025 20:07:41 +0000 (13:07 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 20 Feb 2025 20:07:41 +0000 (13:07 -0700)
This used to be called RWF_UNCACHED, and it never made it upstream. But
as of the 6.14 kernel, RWF_DONTCACHE exists, and provides the same
guarantees that the older RWF_UNCACHED did - it's applied to buffered
IO, and any page cache instantiated for this read or write will be
dropped on IO completion. Any data already in cache will remain in cache
and will not cause IO to be issued.

This adds support for the io_uring and sync IO engines.

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

index facc967f1a9ddda6e4951f0de388ea820c46bdc8..983e32b7f272d946aa0566928915ef9842c6d89b 100644 (file)
@@ -114,6 +114,7 @@ struct ioring_options {
        unsigned int sqpoll_set;
        unsigned int sqpoll_cpu;
        unsigned int nonvectored;
+       unsigned int uncached;
        unsigned int nowait;
        unsigned int force_async;
        unsigned int md_per_io_size;
@@ -271,7 +272,11 @@ static struct fio_option options[] = {
        {
                .name   = "uncached",
                .lname  = "Uncached",
-               .type   = FIO_OPT_SOFT_DEPRECATED,
+               .type   = FIO_OPT_INT,
+               .off1   = offsetof(struct ioring_options, uncached),
+               .help   = "Use RWF_DONTCACHE for buffered read/writes",
+               .category = FIO_OPT_C_ENGINE,
+               .group  = FIO_OPT_G_IOURING,
        },
        {
                .name   = "nowait",
@@ -432,6 +437,8 @@ static int fio_ioring_prep(struct thread_data *td, struct io_u *io_u)
                        }
                }
                sqe->rw_flags = 0;
+               if (!td->o.odirect && o->uncached)
+                       sqe->rw_flags |= RWF_DONTCACHE;
                if (o->nowait)
                        sqe->rw_flags |= RWF_NOWAIT;
                if (td->o.oatomic && io_u->ddir == DDIR_WRITE)
@@ -513,6 +520,8 @@ static int fio_ioring_cmd_prep(struct thread_data *td, struct io_u *io_u)
                sqe->fd = f->fd;
        }
        sqe->rw_flags = 0;
+       if (!td->o.odirect && o->uncached)
+               sqe->rw_flags |= RWF_DONTCACHE;
        if (o->nowait)
                sqe->rw_flags |= RWF_NOWAIT;
 
index 729d8a71cfea25f6827a6f70fff469493b473b25..89466ca596aa00e4804ffc2a570dc9633168a748 100644 (file)
@@ -39,6 +39,7 @@ struct psyncv2_options {
        void *pad;
        unsigned int hipri;
        unsigned int hipri_percentage;
+       unsigned int uncached;
        unsigned int nowait;
 };
 
@@ -67,7 +68,11 @@ static struct fio_option options[] = {
        {
                .name   = "uncached",
                .lname  = "Uncached",
-               .type   = FIO_OPT_SOFT_DEPRECATED,
+               .type   = FIO_OPT_INT,
+               .off1   = offsetof(struct psyncv2_options, uncached),
+               .help   = "Use RWF_DONTCACHE for buffered read/writes",
+               .category = FIO_OPT_C_ENGINE,
+               .group  = FIO_OPT_G_INVALID,
        },
        {
                .name   = "nowait",
@@ -167,6 +172,8 @@ static enum fio_q_status fio_pvsyncio2_queue(struct thread_data *td,
        if (o->hipri &&
            (rand_between(&sd->rand_state, 1, 100) <= o->hipri_percentage))
                flags |= RWF_HIPRI;
+       if (!td->o.odirect && o->uncached)
+               flags |= RWF_DONTCACHE;
        if (o->nowait)
                flags |= RWF_NOWAIT;
 
index ead8295c4413545324056bdce6f2839e9cb365c1..6157e0e0b3b9bfe230655cc252d392abdc4dfd8f 100644 (file)
@@ -333,6 +333,10 @@ static inline int fio_set_sched_idle(void)
 #define RWF_ATOMIC     0x00000040
 #endif
 
+#ifndef RWF_DONTCACHE
+#define RWF_DONTCACHE  0x00000080
+#endif
+
 #ifndef RWF_WRITE_LIFE_SHIFT
 #define RWF_WRITE_LIFE_SHIFT           4
 #define RWF_WRITE_LIFE_SHORT           (1 << RWF_WRITE_LIFE_SHIFT)
index 757121806e28f03f48b2c3e18461ae1348ddfdec..74f9752d4322c7c53a4d3ac988533fb3e5c539a6 100644 (file)
@@ -51,7 +51,7 @@ specific_options=https  http_host  http_user  http_pass  http_s3_key  http_s3_ke
 specific_options=ime_psync  ime_psyncv
 
 [ioengine_io_uring]
-specific_options=hipri  cmdprio_percentage  cmdprio_class  cmdprio  cmdprio_bssplit  fixedbufs  registerfiles  sqthread_poll  sqthread_poll_cpu  nonvectored  nowait  force_async atomic
+specific_options=hipri  cmdprio_percentage  cmdprio_class  cmdprio  cmdprio_bssplit  fixedbufs  registerfiles  sqthread_poll  sqthread_poll_cpu  nonvectored  nowait  force_async atomic uncached
 
 [ioengine_io_uring_cmd]
 specific_options=hipri  cmdprio_percentage  cmdprio_class  cmdprio  cmdprio_bssplit  fixedbufs  registerfiles  sqthread_poll  sqthread_poll_cpu  nonvectored  nowait  force_async  cmd_type  md_per_io_size  pi_act  pi_chk  apptag  apptag_mask
@@ -99,7 +99,7 @@ specific_options=hostname  bindname  port  verb
 specific_options=hipri  readfua  writefua  sg_write_mode  stream_id
 
 [ioengine_pvsync2]
-specific_options=hipri  hipri_percentage  nowait  sync  psync  vsync  pvsync atomic
+specific_options=hipri  hipri_percentage  nowait  sync  psync  vsync  pvsync atomic uncached
 
 [ioengine_xnvme]
 specific_options=hipri  sqthread_poll  xnvme_be  xnvme_async  xnvme_sync  xnvme_admin  xnvme_dev_nsid  xnvme_iovec