Skip to contentSkip to conversation

mm: improve write performance with RWF_DONTCACHE

PATCH Superseded Jeff Layton 3 participants 16 messages Apr 1 – Apr 7

Subsystems (5)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

cover mm: improve write performance with RWF_DONTCACHE

Recently, we've added controls that allow nfsd to use different IO modes for reads and writes. There are currently 3 different settings for each:

- buffered: traditional buffered reads and writes (this is the default)
- dontcache: set the RWF_DONTCACHE flag on the read or write
- direct: use direct I/O

One of my goals for this half of the year was to do some benchmarking of these different modes with different workloads to see if we can come up with some guidance about what should be used and when.

I had Claude cook up a set of benchmarks that used fio's libnfs backend and started testing the different modes. The initial results weren't terribly surprising, but one thing that really stood out was how badly RWF_DONTCACHE performed with write-heavy workloads. This turned out to be the case on a local xfs with io_uring as well as with nfsd.

The nice thing about these new debugfs controls for nfsd is that it makes it easy to experiement with different IO modes for nfsd. After testing several different approaches, I think this patchset represents a fairly clear improvement. The first two patches alleviate the flush contention when RWF_DONTCACHE is used with heavy write activity.

The last two patches add the performance benchmarking scripts. I don't expect us to merge those, but I wanted to include them to make it clear how this was tested. The results of my testing with all 4 modes (buffered, direct, patched and unpatched dontcache) along with Claude's analysis are at the links below:

nfsd results: https://markdownpastebin.com/?id=0eaf694bd54046b584a8572895abcec2
xfs results: https://markdownpastebin.com/?id=96249deb897a401ba32acbce05312dcc

I can also send them inline if people don't want to chase links.

---
Jeff Layton (4):
mm: fix IOCB_DONTCACHE write performance with rate-limited writeback
mm: add atomic flush guard for IOCB_DONTCACHE writeback
testing: add nfsd-io-bench NFS server benchmark suite
testing: add dontcache-bench local filesystem benchmark suite

 include/linux/fs.h                                 |   7 +-
 include/linux/pagemap.h                            |   1 +
 mm/filemap.c                                       |  51 ++
 .../dontcache-bench/fio-jobs/lat-reader.fio        |  12 +
 .../dontcache-bench/fio-jobs/multi-write.fio       |   9 +
 .../dontcache-bench/fio-jobs/noisy-writer.fio      |  12 +
 .../testing/dontcache-bench/fio-jobs/rand-read.fio |  13 +
 .../dontcache-bench/fio-jobs/rand-write.fio        |  13 +
 .../testing/dontcache-bench/fio-jobs/seq-read.fio  |  13 +
 .../testing/dontcache-bench/fio-jobs/seq-write.fio |  13 +
 .../dontcache-bench/scripts/parse-results.sh       | 238 +++++++++
 .../dontcache-bench/scripts/run-benchmarks.sh      | 518 ++++++++++++++++++++
 .../testing/nfsd-io-bench/fio-jobs/lat-reader.fio  |  15 +
 .../testing/nfsd-io-bench/fio-jobs/multi-write.fio |  14 +
 .../nfsd-io-bench/fio-jobs/noisy-writer.fio        |  14 +
 tools/testing/nfsd-io-bench/fio-jobs/rand-read.fio |  15 +
 .../testing/nfsd-io-bench/fio-jobs/rand-write.fio  |  15 +
 tools/testing/nfsd-io-bench/fio-jobs/seq-read.fio  |  14 +
 tools/testing/nfsd-io-bench/fio-jobs/seq-write.fio |  14 +
 .../testing/nfsd-io-bench/scripts/parse-results.sh | 238 +++++++++
 .../nfsd-io-bench/scripts/run-benchmarks.sh        | 543 +++++++++++++++++++++
 .../testing/nfsd-io-bench/scripts/setup-server.sh  |  94 ++++
 22 files changed, 1874 insertions(+), 2 deletions(-)

---
base-commit: 9147566d801602c9e7fc7f85e989735735bf38ba
change-id: 20260401-dontcache-5811efd7eaf3

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
author maintainer
#1 lore raw

PATCH 1/4 mm: fix IOCB_DONTCACHE write performance with rate-limited writeback

IOCB_DONTCACHE calls filemap_flush_range() with nr_to_write=LONG_MAX on every write, which flushes all dirty pages in the written range. Under concurrent writers this creates severe serialization on the writeback submission path, causing throughput to collapse to ~47% of buffered I/O with multi-second tail latency. Even single-client sequential writes suffer: on a 512GB file with 256GB RAM, the aggressive flushing triggers dirty throttling that limits throughput to 575 MB/s vs 1442 MB/s with rate-limited writeback.

Replace the filemap_flush_range() call in generic_write_sync() with a new filemap_dontcache_writeback_range() that uses two rate-limiting mechanisms:

1. Skip-if-busy: check mapping_tagged(PAGECACHE_TAG_WRITEBACK) before flushing. If writeback is already in progress on the mapping, skip the flush entirely. This eliminates writeback submission contention between concurrent writers.

2. Proportional cap: when flushing does occur, cap nr_to_write to the number of pages just written. This prevents any single write from triggering a large flush that would starve concurrent readers.

Both mechanisms are necessary: skip-if-busy alone causes I/O bursts when the tag clears (reader p99.9 spikes 83x); proportional cap alone still serializes on xarray locks regardless of submission size.

Pages touched under IOCB_DONTCACHE continue to be marked for eviction (dropbehind), so page cache usage remains bounded. Ranges skipped by the busy check are eventually flushed by background writeback or by the next writer to find the tag clear.

---
 include/linux/fs.h |  7 +++++--
 mm/filemap.c       | 29 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)
include/linux/fs.h +5 -2
index 8b3dd145b25ec12b00ac1df17a952d9116b88047..53e9cca1b50a946a1276c49902294c3ae0ab3500 100644
@@ -2610,6 +2610,8 @@ extern int __must_check file_write_and_wait_range(struct file *file,
 						loff_t start, loff_t end);
 int filemap_flush_range(struct address_space *mapping, loff_t start,
 		loff_t end);
+int filemap_dontcache_writeback_range(struct address_space *mapping,
+		loff_t start, loff_t end, ssize_t nr_written);
 
 static inline int file_write_and_wait(struct file *file)
 {
@@ -2645,8 +2647,9 @@ static inline ssize_t generic_write_sync(struct kiocb *iocb, ssize_t count)
 	} else if (iocb->ki_flags & IOCB_DONTCACHE) {
 		struct address_space *mapping = iocb->ki_filp->f_mapping;
 
-		filemap_flush_range(mapping, iocb->ki_pos - count,
-				iocb->ki_pos - 1);
+		filemap_dontcache_writeback_range(mapping,
+				iocb->ki_pos - count,
+				iocb->ki_pos - 1, count);
 	}
 
 	return count;
mm/filemap.c +29 -0
index 406cef06b684a84a1e0c27d8267e95f32282ffdc..af2024b736bef74571cc22ab7e3cde2c8e872efe 100644
@@ -437,6 +437,35 @@ int filemap_flush_range(struct address_space *mapping, loff_t start,
 }
 EXPORT_SYMBOL_GPL(filemap_flush_range);
 
