]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mm/filemap.c: don't bother dropping mmap_sem for zero size readahead
authorJan Kara <jack@suse.cz>
Thu, 2 Apr 2020 04:04:40 +0000 (21:04 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 2 Apr 2020 16:35:26 +0000 (09:35 -0700)
When handling a page fault, we drop mmap_sem to start async readahead so
that we don't block on IO submission with mmap_sem held.  However there's
no point to drop mmap_sem in case readahead is disabled.  Handle that case
to avoid pointless dropping of mmap_sem and retrying the fault.  This was
actually reported to block mlockall(MCL_CURRENT) indefinitely.

Fixes: 6b4c9f446981 ("filemap: drop the mmap_sem for all blocking operations")
Reported-by: Minchan Kim <minchan@kernel.org>
Reported-by: Robert Stupp <snazy@gmx.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Minchan Kim <minchan@kernel.org>
Link: http://lkml.kernel.org/r/20200212101356.30759-1-jack@suse.cz
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/filemap.c

index 1784478270e1506c22bcd5a1b7cc69066f20d89a..5bffaa2176cd24bf60112b83f6df14d36a6b44f1 100644 (file)
@@ -2416,7 +2416,7 @@ static struct file *do_async_mmap_readahead(struct vm_fault *vmf,
        pgoff_t offset = vmf->pgoff;
 
        /* If we don't want any read-ahead, don't bother */
-       if (vmf->vma->vm_flags & VM_RAND_READ)
+       if (vmf->vma->vm_flags & VM_RAND_READ || !ra->ra_pages)
                return fpin;
        if (ra->mmap_miss > 0)
                ra->mmap_miss--;