From eb314e7072a056b13c28bcb785f51b35c67fd1e6 Mon Sep 17 00:00:00 2001 From: Yuanchu Xie Date: Fri, 31 Mar 2023 11:37:02 -0700 Subject: [PATCH] fio: add support for POSIX_FADV_NOREUSE As of Linux kernel commit 17e810229cb3 ("mm: support POSIX_FADV_NOREUSE"), POSIX_FADV_NOREUSE hints at the LRU algorithm to ignore accesses to mapped files with this flag. Previously, it was a no-op. Add it in fio as an fadvise_hint option to test the new behavior. Signed-off-by: Yuanchu Xie Link: https://lore.kernel.org/r/20230331183703.3145788-1-yuanchu@google.com Signed-off-by: Jens Axboe --- fio.h | 1 + ioengines.c | 2 ++ options.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/fio.h b/fio.h index 32535517..f2acd430 100644 --- a/fio.h +++ b/fio.h @@ -163,6 +163,7 @@ enum { F_ADV_TYPE, F_ADV_RANDOM, F_ADV_SEQUENTIAL, + F_ADV_NOREUSE, }; /* diff --git a/ioengines.c b/ioengines.c index e2316ee4..56759c53 100644 --- a/ioengines.c +++ b/ioengines.c @@ -565,6 +565,8 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f) flags = POSIX_FADV_RANDOM; else if (td->o.fadvise_hint == F_ADV_SEQUENTIAL) flags = POSIX_FADV_SEQUENTIAL; + else if (td->o.fadvise_hint == F_ADV_NOREUSE) + flags = POSIX_FADV_NOREUSE; else { log_err("fio: unknown fadvise type %d\n", td->o.fadvise_hint); diff --git a/options.c b/options.c index 18857795..fe580ebb 100644 --- a/options.c +++ b/options.c @@ -2740,6 +2740,10 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .oval = F_ADV_SEQUENTIAL, .help = "Advise using FADV_SEQUENTIAL", }, + { .ival = "noreuse", + .oval = F_ADV_NOREUSE, + .help = "Advise using FADV_NOREUSE", + }, }, .help = "Use fadvise() to advise the kernel on IO pattern", .def = "1", -- 2.25.1