+/**
+ * filemap_dontcache_writeback_range - rate-limited writeback for dontcache I/O
+ * @mapping:	target address_space
+ * @start:	byte offset to start writeback
+ * @end:	last byte offset (inclusive) for writeback
+ * @nr_written:	number of bytes just written by the caller
+ *
+ * Rate-limited writeback for IOCB_DONTCACHE writes.  Skips the flush
+ * entirely if writeback is already in progress on the mapping (skip-if-busy),
+ * and when flushing, caps nr_to_write to the number of pages just written
+ * (proportional cap).  Together these avoid writeback contention between
+ * concurrent writers and prevent I/O bursts that starve readers.
+ *
+ * Return: %0 on success, negative error code otherwise.
+ */
+int filemap_dontcache_writeback_range(struct address_space *mapping,
+		loff_t start, loff_t end, ssize_t nr_written)
+{
+	long nr;
+
+	if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK))
+		return 0;
+
+	nr = (nr_written + PAGE_SIZE - 1) >> PAGE_SHIFT;
+	return filemap_writeback(mapping, start, end, WB_SYNC_NONE, &nr,
+			WB_REASON_BACKGROUND);
+}
+EXPORT_SYMBOL_GPL(filemap_dontcache_writeback_range);
+
 /**
  * filemap_flush - mostly a non-blocking flush
  * @mapping:	target address_space
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 1/4] mm: fix IOCB_DONTCACHE write performance with rate-limited writeback

Quoted 9 lines · Jeff Layton

IOCB_DONTCACHE calls filemap_flush_range() with nr_to_write=LONG_MAX on every write, which flushes all dirty pages in the written range.

Under concurrent writers this creates severe serialization on the writeback submission path, causing throughput to collapse to ~47% of buffered I/O with multi-second tail latency. Even single-client sequential writes suffer: on a 512GB file with 256GB RAM, the aggressive flushing triggers dirty throttling that limits throughput to 575 MB/s vs 1442 MB/s with rate-limited writeback.

I'm not sure the first how you think the first paragraph relate to the second.

Quoted 8 lines

Replace the filemap_flush_range() call in generic_write_sync() with a new filemap_dontcache_writeback_range() that uses two rate-limiting mechanisms:

1. Skip-if-busy: check mapping_tagged(PAGECACHE_TAG_WRITEBACK) before flushing. If writeback is already in progress on the mapping, skip the flush entirely. This eliminates writeback submission contention between concurrent writers.

Makes sense.

Quoted 4 lines

2. Proportional cap: when flushing does occur, cap nr_to_write to the number of pages just written. This prevents any single write from triggering a large flush that would starve concurrent readers.

This doesn't make any sense at all. filemap_flush_range/filemap_writeback always caps the number of written pages to the range passed in. What do you think is the change here?

mm/filemap.c int filemap_flush_range(struct address_space *mapping, loff_t start, · line 465

Quoted 2 lines
mm/filemap.c +2 -0
+	return filemap_writeback(mapping, start, end, WB_SYNC_NONE, &nr,
+			WB_REASON_BACKGROUND);

filemap_writeback only has 5 arguments in any tree I've looked at including linux-next.

author maintainer
#3 lore raw

Re: [PATCH 1/4] mm: fix IOCB_DONTCACHE write performance with rate-limited writeback

Quoted 11 lines · Christoph Hellwig
Quoted 9 lines · Jeff Layton

IOCB_DONTCACHE calls filemap_flush_range() with nr_to_write=LONG_MAX on every write, which flushes all dirty pages in the written range.

Under concurrent writers this creates severe serialization on the writeback submission path, causing throughput to collapse to ~47% of buffered I/O with multi-second tail latency. Even single-client sequential writes suffer: on a 512GB file with 256GB RAM, the aggressive flushing triggers dirty throttling that limits throughput to 575 MB/s vs 1442 MB/s with rate-limited writeback.

Quoted 3 lines

I'm not sure the first how you think the first paragraph relate to the second.

The belief is that under heavy parallel write workload on the same inode, the writers all end up stacking up on the mapping's xa_lock. However as Ritesh points out, I should probably confirm that with perf.

Quoted 11 lines
Quoted 8 lines

Replace the filemap_flush_range() call in generic_write_sync() with a new filemap_dontcache_writeback_range() that uses two rate-limiting mechanisms:

1. Skip-if-busy: check mapping_tagged(PAGECACHE_TAG_WRITEBACK) before flushing. If writeback is already in progress on the mapping, skip the flush entirely. This eliminates writeback submission contention between concurrent writers.

Makes sense.

Quoted 9 lines
Quoted 4 lines

2. Proportional cap: when flushing does occur, cap nr_to_write to the number of pages just written. This prevents any single write from triggering a large flush that would starve concurrent readers.

This doesn't make any sense at all. filemap_flush_range/filemap_writeback always caps the number of written pages to the range passed in. What do you think is the change here?

I had some earlier results that indicated that this did help. It's possible they were bogus though. I'll recheck that and get back to you.

Quoted 6 lines

mm/filemap.c int filemap_flush_range(struct address_space *mapping, loff_t start, · line 465

Quoted 2 lines
mm/filemap.c +2 -0
+	return filemap_writeback(mapping, start, end, WB_SYNC_NONE, &nr,
+			WB_REASON_BACKGROUND);

filemap_writeback only has 5 arguments in any tree I've looked at including linux-next.

I think this was a bad merge on my part. Mea culpa. The version in the "dontcache" branch of my tree should be correct.

Thanks for the review!

Signature · 1 line
Jeff Layton <[email protected]>
#4 lore raw

Re: [PATCH 1/4] mm: fix IOCB_DONTCACHE write performance with rate-limited writeback

Quoted 11 lines · Jeff Layton
Quoted 11 lines · Jeff Layton
Quoted 9 lines

IOCB_DONTCACHE calls filemap_flush_range() with nr_to_write=LONG_MAX on every write, which flushes all dirty pages in the written range.

Under concurrent writers this creates severe serialization on the writeback submission path, causing throughput to collapse to ~47% of buffered I/O with multi-second tail latency. Even single-client sequential writes suffer: on a 512GB file with 256GB RAM, the aggressive flushing triggers dirty throttling that limits throughput to 575 MB/s vs 1442 MB/s with rate-limited writeback.

Quoted 7 lines
Quoted 3 lines

I'm not sure the first how you think the first paragraph relate to the second.

The belief is that under heavy parallel write workload on the same inode, the writers all end up stacking up on the mapping's xa_lock. However as Ritesh points out, I should probably confirm that with perf.

But nr_to_write should not change anything. If .range_start and .range_end are set in a writeback_iter() loop, writeback_iter will try to get and writeback every page in the range. Setting nr_to_write in addition to that could only reduce the amount written if it was less than the size of the range, which in your patch it isn't.

In fact we should probably have a debug check to never set both a range and nr_to_write as that combination doesn't make sense.

#5 lore raw

Re: [PATCH 1/4] mm: fix IOCB_DONTCACHE write performance with rate-limited writeback

In reply to Jeff Layton
Quoted 5 lines · Jeff Layton

IOCB_DONTCACHE calls filemap_flush_range() with nr_to_write=LONG_MAX on every write, which flushes all dirty pages in the written range. Under concurrent writers this creates severe serialization on the writeback submission path, causing throughput to collapse to ~47% of buffered I/O with multi-second tail latency.

Yes, between concurrent writers, I agree with the theory.

Quoted 4 lines

Even single-client
sequential writes suffer: on a 512GB file with 256GB RAM, the aggressive flushing triggers dirty throttling that limits throughput to 575 MB/s vs 1442 MB/s with rate-limited writeback.

I am not sure if this 2.5x performance penalty in a "single" sequential writer is due to throttling logic. On giving it some thoughts, I suspect if this is because, the submission side and the completion side both takes the xa_lock and hence could be contending on that.

For e.g. since this patch skips doing the flush the second time, (note that writeback is active when the same writer dirtied the page during previous write), this allows the writer to do more work of writing data to page cache pages, instead of waiting on the xa_lock which the completion callback could be holding (folio_end_writeback() -> folio_end_dropbehind())

If I see Peak Dirty data from the link you shared [1] in single writer case...

Mode MB/s p50 (ms) p99 (ms) p99.9 (ms) Peak Dirty Peak Cache
dontcache (unpatched) 1179 3.2 103.3 170.9 14 MB 4.7 GB
dontcache (patched) 1453 5.4 43.8 57.4 36 GB 45 GB

... this too shows that the submission side is writing more dirty pages, then the completion side able to write it...

I suspect this contention (between submission and completion) could more in IOCB_DONTCACHE case, since the completion side also removes the folio from the page cache within the same xa_lock, which is not the same with normal buffered writes.

Maybe a perf callgraph showing the contention would be nicer thing to add here [1] ;).

[1]: https://markdownpastebin.com/?id=96249deb897a401ba32acbce05312dcc

Quoted 15 lines

Replace the filemap_flush_range() call in generic_write_sync() with a new filemap_dontcache_writeback_range() that uses two rate-limiting mechanisms:

1. Skip-if-busy: check mapping_tagged(PAGECACHE_TAG_WRITEBACK) before flushing. If writeback is already in progress on the mapping, skip the flush entirely. This eliminates writeback submission contention between concurrent writers.

2. Proportional cap: when flushing does occur, cap nr_to_write to the number of pages just written. This prevents any single write from triggering a large flush that would starve concurrent readers.

Quoted 8 lines

Both mechanisms are necessary: skip-if-busy alone causes I/O bursts when the tag clears (reader p99.9 spikes 83x); proportional cap alone still serializes on xarray locks regardless of submission size.

Pages touched under IOCB_DONTCACHE continue to be marked for eviction (dropbehind), so page cache usage remains bounded. Ranges skipped by the busy check are eventually flushed by background writeback or by the next writer to find the tag clear.

Yes, but the next writer may not write the dirty pages, of the previous writer which skipped the flush call right (even if it finds the tag clear)? Because filemap_dontcache_writeback_range( ) passes the range and nr_to_write that means, unless the previous writer dirtied the same range, the new writer won't be able to write the dirty pages of the previous writer correct? So, it is mainly only the background writeback now, which will flush this dirty pages of the writer which skipped the flush (unless of course a fsync/sync call is made).

But having said that, I agree, this patch series is a nice performance improvement overall :)

Quoted 56 lines
---
 include/linux/fs.h |  7 +++++--
 mm/filemap.c       | 29 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)
include/linux/fs.h +5 -2
index 8b3dd145b25ec12b00ac1df17a952d9116b88047..53e9cca1b50a946a1276c49902294c3ae0ab3500 100644
@@ -2610,6 +2610,8 @@ extern int __must_check file_write_and_wait_range(struct file *file,
 						loff_t start, loff_t end);
 int filemap_flush_range(struct address_space *mapping, loff_t start,
 		loff_t end);
+int filemap_dontcache_writeback_range(struct address_space *mapping,
+		loff_t start, loff_t end, ssize_t nr_written);
 
 static inline int file_write_and_wait(struct file *file)
 {
@@ -2645,8 +2647,9 @@ static inline ssize_t generic_write_sync(struct kiocb *iocb, ssize_t count)
 	} else if (iocb->ki_flags & IOCB_DONTCACHE) {
 		struct address_space *mapping = iocb->ki_filp->f_mapping;
 
-		filemap_flush_range(mapping, iocb->ki_pos - count,
-				iocb->ki_pos - 1);
+		filemap_dontcache_writeback_range(mapping,
+				iocb->ki_pos - count,
+				iocb->ki_pos - 1, count);
 	}
 
 	return count;
mm/filemap.c +16 -0
index 406cef06b684a84a1e0c27d8267e95f32282ffdc..af2024b736bef74571cc22ab7e3cde2c8e872efe 100644
@@ -437,6 +437,35 @@ int filemap_flush_range(struct address_space *mapping, loff_t start,
 }
 EXPORT_SYMBOL_GPL(filemap_flush_range);
 
+/**
+ * filemap_dontcache_writeback_range - rate-limited writeback for dontcache I/O
+ * @mapping:	target address_space
+ * @start:	byte offset to start writeback
+ * @end:	last byte offset (inclusive) for writeback
+ * @nr_written:	number of bytes just written by the caller
+ *
+ * Rate-limited writeback for IOCB_DONTCACHE writes.  Skips the flush
+ * entirely if writeback is already in progress on the mapping (skip-if-busy),
+ * and when flushing, caps nr_to_write to the number of pages just written
+ * (proportional cap).  Together these avoid writeback contention between
+ * concurrent writers and prevent I/O bursts that starve readers.
+ *
+ * Return: %0 on success, negative error code otherwise.
+ */
+int filemap_dontcache_writeback_range(struct address_space *mapping,

mm/filemap.c int filemap_flush_range(struct address_space *mapping, loff_t start, · line 465

Quoted 10 lines
mm/filemap.c +10 -0
+		loff_t start, loff_t end, ssize_t nr_written)
+{
+	long nr;
+
+	if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK))
+		return 0;
+
+	nr = (nr_written + PAGE_SIZE - 1) >> PAGE_SHIFT;
+	return filemap_writeback(mapping, start, end, WB_SYNC_NONE, &nr,
+			WB_REASON_BACKGROUND);

