All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mm/filemap: don't initiate writeback if mapping has no dirty pages
@ 2019-07-22  9:36 Konstantin Khlebnikov
  2019-07-22  9:36 ` [PATCH 2/2] mm/filemap: rewrite mapping_needs_writeback in less fancy manner Konstantin Khlebnikov
  2019-07-23  0:52 ` [PATCH 1/2] mm/filemap: don't initiate writeback if mapping has no dirty pages Andrew Morton
  0 siblings, 2 replies; 8+ messages in thread
From: Konstantin Khlebnikov @ 2019-07-22  9:36 UTC (permalink / raw)
  To: linux-mm, Andrew Morton, linux-kernel
  Cc: Tejun Heo, Jens Axboe, Johannes Weiner

Functions like filemap_write_and_wait_range() should do nothing if inode
has no dirty pages or pages currently under writeback. But they anyway
construct struct writeback_control and this does some atomic operations
if CONFIG_CGROUP_WRITEBACK=y - on fast path it locks inode->i_lock and
updates state of writeback ownership, on slow path might be more work.
Current this path is safely avoided only when inode mapping has no pages.

For example generic_file_read_iter() calls filemap_write_and_wait_range()
at each O_DIRECT read - pretty hot path.

This patch skips starting new writeback if mapping has no dirty tags set.
If writeback is already in progress filemap_write_and_wait_range() will
wait for it.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 mm/filemap.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index d0cf700bf201..d9572593e5c7 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -408,7 +408,8 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
 		.range_end = end,
 	};
 
-	if (!mapping_cap_writeback_dirty(mapping))
+	if (!mapping_cap_writeback_dirty(mapping) ||
+	    !mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
 		return 0;
 
 	wbc_attach_fdatawrite_inode(&wbc, mapping->host);


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-07-30 18:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-22  9:36 [PATCH 1/2] mm/filemap: don't initiate writeback if mapping has no dirty pages Konstantin Khlebnikov
2019-07-22  9:36 ` [PATCH 2/2] mm/filemap: rewrite mapping_needs_writeback in less fancy manner Konstantin Khlebnikov
2019-07-23  0:52 ` [PATCH 1/2] mm/filemap: don't initiate writeback if mapping has no dirty pages Andrew Morton
2019-07-23  8:16   ` Konstantin Khlebnikov
2019-07-30 14:14     ` Jan Kara
2019-07-30 14:57       ` Konstantin Khlebnikov
2019-07-30 15:48         ` Jan Kara
2019-07-30 18:15           ` Konstantin Khlebnikov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.