Skip to content

Commit

Permalink
mm/vmalloc: use wrapper function get_vm_area_size to caculate size of…
Browse files Browse the repository at this point in the history
… vm area

Use wrapper function get_vm_area_size to calculate size of vm area.

Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Wanpeng Li authored and Linus Torvalds committed Sep 11, 2013
1 parent 7d9f073 commit 762216a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mm/vmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ void unmap_kernel_range(unsigned long addr, unsigned long size)
int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page ***pages)
{
unsigned long addr = (unsigned long)area->addr;
unsigned long end = addr + area->size - PAGE_SIZE;
unsigned long end = addr + get_vm_area_size(area);
int err;

err = vmap_page_range(addr, end, prot, *pages);
Expand Down Expand Up @@ -1553,7 +1553,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
unsigned int nr_pages, array_size, i;
gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;

nr_pages = (area->size - PAGE_SIZE) >> PAGE_SHIFT;
nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
array_size = (nr_pages * sizeof(struct page *));

area->nr_pages = nr_pages;
Expand Down Expand Up @@ -1985,7 +1985,7 @@ long vread(char *buf, char *addr, unsigned long count)

vm = va->vm;
vaddr = (char *) vm->addr;
if (addr >= vaddr + vm->size - PAGE_SIZE)
if (addr >= vaddr + get_vm_area_size(vm))
continue;
while (addr < vaddr) {
if (count == 0)
Expand All @@ -1995,7 +1995,7 @@ long vread(char *buf, char *addr, unsigned long count)
addr++;
count--;
}
n = vaddr + vm->size - PAGE_SIZE - addr;
n = vaddr + get_vm_area_size(vm) - addr;
if (n > count)
n = count;
if (!(vm->flags & VM_IOREMAP))
Expand Down Expand Up @@ -2067,7 +2067,7 @@ long vwrite(char *buf, char *addr, unsigned long count)

vm = va->vm;
vaddr = (char *) vm->addr;
if (addr >= vaddr + vm->size - PAGE_SIZE)
if (addr >= vaddr + get_vm_area_size(vm))
continue;
while (addr < vaddr) {
if (count == 0)
Expand All @@ -2076,7 +2076,7 @@ long vwrite(char *buf, char *addr, unsigned long count)
addr++;
count--;
}
n = vaddr + vm->size - PAGE_SIZE - addr;
n = vaddr + get_vm_area_size(vm) - addr;
if (n > count)
n = count;
if (!(vm->flags & VM_IOREMAP)) {
Expand Down

0 comments on commit 762216a

Please sign in to comment.