patch-1.3.69 linux/mm/mlock.c

Next file: linux/mm/mmap.c
Previous file: linux/mm/memory.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.68/linux/mm/mlock.c linux/mm/mlock.c
@@ -106,12 +106,6 @@
 	if (newflags == vma->vm_flags)
 		return 0;
 
-	/* keep track of amount of locked VM */
-	pages = (end - start) >> PAGE_SHIFT;
-	if (!(newflags & VM_LOCKED))
-		pages = -pages;
-	vma->vm_mm->locked_vm += pages;
-
 	if (start == vma->vm_start) {
 		if (end == vma->vm_end)
 			retval = mlock_fixup_all(vma, newflags);
@@ -123,12 +117,19 @@
 		else
 			retval = mlock_fixup_middle(vma, start, end, newflags);
 	}
-	if (!retval && (newflags & VM_LOCKED)) {
-		while (start < end) {
-			char c = get_user((char *) start);
-			__asm__ __volatile__("": :"r" (c));
-			start += PAGE_SIZE;
-		}
+	if (!retval) {
+		/* keep track of amount of locked VM */
+		pages = (end - start) >> PAGE_SHIFT;
+		if (!(newflags & VM_LOCKED))
+			pages = -pages;
+		vma->vm_mm->locked_vm += pages;
+
+		if (newflags & VM_LOCKED)
+			while (start < end) {
+				char c = get_user((char *) start);
+				__asm__ __volatile__("": :"r" (c));
+				start += PAGE_SIZE;
+			}
 	}
 	return retval;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this