* [PATCH 01/10] mm/msync: Use offset_in_page macro
[not found] <1442326012-7034-1-git-send-email-kuleshovmail@gmail.com>
@ 2015-09-15 14:07 ` Alexander Kuleshov
2015-09-15 14:07 ` [PATCH 02/10] mm/nommu: " Alexander Kuleshov
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alexander Kuleshov @ 2015-09-15 14:07 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Johannes Weiner, David Rientjes, Vladimir Davydov,
Tejun Heo, linux-mm, linux-kernel, Alexander Kuleshov
The <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>
---
mm/msync.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/msync.c b/mm/msync.c
index bb04d53..24e612f 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -38,7 +38,7 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC))
goto out;
- if (start & ~PAGE_MASK)
+ if (offset_in_page(start))
goto out;
if ((flags & MS_ASYNC) && (flags & MS_SYNC))
goto out;
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 02/10] mm/nommu: Use offset_in_page macro
[not found] <1442326012-7034-1-git-send-email-kuleshovmail@gmail.com>
2015-09-15 14:07 ` [PATCH 01/10] mm/msync: Use offset_in_page macro Alexander Kuleshov
@ 2015-09-15 14:07 ` Alexander Kuleshov
2015-09-15 14:07 ` [PATCH 03/10] mm/mincore: " Alexander Kuleshov
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alexander Kuleshov @ 2015-09-15 14:07 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Johannes Weiner, David Rientjes, Vladimir Davydov,
Tejun Heo, linux-mm, linux-kernel, Alexander Kuleshov
The <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>
---
mm/nommu.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/nommu.c b/mm/nommu.c
index ab14a20..1e0f168 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1497,7 +1497,7 @@ SYSCALL_DEFINE1(old_mmap, struct mmap_arg_struct __user *, arg)
if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
- if (a.offset & ~PAGE_MASK)
+ if (offset_in_page(a.offset))
return -EINVAL;
return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
@@ -1653,9 +1653,9 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
goto erase_whole_vma;
if (start < vma->vm_start || end > vma->vm_end)
return -EINVAL;
- if (start & ~PAGE_MASK)
+ if (offset_in_page(start))
return -EINVAL;
- if (end != vma->vm_end && end & ~PAGE_MASK)
+ if (end != vma->vm_end && offset_in_page(end))
return -EINVAL;
if (start != vma->vm_start && end != vma->vm_end) {
ret = split_vma(mm, vma, start, 1);
@@ -1736,7 +1736,7 @@ static unsigned long do_mremap(unsigned long addr,
if (old_len == 0 || new_len == 0)
return (unsigned long) -EINVAL;
- if (addr & ~PAGE_MASK)
+ if (offset_in_page(addr))
return -EINVAL;
if (flags & MREMAP_FIXED && new_addr != addr)
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 03/10] mm/mincore: Use offset_in_page macro
[not found] <1442326012-7034-1-git-send-email-kuleshovmail@gmail.com>
2015-09-15 14:07 ` [PATCH 01/10] mm/msync: Use offset_in_page macro Alexander Kuleshov
2015-09-15 14:07 ` [PATCH 02/10] mm/nommu: " Alexander Kuleshov
@ 2015-09-15 14:07 ` Alexander Kuleshov
2015-09-15 14:07 ` [PATCH 04/10] mm/early_ioremap: " Alexander Kuleshov
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alexander Kuleshov @ 2015-09-15 14:07 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Johannes Weiner, David Rientjes, Vladimir Davydov,
Tejun Heo, linux-mm, linux-kernel, Alexander Kuleshov
The <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>
---
mm/mincore.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/mincore.c b/mm/mincore.c
index be25efd..a011355 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -234,8 +234,7 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len,
/* This also avoids any overflows on PAGE_CACHE_ALIGN */
pages = len >> PAGE_SHIFT;
- pages += (len & ~PAGE_MASK) != 0;
+ pages += (offset_in_page(len)) != 0;
if (!access_ok(VERIFY_WRITE, vec, pages))
return -EFAULT;
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 04/10] mm/early_ioremap: Use offset_in_page macro
[not found] <1442326012-7034-1-git-send-email-kuleshovmail@gmail.com>
` (2 preceding siblings ...)
2015-09-15 14:07 ` [PATCH 03/10] mm/mincore: " Alexander Kuleshov
@ 2015-09-15 14:07 ` Alexander Kuleshov
2015-09-15 14:08 ` [PATCH 05/10] mm/percpu: " Alexander Kuleshov
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alexander Kuleshov @ 2015-09-15 14:07 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Johannes Weiner, David Rientjes, Vladimir Davydov,
Tejun Heo, linux-mm, linux-kernel, Alexander Kuleshov
The <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>
---
mm/early_ioremap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/early_ioremap.c b/mm/early_ioremap.c
index 17ae14b..6d5717b 100644
--- a/mm/early_ioremap.c
+++ b/mm/early_ioremap.c
@@ -126,7 +126,7 @@ __early_ioremap(resource_size_t phys_addr, unsigned long size, pgprot_t prot)
/*
* Mappings have to be page-aligned
*/
- offset = phys_addr & ~PAGE_MASK;
+ offset = offset_in_page(phys_addr);
phys_addr &= PAGE_MASK;
size = PAGE_ALIGN(last_addr + 1) - phys_addr;
@@ -189,7 +189,7 @@ void __init early_iounmap(void __iomem *addr, unsigned long size)
if (WARN_ON(virt_addr < fix_to_virt(FIX_BTMAP_BEGIN)))
return;
- offset = virt_addr & ~PAGE_MASK;
+ offset = offset_in_page(virt_addr);
nrpages = PAGE_ALIGN(offset + size) >> PAGE_SHIFT;
idx = FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*slot;
@@ -234,7 +234,7 @@ void __init copy_from_early_mem(void *dest, phys_addr_t src, unsigned long size)
char *p;
while (size) {
- slop = src & ~PAGE_MASK;
+ slop = offset_in_page(src);
clen = size;
if (clen > MAX_MAP_CHUNK - slop)
clen = MAX_MAP_CHUNK - slop;
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 05/10] mm/percpu: Use offset_in_page macro
[not found] <1442326012-7034-1-git-send-email-kuleshovmail@gmail.com>
` (3 preceding siblings ...)
2015-09-15 14:07 ` [PATCH 04/10] mm/early_ioremap: " Alexander Kuleshov
@ 2015-09-15 14:08 ` Alexander Kuleshov
2015-09-15 14:32 ` Tejun Heo
2015-09-15 14:08 ` [PATCH 06/10] mm/util: " Alexander Kuleshov
` (4 subsequent siblings)
9 siblings, 1 reply; 11+ messages in thread
From: Alexander Kuleshov @ 2015-09-15 14:08 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Johannes Weiner, David Rientjes, Vladimir Davydov,
Tejun Heo, linux-mm, linux-kernel, Alexander Kuleshov
The <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>
---
mm/percpu.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mm/percpu.c b/mm/percpu.c
index a63b4d8..8a943b9 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1554,12 +1554,12 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
PCPU_SETUP_BUG_ON(ai->nr_groups <= 0);
#ifdef CONFIG_SMP
PCPU_SETUP_BUG_ON(!ai->static_size);
- PCPU_SETUP_BUG_ON((unsigned long)__per_cpu_start & ~PAGE_MASK);
+ PCPU_SETUP_BUG_ON(offset_in_page(__per_cpu_start));
#endif
PCPU_SETUP_BUG_ON(!base_addr);
- PCPU_SETUP_BUG_ON((unsigned long)base_addr & ~PAGE_MASK);
+ PCPU_SETUP_BUG_ON(offset_in_page(base_addr));
PCPU_SETUP_BUG_ON(ai->unit_size < size_sum);
- PCPU_SETUP_BUG_ON(ai->unit_size & ~PAGE_MASK);
+ PCPU_SETUP_BUG_ON(offset_in_page(ai->unit_size));
PCPU_SETUP_BUG_ON(ai->unit_size < PCPU_MIN_UNIT_SIZE);
PCPU_SETUP_BUG_ON(ai->dyn_size < PERCPU_DYNAMIC_EARLY_SIZE);
PCPU_SETUP_BUG_ON(pcpu_verify_alloc_info(ai) < 0);
@@ -1806,7 +1806,7 @@ static struct pcpu_alloc_info * __init pcpu_build_alloc_info(
alloc_size = roundup(min_unit_size, atom_size);
upa = alloc_size / min_unit_size;
- while (alloc_size % upa || ((alloc_size / upa) & ~PAGE_MASK))
+ while (alloc_size % upa || (offset_in_page(alloc_size / upa)))
upa--;
max_upa = upa;
@@ -1838,7 +1838,7 @@ static struct pcpu_alloc_info * __init pcpu_build_alloc_info(
for (upa = max_upa; upa; upa--) {
int allocs = 0, wasted = 0;
- if (alloc_size % upa || ((alloc_size / upa) & ~PAGE_MASK))
+ if (alloc_size % upa || (offset_in_page(alloc_size / upa)))
continue;
for (group = 0; group < nr_groups; group++) {
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 05/10] mm/percpu: Use offset_in_page macro
2015-09-15 14:08 ` [PATCH 05/10] mm/percpu: " Alexander Kuleshov
@ 2015-09-15 14:32 ` Tejun Heo
0 siblings, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2015-09-15 14:32 UTC (permalink / raw)
To: Alexander Kuleshov
Cc: Andrew Morton, Michal Hocko, Johannes Weiner, David Rientjes,
Vladimir Davydov, linux-mm, linux-kernel
On Tue, Sep 15, 2015 at 08:08:01PM +0600, Alexander Kuleshov wrote:
> The <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>
Acked-by: Tejun Heo <tj@kernel.org>
Please feel free to route with other patches.
Thanks.
--
tejun
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 06/10] mm/util: Use offset_in_page macro
[not found] <1442326012-7034-1-git-send-email-kuleshovmail@gmail.com>
` (4 preceding siblings ...)
2015-09-15 14:08 ` [PATCH 05/10] mm/percpu: " Alexander Kuleshov
@ 2015-09-15 14:08 ` Alexander Kuleshov
2015-09-15 14:08 ` [PATCH 07/10] mm/mlock: " Alexander Kuleshov
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alexander Kuleshov @ 2015-09-15 14:08 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Johannes Weiner, David Rientjes, Vladimir Davydov,
Tejun Heo, linux-mm, linux-kernel, Alexander Kuleshov
The <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>
---
mm/util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/util.c b/mm/util.c
index 68ff8a5..9af1c12 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -309,7 +309,7 @@ unsigned long vm_mmap(struct file *file, unsigned long addr,
{
if (unlikely(offset + PAGE_ALIGN(len) < offset))
return -EINVAL;
- if (unlikely(offset & ~PAGE_MASK))
+ if (unlikely(offset_in_page(offset)))
return -EINVAL;
return vm_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 07/10] mm/mlock: Use offset_in_page macro
[not found] <1442326012-7034-1-git-send-email-kuleshovmail@gmail.com>
` (5 preceding siblings ...)
2015-09-15 14:08 ` [PATCH 06/10] mm/util: " Alexander Kuleshov
@ 2015-09-15 14:08 ` Alexander Kuleshov
2015-09-15 14:08 ` [PATCH 08/10] mm/vmalloc: " Alexander Kuleshov
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alexander Kuleshov @ 2015-09-15 14:08 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Johannes Weiner, David Rientjes, Vladimir Davydov,
Tejun Heo, linux-mm, linux-kernel, Alexander Kuleshov
The <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>
---
mm/mlock.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/mlock.c b/mm/mlock.c
index 25936680..e86206b 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -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(¤t->mm->mmap_sem);
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 08/10] mm/vmalloc: Use offset_in_page macro
[not found] <1442326012-7034-1-git-send-email-kuleshovmail@gmail.com>
` (6 preceding siblings ...)
2015-09-15 14:08 ` [PATCH 07/10] mm/mlock: " Alexander Kuleshov
@ 2015-09-15 14:08 ` Alexander Kuleshov
2015-09-15 14:08 ` [PATCH 09/10] mm/mmap: " Alexander Kuleshov
2015-09-15 14:08 ` [PATCH 10/10] mm/mremap: " Alexander Kuleshov
9 siblings, 0 replies; 11+ messages in thread
From: Alexander Kuleshov @ 2015-09-15 14:08 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Johannes Weiner, David Rientjes, Vladimir Davydov,
Tejun Heo, linux-mm, linux-kernel, Alexander Kuleshov
The <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>
---
mm/vmalloc.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 2faaa29..b51b733 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -358,7 +358,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,
struct vmap_area *first;
BUG_ON(!size);
- BUG_ON(size & ~PAGE_MASK);
+ BUG_ON(offset_in_page(size));
BUG_ON(!is_power_of_2(align));
va = kmalloc_node(sizeof(struct vmap_area),
@@ -936,7 +936,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask)
void *vaddr = NULL;
unsigned int order;
- BUG_ON(size & ~PAGE_MASK);
+ BUG_ON(offset_in_page(size));
BUG_ON(size > PAGE_SIZE*VMAP_MAX_ALLOC);
if (WARN_ON(size == 0)) {
/*
@@ -989,7 +989,7 @@ static void vb_free(const void *addr, unsigned long size)
unsigned int order;
struct vmap_block *vb;
- BUG_ON(size & ~PAGE_MASK);
+ BUG_ON(offset_in_page(size));
BUG_ON(size > PAGE_SIZE*VMAP_MAX_ALLOC);
flush_cache_vunmap((unsigned long)addr, (unsigned long)addr + size);
@@ -1902,7 +1902,7 @@ static int aligned_vread(char *buf, char *addr, unsigned long count)
while (count) {
unsigned long offset, length;
- offset = (unsigned long)addr & ~PAGE_MASK;
+ offset = offset_in_page(addr);
length = PAGE_SIZE - offset;
if (length > count)
length = count;
@@ -1941,7 +1941,7 @@ static int aligned_vwrite(char *buf, char *addr, unsigned long count)
while (count) {
unsigned long offset, length;
- offset = (unsigned long)addr & ~PAGE_MASK;
+ offset = offset_in_page(addr);
length = PAGE_SIZE - offset;
if (length > count)
length = count;
@@ -2392,7 +2392,7 @@ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
bool purged = false;
/* verify parameters and allocate data structures */
- BUG_ON(align & ~PAGE_MASK || !is_power_of_2(align));
+ BUG_ON(offset_in_page(align) || !is_power_of_2(align));
for (last_area = 0, area = 0; area < nr_vms; area++) {
start = offsets[area];
end = start + sizes[area];
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 09/10] mm/mmap: Use offset_in_page macro
[not found] <1442326012-7034-1-git-send-email-kuleshovmail@gmail.com>
` (7 preceding siblings ...)
2015-09-15 14:08 ` [PATCH 08/10] mm/vmalloc: " Alexander Kuleshov
@ 2015-09-15 14:08 ` Alexander Kuleshov
2015-09-15 14:08 ` [PATCH 10/10] mm/mremap: " Alexander Kuleshov
9 siblings, 0 replies; 11+ messages in thread
From: Alexander Kuleshov @ 2015-09-15 14:08 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Johannes Weiner, David Rientjes, Vladimir Davydov,
Tejun Heo, linux-mm, linux-kernel, Alexander Kuleshov
The <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>
---
mm/mmap.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index 971dd2c..a313a9c 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1304,7 +1304,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
* that it represents a valid section of the address space.
*/
addr = get_unmapped_area(file, addr, len, pgoff, flags);
- if (addr & ~PAGE_MASK)
+ if (offset_in_page(addr))
return addr;
/* Do simple checking here so the lower-level routines won't have
@@ -1475,7 +1475,7 @@ SYSCALL_DEFINE1(old_mmap, struct mmap_arg_struct __user *, arg)
if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
- if (a.offset & ~PAGE_MASK)
+ if (offset_in_page(a.offset))
return -EINVAL;
return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
@@ -1996,7 +1996,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
* can happen with large stack limits and large mmap()
* allocations.
*/
- if (addr & ~PAGE_MASK) {
+ if (offset_in_page(addr)) {
VM_BUG_ON(addr != -ENOMEM);
info.flags = 0;
info.low_limit = TASK_UNMAPPED_BASE;
@@ -2032,7 +2032,7 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
if (addr > TASK_SIZE - len)
return -ENOMEM;
- if (addr & ~PAGE_MASK)
+ if (offset_in_page(addr))
return -EINVAL;
addr = arch_rebalance_pgtables(addr, len);
@@ -2543,7 +2543,7 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
unsigned long end;
struct vm_area_struct *vma, *prev, *last;
- if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
+ if ((offset_in_page(start)) || start > TASK_SIZE || len > TASK_SIZE-start)
return -EINVAL;
len = PAGE_ALIGN(len);
@@ -2741,7 +2741,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
- if (error & ~PAGE_MASK)
+ if (offset_in_page(error))
return error;
error = mlock_future_check(mm, mm->def_flags, len);
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 10/10] mm/mremap: Use offset_in_page macro
[not found] <1442326012-7034-1-git-send-email-kuleshovmail@gmail.com>
` (8 preceding siblings ...)
2015-09-15 14:08 ` [PATCH 09/10] mm/mmap: " Alexander Kuleshov
@ 2015-09-15 14:08 ` Alexander Kuleshov
9 siblings, 0 replies; 11+ messages in thread
From: Alexander Kuleshov @ 2015-09-15 14:08 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Johannes Weiner, David Rientjes, Vladimir Davydov,
Tejun Heo, linux-mm, linux-kernel, Alexander Kuleshov
The <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>
---
mm/mremap.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/mremap.c b/mm/mremap.c
index 5a71cce..3fea83c 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -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)
@@ -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);
@@ -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);
@@ -566,7 +566,7 @@ 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;
}
@@ -574,7 +574,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
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;
}
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 11+ messages in thread