Was this rebased against some other tree? I couldn't find it in linux-next. I think, that last argument is wrong.

Quoted 9 lines
mm/filemap.c +3 -0
+}
+EXPORT_SYMBOL_GPL(filemap_dontcache_writeback_range);
+
 /**
  * filemap_flush - mostly a non-blocking flush
  * @mapping:	target address_space
Signature · 2 lines
-- 
2.53.0
author maintainer
#6 lore raw

Re: [PATCH 1/4] mm: fix IOCB_DONTCACHE write performance with rate-limited writeback

Quoted 41 lines · Ritesh Harjani
Quoted 5 lines · Jeff Layton

IOCB_DONTCACHE calls filemap_flush_range() with nr_to_write=LONG_MAX on every write, which flushes all dirty pages in the written range. Under concurrent writers this creates severe serialization on the writeback submission path, causing throughput to collapse to ~47% of buffered I/O with multi-second tail latency.

Yes, between concurrent writers, I agree with the theory.

Quoted 4 lines

Even single-client
sequential writes suffer: on a 512GB file with 256GB RAM, the aggressive flushing triggers dirty throttling that limits throughput to 575 MB/s vs 1442 MB/s with rate-limited writeback.

I am not sure if this 2.5x performance penalty in a "single" sequential writer is due to throttling logic. On giving it some thoughts, I suspect if this is because, the submission side and the completion side both takes the xa_lock and hence could be contending on that.

For e.g. since this patch skips doing the flush the second time, (note that writeback is active when the same writer dirtied the page during previous write), this allows the writer to do more work of writing data to page cache pages, instead of waiting on the xa_lock which the completion callback could be holding (folio_end_writeback() -> folio_end_dropbehind())

If I see Peak Dirty data from the link you shared [1] in single writer case...

Mode MB/s p50 (ms) p99 (ms) p99.9 (ms) Peak Dirty Peak Cache
dontcache (unpatched) 1179 3.2 103.3 170.9 14 MB 4.7 GB
dontcache (patched) 1453 5.4 43.8 57.4 36 GB 45 GB

... this too shows that the submission side is writing more dirty pages, then the completion side able to write it...

I suspect this contention (between submission and completion) could more in IOCB_DONTCACHE case, since the completion side also removes the folio from the page cache within the same xa_lock, which is not the same with normal buffered writes.

Quoted 5 lines

Maybe a perf callgraph showing the contention would be nicer thing to add here [1] ;).

[1]: https://markdownpastebin.com/?id=96249deb897a401ba32acbce05312dcc

That's an interesting point.

The theory I've been operating on is that the flusher thread ends up squatting on the xa_lock for a while when memory gets tight, and that blocks other readers and writers. Staying ahead of the dirty limits and limiting the amount of flush work that each writer does alleviates contention for that lock and that's what improves the performance.

You're right though. I'll plan to play around with perf and see if I can confirm the theory.

Quoted 33 lines
Quoted 15 lines

Replace the filemap_flush_range() call in generic_write_sync() with a new filemap_dontcache_writeback_range() that uses two rate-limiting mechanisms:

1. Skip-if-busy: check mapping_tagged(PAGECACHE_TAG_WRITEBACK) before flushing. If writeback is already in progress on the mapping, skip the flush entirely. This eliminates writeback submission contention between concurrent writers.

2. Proportional cap: when flushing does occur, cap nr_to_write to the number of pages just written. This prevents any single write from triggering a large flush that would starve concurrent readers.

Quoted 8 lines

Both mechanisms are necessary: skip-if-busy alone causes I/O bursts when the tag clears (reader p99.9 spikes 83x); proportional cap alone still serializes on xarray locks regardless of submission size.

Pages touched under IOCB_DONTCACHE continue to be marked for eviction (dropbehind), so page cache usage remains bounded. Ranges skipped by the busy check are eventually flushed by background writeback or by the next writer to find the tag clear.

Yes, but the next writer may not write the dirty pages, of the previous writer which skipped the flush call right (even if it finds the tag clear)? Because filemap_dontcache_writeback_range( ) passes the range and nr_to_write that means, unless the previous writer dirtied the same range, the new writer won't be able to write the dirty pages of the previous writer correct? So, it is mainly only the background writeback now, which will flush this dirty pages of the writer which skipped the flush (unless of course a fsync/sync call is made).

Quoted 3 lines

But having said that, I agree, this patch series is a nice performance improvement overall :)

Correct. When DONTCACHE writers end up skipping the flush, we rely on VM dirty limits to eventually take care of flushing the data that got skipped. That's why the DONTCACHE dirty pagecache max size ends up looking close to buffered mode's.

I did play with a patch that had the writers attempt to flush 4x more than they had written when memory was tight to compensate for that, but it ended up performing worse than this set. It's possible that tuning that down to 2x or so would do better, but I decided to just stop here and post what I had.

Quoted 61 lines
Quoted 61 lines
---
 include/linux/fs.h |  7 +++++--
 mm/filemap.c       | 29 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)
include/linux/fs.h +5 -2
index 8b3dd145b25ec12b00ac1df17a952d9116b88047..53e9cca1b50a946a1276c49902294c3ae0ab3500 100644
@@ -2610,6 +2610,8 @@ extern int __must_check file_write_and_wait_range(struct file *file,
 						loff_t start, loff_t end);
 int filemap_flush_range(struct address_space *mapping, loff_t start,
 		loff_t end);
+int filemap_dontcache_writeback_range(struct address_space *mapping,
+		loff_t start, loff_t end, ssize_t nr_written);
 
 static inline int file_write_and_wait(struct file *file)
 {
@@ -2645,8 +2647,9 @@ static inline ssize_t generic_write_sync(struct kiocb *iocb, ssize_t count)
 	} else if (iocb->ki_flags & IOCB_DONTCACHE) {
 		struct address_space *mapping = iocb->ki_filp->f_mapping;
 
-		filemap_flush_range(mapping, iocb->ki_pos - count,
-				iocb->ki_pos - 1);
+		filemap_dontcache_writeback_range(mapping,
+				iocb->ki_pos - count,
+				iocb->ki_pos - 1, count);
 	}
 
 	return count;
mm/filemap.c +21 -0
index 406cef06b684a84a1e0c27d8267e95f32282ffdc..af2024b736bef74571cc22ab7e3cde2c8e872efe 100644
@@ -437,6 +437,35 @@ int filemap_flush_range(struct address_space *mapping, loff_t start,
 }
 EXPORT_SYMBOL_GPL(filemap_flush_range);
 
+/**
+ * filemap_dontcache_writeback_range - rate-limited writeback for dontcache I/O
+ * @mapping:	target address_space
+ * @start:	byte offset to start writeback
+ * @end:	last byte offset (inclusive) for writeback
+ * @nr_written:	number of bytes just written by the caller
+ *
+ * Rate-limited writeback for IOCB_DONTCACHE writes.  Skips the flush
+ * entirely if writeback is already in progress on the mapping (skip-if-busy),
+ * and when flushing, caps nr_to_write to the number of pages just written
+ * (proportional cap).  Together these avoid writeback contention between
+ * concurrent writers and prevent I/O bursts that starve readers.
+ *
+ * Return: %0 on success, negative error code otherwise.
+ */
+int filemap_dontcache_writeback_range(struct address_space *mapping,
+		loff_t start, loff_t end, ssize_t nr_written)
+{
+	long nr;
+
+	if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK))
Quoted 9 lines

