[Devel] [PATCH RHEL7 COMMIT] ms/mm/vmalloc: use wrapper function get_vm_area_size to caculate size of vm area

Konstantin Khorenko khorenko at virtuozzo.com
Thu Sep 3 08:27:31 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.6.6
------>
commit abee218424a2434e8cc576037563de55bec730de
Author: Andrey Ryabinin <aryabinin at odin.com>
Date:   Thu Sep 3 19:27:31 2015 +0400

    ms/mm/vmalloc: use wrapper function get_vm_area_size to caculate size of vm area
    
    https://jira.sw.ru/browse/PSBM-26429
    
    From: Wanpeng Li <liwanp at linux.vnet.ibm.com>
    
    commit 762216ab4e175f49d17bc7ad778c57b9028184e6 upstream.
    
    Use wrapper function get_vm_area_size to calculate size of vm area.
    
    Signed-off-by: Wanpeng Li <liwanp at linux.vnet.ibm.com>
    Cc: Dave Hansen <dave.hansen at linux.intel.com>
    Cc: Rik van Riel <riel at redhat.com>
    Cc: Fengguang Wu <fengguang.wu at intel.com>
    Cc: Joonsoo Kim <iamjoonsoo.kim at lge.com>
    Cc: Johannes Weiner <hannes at cmpxchg.org>
    Cc: Tejun Heo <tj at kernel.org>
    Cc: Yasuaki Ishimatsu <isimatu.yasuaki at jp.fujitsu.com>
    Cc: David Rientjes <rientjes at google.com>
    Cc: KOSAKI Motohiro <kosaki.motohiro at jp.fujitsu.com>
    Cc: Jiri Kosina <jkosina at suse.cz>
    Cc: Wanpeng Li <liwanp at linux.vnet.ibm.com>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
    Signed-off-by: Andrey Ryabinin <aryabinin at odin.com>
    
    Signed-off-by: Andrey Ryabinin <aryabinin at odin.com>
---
 mm/vmalloc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 7fbc92a..0c531e1 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1285,7 +1285,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);
@@ -1605,7 +1605,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;
@@ -2037,7 +2037,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)
@@ -2047,7 +2047,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))
@@ -2119,7 +2119,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)
@@ -2128,7 +2128,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)) {



More information about the Devel mailing list