diff options
author | Jens Axboe <axboe@fb.com> | 2014-05-22 14:54:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-05-23 12:37:29 -0400 |
commit | 7fcbbaf18392f0b17c95e2f033c8ccf87eecde1d (patch) | |
tree | eef8e5449c79bf596cf16bca47de1c8ca60048d0 /mm/filemap.c | |
parent | b985194c8c0a130ed155b71662e39f7eaea4876f (diff) |
mm/filemap.c: avoid always dirtying mapping->flags on O_DIRECT
In some testing I ran today (some fio jobs that spread over two nodes),
we end up spending 40% of the time in filemap_check_errors(). That
smells fishy. Looking further, this is basically what happens:
blkdev_aio_read()
generic_file_aio_read()
filemap_write_and_wait_range()
if (!mapping->nr_pages)
filemap_check_errors()
and filemap_check_errors() always attempts two test_and_clear_bit() on
the mapping flags, thus dirtying it for every single invocation. The
patch below tests each of these bits before clearing them, avoiding this
issue. In my test case (4-socket box), performance went from 1.7M IOPS
to 4.0M IOPS.
Signed-off-by: Jens Axboe <axboe@fb.com>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 000a220e2a41..088358c8006b 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -257,9 +257,11 @@ static int filemap_check_errors(struct address_space *mapping) | |||
257 | { | 257 | { |
258 | int ret = 0; | 258 | int ret = 0; |
259 | /* Check for outstanding write errors */ | 259 | /* Check for outstanding write errors */ |
260 | if (test_and_clear_bit(AS_ENOSPC, &mapping->flags)) | 260 | if (test_bit(AS_ENOSPC, &mapping->flags) && |
261 | test_and_clear_bit(AS_ENOSPC, &mapping->flags)) | ||
261 | ret = -ENOSPC; | 262 | ret = -ENOSPC; |
262 | if (test_and_clear_bit(AS_EIO, &mapping->flags)) | 263 | if (test_bit(AS_EIO, &mapping->flags) && |
264 | test_and_clear_bit(AS_EIO, &mapping->flags)) | ||
263 | ret = -EIO; | 265 | ret = -EIO; |
264 | return ret; | 266 | return ret; |
265 | } | 267 | } |