mm/filemap.c int filemap_flush_range(struct address_space *mapping, loff_t start, · line 465

Quoted 5 lines
mm/filemap.c +5 -0
+		return 0;
+
+	nr = (nr_written + PAGE_SIZE - 1) >> PAGE_SHIFT;
+	return filemap_writeback(mapping, start, end, WB_SYNC_NONE, &nr,
+			WB_REASON_BACKGROUND);

Was this rebased against some other tree? I couldn't find it in linux-next. I think, that last argument is wrong.

Yes, my apologies. I think this must have been a bad merge on my part during the rebase. I'll post a v2 in the near future.

Quoted 9 lines
Quoted 9 lines
mm/filemap.c +3 -0
+}
+EXPORT_SYMBOL_GPL(filemap_dontcache_writeback_range);
+
 /**
  * filemap_flush - mostly a non-blocking flush
  * @mapping:	target address_space
Signature · 2 lines
-- 
2.53.0

Thanks for the review!

Signature · 1 line
Jeff Layton <[email protected]>
#7 lore raw

Re: [PATCH 1/4] mm: fix IOCB_DONTCACHE write performance with rate-limited writeback

Quoted 12 lines · Jeff Layton
Quoted 11 lines · Ritesh Harjani
Quoted 5 lines · Jeff Layton

IOCB_DONTCACHE calls filemap_flush_range() with nr_to_write=LONG_MAX on every write, which flushes all dirty pages in the written range. Under concurrent writers this creates severe serialization on the writeback submission path, causing throughput to collapse to ~47% of buffered I/O with multi-second tail latency.

Yes, between concurrent writers, I agree with the theory.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Even single-client
sequential writes suffer: on a 512GB file with 256GB RAM, the aggressive flushing triggers dirty throttling that limits throughput to 575 MB/s vs 1442 MB/s with rate-limited writeback.

I am not sure if this 2.5x performance penalty in a "single" sequential

Sorry my bad.. I mis-understood this 2.5x delta at first.

So in a single sequential write case, what this patch is mainly improving is from unpatched RWF_DONTCACHE (1179 MB/s) to patched RWF_DONTCACHE (1453 MB/s) = ~23% improvement.

So the below theory which I was talking about was from this delta perspective i.e. comparing unpatched v/s patched RWF_DONTCACHE mode.

Quoted 30 lines
Quoted 24 lines

writer is due to throttling logic. On giving it some thoughts, I suspect if this is because, the submission side and the completion side both takes the xa_lock and hence could be contending on that.

For e.g. since this patch skips doing the flush the second time, (note that writeback is active when the same writer dirtied the page during previous write), this allows the writer to do more work of writing data to page cache pages, instead of waiting on the xa_lock which the completion callback could be holding (folio_end_writeback() -> folio_end_dropbehind())

If I see Peak Dirty data from the link you shared [1] in single writer case...

Mode MB/s p50 (ms) p99 (ms) p99.9 (ms) Peak Dirty Peak Cache
dontcache (unpatched) 1179 3.2 103.3 170.9 14 MB 4.7 GB
dontcache (patched) 1453 5.4 43.8 57.4 36 GB 45 GB

... this too shows that the submission side is writing more dirty pages, then the completion side able to write it...

I suspect this contention (between submission and completion) could more in IOCB_DONTCACHE case, since the completion side also removes the folio from the page cache within the same xa_lock, which is not the same with normal buffered writes.

Quoted 5 lines

Maybe a perf callgraph showing the contention would be nicer thing to add here [1] ;).

[1]: https://markdownpastebin.com/?id=96249deb897a401ba32acbce05312dcc

Quoted 8 lines

That's an interesting point.

The theory I've been operating on is that the flusher thread ends up squatting on the xa_lock for a while when memory gets tight, and that blocks other readers and writers. Staying ahead of the dirty limits and limiting the amount of flush work that each writer does alleviates contention for that lock and that's what improves the performance.

That's right for comparison between buffered write against RWF_DONTCACHE. But what I meant in above was for the improvement from 1179 MB/s to 1453 MB/s could be accounted to less contention on xa_lock on patched version v/s unpatched version for single write sequential testcase.

Quoted 3 lines

You're right though. I'll plan to play around with perf and see if I can confirm the theory.

Yes, thanks, that will be nice to have!

-ritesh

author maintainer
#8 lore raw

PATCH 2/4 mm: add atomic flush guard for IOCB_DONTCACHE writeback

In reply to Jeff Layton

When the PAGECACHE_TAG_WRITEBACK tag clears after a round of writeback completes, all concurrent IOCB_DONTCACHE writers see the tag clear simultaneously and submit proportional flushes at once — a thundering herd that causes p99.9 tail latency spikes.

Add an AS_DONTCACHE_FLUSHING flag to the address_space and use test_and_set_bit() to ensure at most one IOCB_DONTCACHE writer flushes at a time. Other writers that find the bit set skip their flush entirely. The bit is cleared when the flush completes.

Together with the existing skip-if-busy check on PAGECACHE_TAG_WRITEBACK (which provides temporal rate limiting by skipping flushes while prior writeback is still draining), this creates a two-level guard: the writeback tag paces flush frequency to match device speed, while the atomic flag prevents the thundering herd at tag-clear transitions.

Additionally, add a dirty pressure escape hatch: when dirty pages exceed 75% of the dirty_ratio threshold, bypass the WRITEBACK tag skip and attempt to flush anyway. Under heavy multi-writer load, the skip-if-busy check can cause dirty pages to accumulate (most writers skip because writeback is always in progress), eventually triggering balance_dirty_pages() throttling with severe tail latency. By forcing extra flushes when dirty pressure is high, dontcache writers help drain dirty pages before the throttle threshold is hit.

---
 include/linux/pagemap.h |  1 +
 mm/filemap.c            | 36 +++++++++++++++++++++++++++++-------
 2 files changed, 30 insertions(+), 7 deletions(-)
include/linux/pagemap.h +1 -0
index 31a848485ad9d9850d37185418349b89e6efe420..e71bf75f6c22d0da5330c17c6e525cb12d254dfe 100644
@@ -210,6 +210,7 @@ enum mapping_flags {
 	AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM = 9,
 	AS_KERNEL_FILE = 10,	/* mapping for a fake kernel file that shouldn't
 				   account usage to user cgroups */
