Skip to contentSkip to conversation

fio: add support for POSIX_FADV_NOREUSE

PATCH Superseded Yuanchu Xie 2 participants 3 messages Mar 30, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 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.

---
 fio.h       | 1 +
 ioengines.c | 2 ++
 options.c   | 4 ++++
 3 files changed, 7 insertions(+)
fio.h +1 -0
index 32535517..f2acd430 100644
@@ -163,6 +163,7 @@ enum {
 	F_ADV_TYPE,
 	F_ADV_RANDOM,
 	F_ADV_SEQUENTIAL,
+	F_ADV_NOREUSE,
 };
 
 /*
ioengines.c +2 -0
index e2316ee4..56759c53 100644
@@ -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);
options.c +4 -0
index 18857795..fe580ebb 100644
@@ -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",
Signature · 1 line
2.40.0.348.gf938b09366-goog
#1 lore raw

PATCH 2/2 docs: add noreuse fadvise_hint option

noreuse was added as an fadvise_hint option to apply POSIX_FADV_NOREUSE, so we add it to the docs as well.

---
 fio.1 | 3 +++
 1 file changed, 3 insertions(+)
fio.1 +3 -0
index e2db3a3f..4fa033f3 100644
@@ -1098,6 +1098,9 @@ Advise using FADV_SEQUENTIAL.
 .TP
 .B random
 Advise using FADV_RANDOM.
+.TP
+.B noreuse
+Advise using FADV_NOREUSE.
 .RE
 .RE
 .TP
Signature · 1 line
2.40.0.348.gf938b09366-goog
#2 lore raw

Re: [PATCH 2/2] docs: add noreuse fadvise_hint option

Quoted 2 lines · Yuanchu Xie

noreuse was added as an fadvise_hint option to apply POSIX_FADV_NOREUSE, so we add it to the docs as well.

Can you do the HOWTO as well?

Apart from that oversight, looks fine to me.

Signature · 1 line
Jens Axboe