Commit 8757d5fa authored by Jan Kiszka's avatar Jan Kiszka Committed by Linus Torvalds

[PATCH] mm: fix oom roll-back of __vmalloc_area_node

__vunmap must not rely on area->nr_pages when picking the release methode
for area->pages.  It may be too small when __vmalloc_area_node failed early
due to lacking memory.  Instead, use a flag in vmstruct to differentiate.
Signed-off-by: default avatarJan Kiszka <jan.kiszka@web.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e322fedf
...@@ -11,6 +11,7 @@ struct vm_area_struct; ...@@ -11,6 +11,7 @@ struct vm_area_struct;
#define VM_ALLOC 0x00000002 /* vmalloc() */ #define VM_ALLOC 0x00000002 /* vmalloc() */
#define VM_MAP 0x00000004 /* vmap()ed pages */ #define VM_MAP 0x00000004 /* vmap()ed pages */
#define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */ #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
#define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
/* bits [20..32] reserved for arch specific ioremap internals */ /* bits [20..32] reserved for arch specific ioremap internals */
/* /*
......
...@@ -340,7 +340,7 @@ void __vunmap(void *addr, int deallocate_pages) ...@@ -340,7 +340,7 @@ void __vunmap(void *addr, int deallocate_pages)
__free_page(area->pages[i]); __free_page(area->pages[i]);
} }
if (area->nr_pages > PAGE_SIZE/sizeof(struct page *)) if (area->flags & VM_VPAGES)
vfree(area->pages); vfree(area->pages);
else else
kfree(area->pages); kfree(area->pages);
...@@ -427,9 +427,10 @@ void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, ...@@ -427,9 +427,10 @@ void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
area->nr_pages = nr_pages; area->nr_pages = nr_pages;
/* Please note that the recursion is strictly bounded. */ /* Please note that the recursion is strictly bounded. */
if (array_size > PAGE_SIZE) if (array_size > PAGE_SIZE) {
pages = __vmalloc_node(array_size, gfp_mask, PAGE_KERNEL, node); pages = __vmalloc_node(array_size, gfp_mask, PAGE_KERNEL, node);
else area->flags |= VM_VPAGES;
} else
pages = kmalloc_node(array_size, (gfp_mask & ~__GFP_HIGHMEM), node); pages = kmalloc_node(array_size, (gfp_mask & ~__GFP_HIGHMEM), node);
area->pages = pages; area->pages = pages;
if (!area->pages) { if (!area->pages) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment