mm/mlock: use offset_in_page macro
authorAlexander Kuleshov <kuleshovmail@gmail.com>
Fri, 6 Nov 2015 02:46:49 +0000 (18:46 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 6 Nov 2015 03:34:48 +0000 (19:34 -0800)
linux/mm.h provides offset_in_page() macro.  Let's use already predefined
macro instead of (addr & ~PAGE_MASK).

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/mlock.c

index 7e6ad9c4c549b6accc1d529f603722021a789024..550228d983cc0c4e9cf69bde3e61284a2ab955f6 100644 (file)
@@ -560,7 +560,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
        struct vm_area_struct * vma, * prev;
        int error;
 
-       VM_BUG_ON(start & ~PAGE_MASK);
+       VM_BUG_ON(offset_in_page(start));
        VM_BUG_ON(len != PAGE_ALIGN(len));
        end = start + len;
        if (end < start)
@@ -616,7 +616,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
 
        lru_add_drain_all();    /* flush pagevec */
 
-       len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
+       len = PAGE_ALIGN(len + (offset_in_page(start)));
        start &= PAGE_MASK;
 
        lock_limit = rlimit(RLIMIT_MEMLOCK);
@@ -645,7 +645,7 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
 {
        int ret;
 
-       len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
+       len = PAGE_ALIGN(len + (offset_in_page(start)));
        start &= PAGE_MASK;
 
        down_write(&current->mm->mmap_sem);