mm: mlock: correct a typo in count_mm_mlocked_page_nr() for caculate VMLOCKED pages
authorSimon Guo <wei.guo.simon@gmail.com>
Sat, 10 Sep 2016 10:34:12 +0000 (20:34 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Sat, 10 Sep 2016 10:34:12 +0000 (20:34 +1000)
There is a typo/bug in count_mm_mlocked_page_nr() for "&" which is
mistakenly used with "&&".

Also add more checks and some minor change based on Kirill's previous
comment.

Link: http://lkml.kernel.org/r/1473325970-11393-2-git-send-email-wei.guo.simon@gmail.com
Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
Suggested-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/mlock.c

index e144f75a9e59653a8c41d745c2dacffd3aabe4d8..b1fec89bd1c526c70766e034d1f22cdc68f1e6c5 100644 (file)
@@ -638,9 +638,11 @@ static int count_mm_mlocked_page_nr(struct mm_struct *mm,
                vma = mm->mmap;
 
        for (; vma ; vma = vma->vm_next) {
+               if (start >= vma->vm_end)
+                       continue;
                if (start + len <=  vma->vm_start)
                        break;
-               if (vma->vm_flags && VM_LOCKED) {
+               if (vma->vm_flags & VM_LOCKED) {
                        if (start > vma->vm_start)
                                count -= (start - vma->vm_start);
                        if (start + len < vma->vm_end) {
@@ -651,7 +653,7 @@ static int count_mm_mlocked_page_nr(struct mm_struct *mm,
                }
        }
 
-       return (PAGE_ALIGN(count) >> PAGE_SHIFT);
+       return count >> PAGE_SHIFT;
 }
 
 static __must_check int do_mlock(unsigned long start, size_t len, vm_flags_t flags)
This page took 0.035552 seconds and 5 git commands to generate.