The patch titled Subject: mm/filemap.c: don't initiate writeback if mapping has no dirty pages has been added to the -mm tree. Its filename is mm-filemap-dont-initiate-writeback-if-mapping-has-no-dirty-pages.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-filemap-dont-initiate-writeback-if-mapping-has-no-dirty-pages.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-filemap-dont-initiate-writeback-if-mapping-has-no-dirty-pages.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxxxxxx> Subject: mm/filemap.c: don't initiate writeback if mapping has no dirty pages 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. Link: http://lkml.kernel.org/r/156378816804.1087.8607636317907921438.stgit@buzz Signed-off-by: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxxxxxx> Reviewed-by: Jan Kara <jack@xxxxxxx> Cc: Tejun Heo <tj@xxxxxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/filemap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/mm/filemap.c~mm-filemap-dont-initiate-writeback-if-mapping-has-no-dirty-pages +++ a/mm/filemap.c @@ -408,7 +408,8 @@ int __filemap_fdatawrite_range(struct ad .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); _ Patches currently in -mm which might be from khlebnikov@xxxxxxxxxxxxxx are mm-filemap-dont-initiate-writeback-if-mapping-has-no-dirty-pages.patch mm-filemap-rewrite-mapping_needs_writeback-in-less-fancy-manner.patch