|
@@ -129,7 +129,7 @@ retry:
|
|
|
*/
|
|
|
mark_page_accessed(page);
|
|
|
}
|
|
|
- if ((flags & FOLL_POPULATE) && (vma->vm_flags & VM_LOCKED)) {
|
|
|
+ if ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) {
|
|
|
/*
|
|
|
* The preliminary mapping check is mainly to avoid the
|
|
|
* pointless overhead of lock_page on the ZERO_PAGE
|
|
@@ -299,6 +299,9 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma,
|
|
|
unsigned int fault_flags = 0;
|
|
|
int ret;
|
|
|
|
|
|
+ /* mlock all present pages, but do not fault in new pages */
|
|
|
+ if ((*flags & (FOLL_POPULATE | FOLL_MLOCK)) == FOLL_MLOCK)
|
|
|
+ return -ENOENT;
|
|
|
/* For mm_populate(), just skip the stack guard page. */
|
|
|
if ((*flags & FOLL_POPULATE) &&
|
|
|
(stack_guard_page_start(vma, address) ||
|
|
@@ -890,7 +893,10 @@ long populate_vma_page_range(struct vm_area_struct *vma,
|
|
|
VM_BUG_ON_VMA(end > vma->vm_end, vma);
|
|
|
VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_sem), mm);
|
|
|
|
|
|
- gup_flags = FOLL_TOUCH | FOLL_POPULATE;
|
|
|
+ gup_flags = FOLL_TOUCH | FOLL_POPULATE | FOLL_MLOCK;
|
|
|
+ if (vma->vm_flags & VM_LOCKONFAULT)
|
|
|
+ gup_flags &= ~FOLL_POPULATE;
|
|
|
+
|
|
|
/*
|
|
|
* We want to touch writable mappings with a write fault in order
|
|
|
* to break COW, except for shared mappings because these don't COW
|