From: Jens Axboe Date: Thu, 20 Feb 2025 20:07:41 +0000 (-0700) Subject: Re-introduce RWF_DONTCACHE X-Git-Tag: fio-3.40~64 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=43c67b9f3a8808274bc1e0a3b7b70c56bb8a007f;p=fio.git Re-introduce RWF_DONTCACHE 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 --- diff --git a/engines/io_uring.c b/engines/io_uring.c index facc967f..983e32b7 100644 --- a/engines/io_uring.c +++ b/engines/io_uring.c @@ -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; diff --git a/engines/sync.c b/engines/sync.c index 729d8a71..89466ca5 100644 --- a/engines/sync.c +++ b/engines/sync.c @@ -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; diff --git a/os/os-linux.h b/os/os-linux.h index ead8295c..6157e0e0 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -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) diff --git a/tools/fiograph/fiograph.conf b/tools/fiograph/fiograph.conf index 75712180..74f9752d 100644 --- a/tools/fiograph/fiograph.conf +++ b/tools/fiograph/fiograph.conf @@ -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