+	AS_DONTCACHE_FLUSHING = 11, /* dontcache writeback in progress */
 	/* Bits 16-25 are used for FOLIO_ORDER */
 	AS_FOLIO_ORDER_BITS = 5,
 	AS_FOLIO_ORDER_MIN = 16,
mm/filemap.c +29 -7
index af2024b736bef74571cc22ab7e3cde2c8e872efe..1b5577bd4eda8ad8ee182e58acd50d99f0a8f9f5 100644
@@ -444,11 +444,21 @@ EXPORT_SYMBOL_GPL(filemap_flush_range);
  * @end:	last byte offset (inclusive) for writeback
  * @nr_written:	number of bytes just written by the caller
  *
- * Rate-limited writeback for IOCB_DONTCACHE writes.  Skips the flush
- * entirely if writeback is already in progress on the mapping (skip-if-busy),
- * and when flushing, caps nr_to_write to the number of pages just written
- * (proportional cap).  Together these avoid writeback contention between
- * concurrent writers and prevent I/O bursts that starve readers.
+ * Rate-limited writeback for IOCB_DONTCACHE writes.  Uses three guards to
+ * avoid writeback contention between concurrent writers:
+ *
+ *  1. Skip-if-busy: if writeback is already in progress on the mapping
+ *     (PAGECACHE_TAG_WRITEBACK set), skip the flush — unless dirty pages
+ *     are approaching the dirty_ratio threshold, in which case flush anyway
+ *     to help drain before balance_dirty_pages() throttles all writers.
+ *
+ *  2. Atomic flush guard: use test_and_set_bit(AS_DONTCACHE_FLUSHING) so
+ *     that at most one dontcache writer flushes at a time, preventing a
+ *     thundering herd when the writeback tag clears and multiple writers
+ *     try to flush simultaneously.
+ *
+ *  3. Proportional cap: cap nr_to_write to the number of pages just written,
+ *     preventing any single flush from starving concurrent readers.
  *
  * Return: %0 on success, negative error code otherwise.
  */
