git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git]
/
mm
/
mlock.c
diff --git
a/mm/mlock.c
b/mm/mlock.c
index
e3bc9cd
..
6ea2ee0
100644
(file)
--- a/
mm/mlock.c
+++ b/
mm/mlock.c
@@
-5,21
+5,36
@@
* (C) Copyright 2002 Christoph Hellwig
*/
* (C) Copyright 2002 Christoph Hellwig
*/
+#include <linux/capability.h>
#include <linux/mman.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/mm.h>
+#include <linux/mempolicy.h>
#include <linux/syscalls.h>
#include <linux/vs_memory.h>
#include <linux/syscalls.h>
#include <linux/vs_memory.h>
-static int mlock_fixup(struct vm_area_struct *
vma,
+static int mlock_fixup(struct vm_area_struct *
vma, struct vm_area_struct **prev,
unsigned long start, unsigned long end, unsigned int newflags)
{
struct mm_struct * mm = vma->vm_mm;
unsigned long start, unsigned long end, unsigned int newflags)
{
struct mm_struct * mm = vma->vm_mm;
+ pgoff_t pgoff;
int pages;
int ret = 0;
int pages;
int ret = 0;
- if (newflags == vma->vm_flags)
+ if (newflags == vma->vm_flags) {
+ *prev = vma;
goto out;
goto out;
+ }
+
+ pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT);
+ *prev = vma_merge(mm, *prev, start, end, newflags, vma->anon_vma,
+ vma->vm_file, pgoff, vma_policy(vma));
+ if (*prev) {
+ vma = *prev;
+ goto success;
+ }
+
+ *prev = vma;
if (start != vma->vm_start) {
ret = split_vma(mm, vma, start, 1);
if (start != vma->vm_start) {
ret = split_vma(mm, vma, start, 1);
@@
-33,6
+48,7
@@
static int mlock_fixup(struct vm_area_struct * vma,
goto out;
}
goto out;
}
+success:
/*
* vm_flags is protected by the mmap_sem held in write mode.
* It's okay if try_to_unmap_one unmaps a page just after we
/*
* vm_flags is protected by the mmap_sem held in write mode.
* It's okay if try_to_unmap_one unmaps a page just after we
@@
-50,7
+66,6
@@
static int mlock_fixup(struct vm_area_struct * vma,
ret = make_pages_present(start, end);
}
ret = make_pages_present(start, end);
}
- // vma->vm_mm->locked_vm -= pages;
vx_vmlocked_sub(vma->vm_mm, pages);
out:
if (ret == -ENOMEM)
vx_vmlocked_sub(vma->vm_mm, pages);
out:
if (ret == -ENOMEM)
@@
-61,7
+76,7
@@
out:
static int do_mlock(unsigned long start, size_t len, int on)
{
unsigned long nstart, end, tmp;
static int do_mlock(unsigned long start, size_t len, int on)
{
unsigned long nstart, end, tmp;
- struct vm_area_struct * vma, *
next
;
+ struct vm_area_struct * vma, *
prev
;
int error;
len = PAGE_ALIGN(len);
int error;
len = PAGE_ALIGN(len);
@@
-70,10
+85,13
@@
static int do_mlock(unsigned long start, size_t len, int on)
return -EINVAL;
if (end == start)
return 0;
return -EINVAL;
if (end == start)
return 0;
- vma = find_vma
(current->mm, start
);
+ vma = find_vma
_prev(current->mm, start, &prev
);
if (!vma || vma->vm_start > start)
return -ENOMEM;
if (!vma || vma->vm_start > start)
return -ENOMEM;
+ if (start > vma->vm_start)
+ prev = vma;
+
for (nstart = start ; ; ) {
unsigned int newflags;
for (nstart = start ; ; ) {
unsigned int newflags;
@@
-83,18
+101,19
@@
static int do_mlock(unsigned long start, size_t len, int on)
if (!on)
newflags &= ~VM_LOCKED;
if (!on)
newflags &= ~VM_LOCKED;
- if (vma->vm_end >= end) {
- error = mlock_fixup(vma, nstart, end, newflags);
- break;
- }
-
tmp = vma->vm_end;
tmp = vma->vm_end;
- next = vma->vm_next;
- error = mlock_fixup(vma, nstart, tmp, newflags);
+ if (tmp > end)
+ tmp = end;
+ error = mlock_fixup(vma, &prev, nstart, tmp, newflags);
if (error)
break;
nstart = tmp;
if (error)
break;
nstart = tmp;
- vma = next;
+ if (nstart < prev->vm_end)
+ nstart = prev->vm_end;
+ if (nstart >= end)
+ break;
+
+ vma = prev->vm_next;
if (!vma || vma->vm_start != nstart) {
error = -ENOMEM;
break;
if (!vma || vma->vm_start != nstart) {
error = -ENOMEM;
break;
@@
-146,7
+165,7
@@
asmlinkage long sys_munlock(unsigned long start, size_t len)
static int do_mlockall(int flags)
{
static int do_mlockall(int flags)
{
- struct vm_area_struct * vma;
+ struct vm_area_struct * vma
, * prev = NULL
;
unsigned int def_flags = 0;
if (flags & MCL_FUTURE)
unsigned int def_flags = 0;
if (flags & MCL_FUTURE)
@@
-155,7
+174,7
@@
static int do_mlockall(int flags)
if (flags == MCL_FUTURE)
goto out;
if (flags == MCL_FUTURE)
goto out;
- for (vma = current->mm->mmap; vma ; vma =
vma
->vm_next) {
+ for (vma = current->mm->mmap; vma ; vma =
prev
->vm_next) {
unsigned int newflags;
newflags = vma->vm_flags | VM_LOCKED;
unsigned int newflags;
newflags = vma->vm_flags | VM_LOCKED;
@@
-163,7
+182,7
@@
static int do_mlockall(int flags)
newflags &= ~VM_LOCKED;
/* Ignore errors */
newflags &= ~VM_LOCKED;
/* Ignore errors */
- mlock_fixup(vma, vma->vm_start, vma->vm_end, newflags);
+ mlock_fixup(vma,
&prev,
vma->vm_start, vma->vm_end, newflags);
}
out:
return 0;
}
out:
return 0;