mm/filemap.c: avoid always dirtying mapping->flags on O_DIRECT
authorJens Axboe <axboe@fb.com>
Thu, 28 Aug 2014 18:34:45 +0000 (19:34 +0100)
committerJiri Slaby <jslaby@suse.cz>
Fri, 26 Sep 2014 09:51:56 +0000 (11:51 +0200)
commit5a6ad555bd1cc9c3126df8b8d69ea332b9a4ec8b
tree63ba0596776e85f2f20659ed8884a095f208bb8f
parent337c9823cf0b93c8f4d1c4654bd93cf24e5b837b
mm/filemap.c: avoid always dirtying mapping->flags on O_DIRECT

commit 7fcbbaf18392f0b17c95e2f033c8ccf87eecde1d upstream.

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>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
mm/filemap.c