@@ -456,13 +466,25 @@ int filemap_dontcache_writeback_range(struct address_space *mapping,
 		loff_t start, loff_t end, ssize_t nr_written)
 {
 	long nr;
+	int ret;
+
+	if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) {
+		unsigned long thresh, bg_thresh, dirty;
 
-	if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK))
+		global_dirty_limits(&bg_thresh, &thresh);
+		dirty = global_node_page_state(NR_FILE_DIRTY);
+		if (dirty < thresh * 3 / 4)
+			return 0;
+	}
+
+	if (test_and_set_bit(AS_DONTCACHE_FLUSHING, &mapping->flags))
 		return 0;
 
 	nr = (nr_written + PAGE_SIZE - 1) >> PAGE_SHIFT;
-	return filemap_writeback(mapping, start, end, WB_SYNC_NONE, &nr,
+	ret = filemap_writeback(mapping, start, end, WB_SYNC_NONE, &nr,
 			WB_REASON_BACKGROUND);
+	clear_bit(AS_DONTCACHE_FLUSHING, &mapping->flags);
+	return ret;
 }
 EXPORT_SYMBOL_GPL(filemap_dontcache_writeback_range);
 
Signature · 1 line
2.53.0
#9 lore raw

Re: [PATCH 2/4] mm: add atomic flush guard for IOCB_DONTCACHE writeback

Quoted 9 lines · Jeff Layton

When the PAGECACHE_TAG_WRITEBACK tag clears after a round of writeback completes, all concurrent IOCB_DONTCACHE writers see the tag clear simultaneously and submit proportional flushes at once — a thundering herd that causes p99.9 tail latency spikes.

Add an AS_DONTCACHE_FLUSHING flag to the address_space and use test_and_set_bit() to ensure at most one IOCB_DONTCACHE writer flushes at a time. Other writers that find the bit set skip their flush entirely. The bit is cleared when the flush completes.

This sounds like a bad reimplementation of the single writeback thread :)

Have you considered stopping to do in-caller writeback for IOCB_DONTCACHE vs just leaving it to the writeback daeon?

Either by totally disabling the writeback and just leaving the dropbehind bit, or by queuing up wb_writeback_work instances for the ranges, or by just increasing the pressure for the writeback daemon. Note that with all schemes including the one in this patch we might eventually run into writeback scalability limits, which will require multiple writeback workers.

author maintainer
#10 lore raw

Re: [PATCH 2/4] mm: add atomic flush guard for IOCB_DONTCACHE writeback

Quoted 17 lines · Christoph Hellwig
Quoted 9 lines · Jeff Layton

When the PAGECACHE_TAG_WRITEBACK tag clears after a round of writeback completes, all concurrent IOCB_DONTCACHE writers see the tag clear simultaneously and submit proportional flushes at once — a thundering herd that causes p99.9 tail latency spikes.

Add an AS_DONTCACHE_FLUSHING flag to the address_space and use test_and_set_bit() to ensure at most one IOCB_DONTCACHE writer flushes at a time. Other writers that find the bit set skip their flush entirely. The bit is cleared when the flush completes.

This sounds like a bad reimplementation of the single writeback thread :)

Have you considered stopping to do in-caller writeback for IOCB_DONTCACHE vs just leaving it to the writeback daeon?

Quoted 6 lines

Either by totally disabling the writeback and just leaving the dropbehind bit, or by queuing up wb_writeback_work instances for the ranges, or by just increasing the pressure for the writeback daemon. Note that with all schemes including the one in this patch we might eventually run into writeback scalability limits, which will require multiple writeback workers.

I did test a "dropbehind" mode that just set the dropbehind bit without doing the flush at the end of the write. It was better than stock dontcache but the tail latencies were still pretty bad.

I think having each writer do some writeback submission work makes a lot of sense. It helps keep the dirty pages below the dirty thresholds and doesn't seem to tax each writing task _too_ much. The trick is avoiding lock contention while doing it.

I think what would be ideal would be to have some (lockless) mechanism to say "there is enough data touched by the range just written to kick off a write that's a suitable size for the backing store". Each writer could check that and then kick off writeback for an approprite range.

I think this even could be beneficial in the normal buffered write codepath too.

Anyway, I'll play around with this idea some more and come back with a v2.

Thanks for the review!

Signature · 1 line
Jeff Layton <[email protected]>
#11 lore raw

Re: [PATCH 2/4] mm: add atomic flush guard for IOCB_DONTCACHE writeback

Quoted 10 lines · Jeff Layton
Quoted 9 lines

Have you considered stopping to do in-caller writeback for IOCB_DONTCACHE vs just leaving it to the writeback daeon?

Either by totally disabling the writeback and just leaving the dropbehind bit, or by queuing up wb_writeback_work instances for the ranges, or by just increasing the pressure for the writeback daemon. Note that with all schemes including the one in this patch we might eventually run into writeback scalability limits, which will require multiple writeback workers.

Quoted 8 lines

I did test a "dropbehind" mode that just set the dropbehind bit without doing the flush at the end of the write. It was better than stock dontcache but the tail latencies were still pretty bad.

I think having each writer do some writeback submission work makes a lot of sense. It helps keep the dirty pages below the dirty thresholds and doesn't seem to tax each writing task _too_ much. The trick is avoiding lock contention while doing it.

Well, an any time you hit a shared resources from multiple threads you
create that lock contention. Which is why in file system and writeback
land we've moved away from random user processes hitting both data and metadata (e.g. XFS AIL) writeback as it leads to these scalability issues. At some point we might run out of steam in a single thread, although so far that's mostly been because it does stupid things (e.g. writeback on file systems doing complex allocator stuff).

Quoted 4 lines

I think what would be ideal would be to have some (lockless) mechanism to say "there is enough data touched by the range just written to kick off a write that's a suitable size for the backing store". Each writer could check that and then kick off writeback for an approprite range.

And that is called the writeback thread. So what we should do there is to make sure we queue up writeback on it for each dontcache write. Initially queuing up a wb_writeback_work for each range might be first approximation, although we should probably find a way to just increase a threshold if going down that road.

Quoted 2 lines

I think this even could be beneficial in the normal buffered write codepath too.

Yes, we've had lots of observation that the current 30s timeout is actively harmful. Especially on SSDs, but even on HDD just keeping the active might make sense.

author maintainer
#12 lore raw

