[RFC,18/24] shared file mappings: use the vmf->range field when dropping mmap_sem
diff mbox series

Message ID 20200224203057.162467-19-walken@google.com
State New
Headers show
Series
  • Fine grained MM locking
Related show

Commit Message

Michel Lespinasse Feb. 24, 2020, 8:30 p.m. UTC
Modify lock_page_maybe_drop_mmap() and maybe_unlock_mmap_for_io()
to use the vmf->range field when dropping mmap_sem.

This covers dropping mmap_sem during:
- filemap_fault()
- shmem_fault()
- do_fault() write to shared file mapping
  [ through do_shared_fault and fault_dirty_shared_page() ]
- do_wp_page() write to shared file mapping
  [ through wp_page_shared() and fault_dirty_shared_page() ]

Signed-off-by: Michel Lespinasse <walken@google.com>
---
 mm/filemap.c  | 3 ++-
 mm/internal.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git mm/filemap.c mm/filemap.c
index 3afb5a3f0b9c..7827de7b356c 100644
--- mm/filemap.c
+++ mm/filemap.c
@@ -2364,7 +2364,8 @@  static int lock_page_maybe_drop_mmap(struct vm_fault *vmf, struct page *page,
 			 * mmap_sem here and return 0 if we don't have a fpin.
 			 */
 			if (*fpin == NULL)
-				mm_read_unlock(vmf->vma->vm_mm);
+				mm_read_range_unlock(vmf->vma->vm_mm,
+						     vmf->range);
 			return 0;
 		}
 	} else
diff --git mm/internal.h mm/internal.h
index 22f361a1e284..9bfff428c5da 100644
--- mm/internal.h
+++ mm/internal.h
@@ -382,7 +382,7 @@  static inline struct file *maybe_unlock_mmap_for_io(struct vm_fault *vmf,
 	if ((flags & (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT)) ==
 	    FAULT_FLAG_ALLOW_RETRY) {
 		fpin = get_file(vmf->vma->vm_file);
-		mm_read_unlock(vmf->vma->vm_mm);
+		mm_read_range_unlock(vmf->vma->vm_mm, vmf->range);
 	}
 	return fpin;
 }