[PATCH] mm: Don't bother dropping mmap_sem for zero size readahead

From: Jan Kara
Date: Wed Nov 06 2019 - 09:30:26 EST


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.

Signed-off-by: Jan Kara <jack@xxxxxxx>
---
mm/filemap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 1146fcfa3215..3d39c437b07e 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2458,7 +2458,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--;
--
2.16.4


--hQiwHBbRI9kgIhsi--