Re: [PATCH 2/4] mm: add atomic flush guard for IOCB_DONTCACHE writeback

Quoted 33 lines · Christoph Hellwig
Quoted 10 lines · Jeff Layton
Quoted 9 lines

Have you considered stopping to do in-caller writeback for IOCB_DONTCACHE vs just leaving it to the writeback daeon?

Either by totally disabling the writeback and just leaving the dropbehind bit, or by queuing up wb_writeback_work instances for the ranges, or by just increasing the pressure for the writeback daemon. Note that with all schemes including the one in this patch we might eventually run into writeback scalability limits, which will require multiple writeback workers.

Quoted 8 lines

I did test a "dropbehind" mode that just set the dropbehind bit without doing the flush at the end of the write. It was better than stock dontcache but the tail latencies were still pretty bad.

I think having each writer do some writeback submission work makes a lot of sense. It helps keep the dirty pages below the dirty thresholds and doesn't seem to tax each writing task _too_ much. The trick is avoiding lock contention while doing it.

Well, an any time you hit a shared resources from multiple threads you
create that lock contention. Which is why in file system and writeback
land we've moved away from random user processes hitting both data and metadata (e.g. XFS AIL) writeback as it leads to these scalability issues. At some point we might run out of steam in a single thread, although so far that's mostly been because it does stupid things (e.g. writeback on file systems doing complex allocator stuff).

Quoted 4 lines

I think what would be ideal would be to have some (lockless) mechanism to say "there is enough data touched by the range just written to kick off a write that's a suitable size for the backing store". Each writer could check that and then kick off writeback for an approprite range.

Quoted 6 lines

And that is called the writeback thread. So what we should do there is to make sure we queue up writeback on it for each dontcache write. Initially queuing up a wb_writeback_work for each range might be first approximation, although we should probably find a way to just increase a threshold if going down that road.

Ok, I like that idea. I'll give that a shot and see how it does. I'll note that there is no way to specify an inode or range (yet) in wb_writeback_work().

Do you think it's sufficient to just call something like wakeup_flusher_threads_bdi() after every RWF_DONTCACHE write, or should I extend wb_writeback_work to allow for doing work on a range within a single inode?

Quoted 6 lines
Quoted 2 lines

I think this even could be beneficial in the normal buffered write codepath too.

Yes, we've had lots of observation that the current 30s timeout is actively harmful. Especially on SSDs, but even on HDD just keeping the active might make sense.

Signature · 1 line
Jeff Layton <[email protected]>
#13 lore raw

Re: [PATCH 2/4] mm: add atomic flush guard for IOCB_DONTCACHE writeback

Quoted 7 lines · Jeff Layton
Quoted 6 lines

And that is called the writeback thread. So what we should do there is to make sure we queue up writeback on it for each dontcache write. Initially queuing up a wb_writeback_work for each range might be first approximation, although we should probably find a way to just increase a threshold if going down that road.

Quoted 8 lines

Ok, I like that idea. I'll give that a shot and see how it does. I'll note that there is no way to specify an inode or range (yet) in wb_writeback_work().

Do you think it's sufficient to just call something like wakeup_flusher_threads_bdi() after every RWF_DONTCACHE write, or should I extend wb_writeback_work to allow for doing work on a range within a single inode?

I don't think we care about what exact data is written back as this is not an integrity operation. So just waking the flusher thread sounds like the right thing, but we might also need a way to communicate the higher writeback target.

author maintainer
#14 lore raw

PATCH 3/4 testing: add nfsd-io-bench NFS server benchmark suite

In reply to Jeff Layton

Add a benchmark suite for testing NFSD I/O mode performance using fio with the libnfs backend against an NFS server on localhost. Tests buffered, dontcache, and direct I/O modes via NFSD debugfs controls.

Includes:
- fio job files for sequential/random read/write, multi-writer, noisy-neighbor, and latency-sensitive reader workloads
- run-benchmarks.sh: orchestrates test matrix with mode switching
- parse-results.sh: extracts metrics from fio JSON output
- setup-server.sh: configures NFS export for testing

---
 .../testing/nfsd-io-bench/fio-jobs/lat-reader.fio  |  15 +
 .../testing/nfsd-io-bench/fio-jobs/multi-write.fio |  14 +
 .../nfsd-io-bench/fio-jobs/noisy-writer.fio        |  14 +
 tools/testing/nfsd-io-bench/fio-jobs/rand-read.fio |  15 +
 .../testing/nfsd-io-bench/fio-jobs/rand-write.fio  |  15 +
 tools/testing/nfsd-io-bench/fio-jobs/seq-read.fio  |  14 +
 tools/testing/nfsd-io-bench/fio-jobs/seq-write.fio |  14 +
 .../testing/nfsd-io-bench/scripts/parse-results.sh | 238 +++++++++
 .../nfsd-io-bench/scripts/run-benchmarks.sh        | 543 +++++++++++++++++++++
 .../testing/nfsd-io-bench/scripts/setup-server.sh  |  94 ++++
 10 files changed, 976 insertions(+)
tools/testing/nfsd-io-bench/fio-jobs/lat-reader.fio new file +15 -0
new file mode 100644
index 0000000000000000000000000000000000000000..61af37e8b860bc3aa8b64e0a6e68f7eb60ae2740
@@ -0,0 +1,15 @@
+[global]
+ioengine=nfs
+nfs_url=nfs://localhost/export
+direct=0
+bs=4k
+numjobs=16
+runtime=300
+time_based=1
+group_reporting=1
+rw=randread
+log_avg_msec=1000
+write_bw_log=latreader
+write_lat_log=latreader
+
+[lat_reader]
tools/testing/nfsd-io-bench/fio-jobs/multi-write.fio new file +14 -0
new file mode 100644
index 0000000000000000000000000000000000000000..16b792aecabbdfb4abb0c432593344352ed22ff6
@@ -0,0 +1,14 @@
+[global]
+ioengine=nfs
+nfs_url=nfs://localhost/export
+direct=0
+bs=1M
+numjobs=16
+time_based=0
+group_reporting=1
+rw=write
+log_avg_msec=1000
+write_bw_log=multiwrite
+write_lat_log=multiwrite
+
+[writer]
tools/testing/nfsd-io-bench/fio-jobs/noisy-writer.fio new file +14 -0
new file mode 100644
index 0000000000000000000000000000000000000000..615154a7737e84308bcf4891dd27e87aec43fea7
@@ -0,0 +1,14 @@
+[global]
+ioengine=nfs
+nfs_url=nfs://localhost/export
+direct=0
+bs=1M
+numjobs=16
+time_based=0
+group_reporting=1
+rw=write
+log_avg_msec=1000
+write_bw_log=noisywriter
+write_lat_log=noisywriter
+
+[bulk_writer]
tools/testing/nfsd-io-bench/fio-jobs/rand-read.fio new file +15 -0
new file mode 100644
index 0000000000000000000000000000000000000000..501bae7416a8ba514e4166469e60c89e48a5fc20
@@ -0,0 +1,15 @@
+[global]
+ioengine=nfs
+nfs_url=nfs://localhost/export
+direct=0
+bs=4k
+numjobs=16
+runtime=300
+time_based=1
+group_reporting=1
+rw=randread
+log_avg_msec=1000
+write_bw_log=randread
+write_lat_log=randread
+
+[randread]
tools/testing/nfsd-io-bench/fio-jobs/rand-write.fio new file +15 -0
new file mode 100644
index 0000000000000000000000000000000000000000..d891d04197aead906895031a9ab0ecdc86a85d58
@@ -0,0 +1,15 @@
+[global]
+ioengine=nfs
+nfs_url=nfs://localhost/export
+direct=0
+bs=64k
+numjobs=16
+runtime=300
+time_based=1
+group_reporting=1
+rw=randwrite
+log_avg_msec=1000
+write_bw_log=randwrite
+write_lat_log=randwrite
+
+[randwrite]
tools/testing/nfsd-io-bench/fio-jobs/seq-read.fio new file +14 -0
new file mode 100644
index 0000000000000000000000000000000000000000..6e24ab355026a243fac47ace8c6da7967550cf9a
@@ -0,0 +1,14 @@
+[global]
+ioengine=nfs
+nfs_url=nfs://localhost/export
+direct=0
+bs=1M
+numjobs=16
+time_based=0
+group_reporting=1
+rw=read
+log_avg_msec=1000
+write_bw_log=seqread
+write_lat_log=seqread
+
+[seqread]
tools/testing/nfsd-io-bench/fio-jobs/seq-write.fio new file +14 -0
new file mode 100644
index 0000000000000000000000000000000000000000..260858e345f5aaea239a7904089c5111aa350ccb
@@ -0,0 +1,14 @@
+[global]
+ioengine=nfs
+nfs_url=nfs://localhost/export
+direct=0
+bs=1M
+numjobs=16
+time_based=0
+group_reporting=1
+rw=write
+log_avg_msec=1000
+write_bw_log=seqwrite
+write_lat_log=seqwrite
+
+[seqwrite]
tools/testing/nfsd-io-bench/scripts/parse-results.sh new file +238 -0

