[PATCH] make present VM_LOCKED stack pages

From: Pete Wyckoff (pw@osc.edu)
Date: Mon Jul 31 2000 - 13:40:44 EST


VM segments marked LOCKED, perhaps by mlockall(MCL_FUTURE), must have
physical pages wired into memory at allocation time. This currently
happens for the mmap (or brk) case, but not for the stack growth case.

The following patch to expand_stack copies the code at the end of
do_mmap_pgoff by calling make_pages_present for the newly allocated
stack pages. It also checks against the resource limit for locked pages
which was previously ignored for stack allocations.

Patch against 2.4.0-test5.

                -- Pete

--- linux/include/linux/mm.h.orig Fri Jul 28 11:01:53 2000
+++ linux/include/linux/mm.h Fri Jul 28 11:32:00 2000
@@ -469,13 +469,16 @@
         address &= PAGE_MASK;
         grow = (vma->vm_start - address) >> PAGE_SHIFT;
         if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur ||
- ((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur)
+ ((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur ||
+ ((vma->vm_mm->locked_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_MEMLOCK].rlim_cur)
                 return -ENOMEM;
         vma->vm_start = address;
         vma->vm_pgoff -= grow;
         vma->vm_mm->total_vm += grow;
- if (vma->vm_flags & VM_LOCKED)
+ if (vma->vm_flags & VM_LOCKED) {
                 vma->vm_mm->locked_vm += grow;
+ make_pages_present(address, address + (grow << PAGE_SHIFT));
+ }
         return 0;
 }
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jul 31 2000 - 21:00:34 EST