Skip to content

Commit

Permalink
mm/mlock: use offset_in_page macro
Browse files Browse the repository at this point in the history
linux/mm.h provides offset_in_page() macro.  Let's use already predefined
macro instead of (addr & ~PAGE_MASK).

Signed-off-by: Alexander Kuleshov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
0xAX authored and torvalds committed Nov 6, 2015
1 parent ea53cde commit 8fd9e48
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mm/mlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8fd9e48

Please sign in to comment.