X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=mm%2Fmadvise.c;h=944b5e52d812f051fb2bffaed33a4288ba4c920e;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=0439c560e0b4ceb474c4e981aa71ddaa2708f77b;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/mm/madvise.c b/mm/madvise.c index 0439c560e..944b5e52d 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -7,7 +7,8 @@ #include #include - +#include +#include /* * We can potentially split a vm area into separate @@ -17,18 +18,18 @@ static long madvise_behavior(struct vm_area_struct * vma, unsigned long start, unsigned long end, int behavior) { struct mm_struct * mm = vma->vm_mm; - int error; + int error = 0; if (start != vma->vm_start) { error = split_vma(mm, vma, start, 1); if (error) - return -EAGAIN; + goto out; } if (end != vma->vm_end) { error = split_vma(mm, vma, end, 0); if (error) - return -EAGAIN; + goto out; } /* @@ -47,7 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma, unsigned long start, break; } - return 0; +out: + if (error == -ENOMEM) + error = -EAGAIN; + return error; } /* @@ -93,7 +97,7 @@ static long madvise_willneed(struct vm_area_struct * vma, static long madvise_dontneed(struct vm_area_struct * vma, unsigned long start, unsigned long end) { - if (vma->vm_flags & VM_LOCKED) + if ((vma->vm_flags & VM_LOCKED) || is_vm_hugetlb_page(vma)) return -EINVAL; if (unlikely(vma->vm_flags & VM_NONLINEAR)) {