mirror-linux/fs/iomap
Jinliang Zheng 177bb4cba9
iomap: avoid unnecessary ifs_set_range_uptodate() with locks
In the buffer write path, iomap_set_range_uptodate() is called every
time iomap_end_write() is called. But if folio_test_uptodate() holds, we
know that all blocks in this folio are already in the uptodate state, so
there is no need to go deep into the critical section of state_lock to
execute bitmap_set().

This is because the folios always creep towards ifs_is_fully_uptodate()
state and once they've gotten there folio_mark_uptodate() is called, which
means the folio is uptodate.

Then once a folio is uptodate, there is no route back to !uptodate without
going through the removal of the folio from the page cache. Therefore, it's
fine to use folio_test_uptodate() to short-circuit unnecessary code paths.

Although state_lock may not have significant lock contention due to
folio lock, this patch at least reduces the number of instructions,
especially the expensive lock-prefixed instructions.

Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
Link: https://lore.kernel.org/20250711081207.1782667-1-alexjlzheng@tencent.com
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-07-11 11:42:44 +02:00
..
Makefile iomap: split bios to zone append limits in the submission handlers 2025-02-06 13:02:14 +01:00
buffered-io.c iomap: avoid unnecessary ifs_set_range_uptodate() with locks 2025-07-11 11:42:44 +02:00
direct-io.c vfs-6.15-rc1.iomap 2025-03-24 10:19:31 -07:00
fiemap.c iomap: introduce a full map advance helper 2025-02-26 09:42:37 +01:00
internal.h iomap: optionally use ioends for direct I/O 2025-02-06 13:02:14 +01:00
ioend.c iomap: add a io_private field to struct iomap_ioend 2025-02-06 13:02:15 +01:00
iter.c iomap: rename iomap_iter processed field to status 2025-02-26 09:42:37 +01:00
seek.c iomap: rename iomap_iter processed field to status 2025-02-26 09:42:37 +01:00
swapfile.c iomap: introduce a full map advance helper 2025-02-26 09:42:37 +01:00
trace.c iomap: Add DIO tracepoints 2023-04-21 08:54:47 -07:00
trace.h iomap: trace: Add missing flags to [IOMAP_|IOMAP_F_]FLAGS_STRINGS 2025-04-15 10:30:49 +02:00