]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
mm/filemap.c: don't initiate writeback if mapping has no dirty pages
authorKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Mon, 23 Sep 2019 22:34:45 +0000 (15:34 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 26 Nov 2019 12:16:16 +0000 (13:16 +0100)
commit8b738c7170444fcf27f18b4fa20505ab31be5fc5
tree8c229e2aae91cebaca53cafa03dbe4a4af883fe3
parente7747baf73e6e7c8da676d48e0a4c4375644bf06
mm/filemap.c: don't initiate writeback if mapping has no dirty pages

BugLink: https://bugs.launchpad.net/bugs/1853519
commit c3aab9a0bd91b696a852169479b7db1ece6cbf8c upstream.

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@yandex-team.ru>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
mm/filemap.c