238 lines not on this page · raw message

tools/testing/nfsd-io-bench/scripts/run-benchmarks.sh new file +543 -0

543 lines not on this page · raw message

tools/testing/nfsd-io-bench/scripts/setup-server.sh new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
2.53.0
author maintainer
#15 lore raw

PATCH 4/4 testing: add dontcache-bench local filesystem benchmark suite

In reply to Jeff Layton

Add a benchmark suite for testing IOCB_DONTCACHE on local filesystems via fio's io_uring engine with the RWF_DONTCACHE flag.

The suite mirrors the nfsd-io-bench test matrix but uses io_uring with the "uncached" fio option instead of NFSD debugfs mode switching:
- uncached=0: standard buffered I/O
- uncached=1: RWF_DONTCACHE
- Mode 2 uses O_DIRECT via fio's --direct=1

Includes fio job files, run-benchmarks.sh, and parse-results.sh.

---
 .../dontcache-bench/fio-jobs/lat-reader.fio        |  12 +
 .../dontcache-bench/fio-jobs/multi-write.fio       |   9 +
 .../dontcache-bench/fio-jobs/noisy-writer.fio      |  12 +
 .../testing/dontcache-bench/fio-jobs/rand-read.fio |  13 +
 .../dontcache-bench/fio-jobs/rand-write.fio        |  13 +
 .../testing/dontcache-bench/fio-jobs/seq-read.fio  |  13 +
 .../testing/dontcache-bench/fio-jobs/seq-write.fio |  13 +
 .../dontcache-bench/scripts/parse-results.sh       | 238 ++++++++++
 .../dontcache-bench/scripts/run-benchmarks.sh      | 518 +++++++++++++++++++++
 9 files changed, 841 insertions(+)
tools/testing/dontcache-bench/fio-jobs/lat-reader.fio new file +12 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e221e7aedec9d20953898d19dc44beb0588a2d6e
@@ -0,0 +1,12 @@
+[global]
+ioengine=io_uring
+direct=0
+bs=4k
+numjobs=1
+time_based=0
+rw=read
+log_avg_msec=1000
+write_bw_log=latreader
+write_lat_log=latreader
+
+[latreader]
tools/testing/dontcache-bench/fio-jobs/multi-write.fio new file +9 -0
new file mode 100644
index 0000000000000000000000000000000000000000..8fc0770f5860667249bef3553b9d9624eb0e2213
@@ -0,0 +1,9 @@
+[global]
+ioengine=io_uring
+direct=0
+bs=1M
+numjobs=1
+time_based=0
+rw=write
+
+[multiwrite]
tools/testing/dontcache-bench/fio-jobs/noisy-writer.fio new file +12 -0
new file mode 100644
index 0000000000000000000000000000000000000000..4524eebd4642f292e0a6093319fc573b79820ff8
@@ -0,0 +1,12 @@
+[global]
+ioengine=io_uring
+direct=0
+bs=1M
+numjobs=1
+time_based=0
+rw=write
+log_avg_msec=1000
+write_bw_log=noisywriter
+write_lat_log=noisywriter
+
+[noisywriter]
tools/testing/dontcache-bench/fio-jobs/rand-read.fio new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e281fa82b86ad12ca4b2dc4fd082d62415dd967a
@@ -0,0 +1,13 @@
+[global]
+ioengine=io_uring
+direct=0
+bs=4k
+numjobs=1
+iodepth=16
+time_based=0
+rw=randread
+log_avg_msec=1000
+write_bw_log=randread
+write_lat_log=randread
+
+[randread]
tools/testing/dontcache-bench/fio-jobs/rand-write.fio new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..cf53bc6f14b9e131793cdcdd4c431ec4e0b79dba
@@ -0,0 +1,13 @@
+[global]
+ioengine=io_uring
+direct=0
+bs=4k
+numjobs=1
+iodepth=16
+time_based=0
+rw=randwrite
+log_avg_msec=1000
+write_bw_log=randwrite
+write_lat_log=randwrite
+
+[randwrite]
tools/testing/dontcache-bench/fio-jobs/seq-read.fio new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ef87921465a7d8221dda0c6d01c0d4be14806703
@@ -0,0 +1,13 @@
+[global]
+ioengine=io_uring
+direct=0
+bs=1M
+numjobs=1
+iodepth=16
+time_based=0
+rw=read
+log_avg_msec=1000
+write_bw_log=seqread
+write_lat_log=seqread
+
+[seqread]
tools/testing/dontcache-bench/fio-jobs/seq-write.fio new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..da3082f9b391e1112eb25756136e5b7f27d6b5e2
@@ -0,0 +1,13 @@
+[global]
+ioengine=io_uring
+direct=0
+bs=1M
+numjobs=1
+iodepth=16
+time_based=0
+rw=write
+log_avg_msec=1000
+write_bw_log=seqwrite
+write_lat_log=seqwrite
+
+[seqwrite]
tools/testing/dontcache-bench/scripts/parse-results.sh new file +238 -0

238 lines not on this page · raw message

tools/testing/dontcache-bench/scripts/run-benchmarks.sh new file +518 -0

518 lines not on this page · raw message

Signature · 1 line
2.53.0