From 92cd534f87b7ef038c78467db15ae15716d32d59 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Wed, 3 Oct 2007 20:42:44 -0700 Subject: [PATCH] vcompound: Virtual fallback for sparsemem Sparsemem currently attempts first to do a physically contiguous mapping and then falls back to vmalloc. The same thing can now be accomplished using GFP_VFALLBACK. Cc: apw@shadowen.org Signed-off-by: Christoph Lameter --- mm/sparse.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) Index: linux-2.6/mm/sparse.c =================================================================== --- linux-2.6.orig/mm/sparse.c 2008-02-16 18:49:16.000000000 -0800 +++ linux-2.6/mm/sparse.c 2008-02-16 18:49:27.000000000 -0800 @@ -327,24 +327,8 @@ static void __kfree_section_memmap(struc #else static struct page *__kmalloc_section_memmap(unsigned long nr_pages) { - struct page *page, *ret; - unsigned long memmap_size = sizeof(struct page) * nr_pages; - - page = alloc_pages(GFP_KERNEL|__GFP_NOWARN, get_order(memmap_size)); - if (page) - goto got_map_page; - - ret = vmalloc(memmap_size); - if (ret) - goto got_map_ptr; - - return NULL; -got_map_page: - ret = (struct page *)pfn_to_kaddr(page_to_pfn(page)); -got_map_ptr: - memset(ret, 0, memmap_size); - - return ret; + return (struct page *)__get_free_pages(GFP_VFALLBACK, + get_order(memmap_size)); } static inline struct page *kmalloc_section_memmap(unsigned long pnum, int nid, @@ -355,11 +339,8 @@ static inline struct page *kmalloc_secti static void __kfree_section_memmap(struct page *memmap, unsigned long nr_pages) { - if (is_vmalloc_addr(memmap)) - vfree(memmap); - else - free_pages((unsigned long)memmap, - get_order(sizeof(struct page) * nr_pages)); + free_pages((unsigned long)memmap, + get_order(sizeof(struct page) * nr_pages)); } #endif /* CONFIG_SPARSEMEM_VMEMMAP */