Skip to content

Commit

Permalink
mm/mremap: 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 de1741a commit f19cb11
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mm/mremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
unsigned long charged = 0;
unsigned long map_flags;

if (new_addr & ~PAGE_MASK)
if (offset_in_page(new_addr))
goto out;

if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
Expand Down Expand Up @@ -435,11 +435,11 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
ret = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff +
((addr - vma->vm_start) >> PAGE_SHIFT),
map_flags);
if (ret & ~PAGE_MASK)
if (offset_in_page(ret))
goto out1;

ret = move_vma(vma, addr, old_len, new_len, new_addr, locked);
if (!(ret & ~PAGE_MASK))
if (!(offset_in_page(ret)))
goto out;
out1:
vm_unacct_memory(charged);
Expand Down Expand Up @@ -484,7 +484,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
if (flags & MREMAP_FIXED && !(flags & MREMAP_MAYMOVE))
return ret;

if (addr & ~PAGE_MASK)
if (offset_in_page(addr))
return ret;

old_len = PAGE_ALIGN(old_len);
Expand Down Expand Up @@ -566,15 +566,15 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
vma->vm_pgoff +
((addr - vma->vm_start) >> PAGE_SHIFT),
map_flags);
if (new_addr & ~PAGE_MASK) {
if (offset_in_page(new_addr)) {
ret = new_addr;
goto out;
}

ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
}
out:
if (ret & ~PAGE_MASK) {
if (offset_in_page(ret)) {
vm_unacct_memory(charged);
locked = 0;
}
Expand Down

0 comments on commit f19cb11

Please sign in to comment.