Commit 47e20933814feeb75543eb514437989cea53ec52

Authored by Jan Kara
Committed by Greg Kroah-Hartman
1 parent 1402105542

mm/filemap.c: don't bother dropping mmap_sem for zero size readahead

commit 5c72feee3e45b40a3c96c7145ec422899d0e8964 upstream.

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>
Cc: SeongJae Park <sjpark@amazon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -2438,7 +2438,7 @@
2438 2438 pgoff_t offset = vmf->pgoff;
2439 2439  
2440 2440 /* If we don't want any read-ahead, don't bother */
2441   - if (vmf->vma->vm_flags & VM_RAND_READ)
  2441 + if (vmf->vma->vm_flags & VM_RAND_READ || !ra->ra_pages)
2442 2442 return fpin;
2443 2443 if (ra->mmap_miss > 0)
2444 2444 ra->mmap_miss--;