Commit 3af776f6 authored by Baoquan He's avatar Baoquan He Committed by Linus Torvalds
Browse files

mm/sparse.c: use kvmalloc/kvfree to alloc/free memmap for the classic sparse

This change makes populate_section_memmap()/depopulate_section_memmap
much simpler.
Suggested-by: default avatarMichal Hocko <>
Signed-off-by: default avatarBaoquan He <>
Signed-off-by: default avatarAndrew Morton <>
Reviewed-by: default avatarDavid Hildenbrand <>
Reviewed-by: default avatarPankaj Gupta <>
Reviewed-by: default avatarMatthew Wilcox (Oracle) <>
Reviewed-by: default avatarWei Yang <>
Acked-by: default avatarMichal Hocko <>

Signed-off-by: default avatarLinus Torvalds <>
parent e03d1f78
......@@ -664,35 +664,14 @@ static void free_map_bootmem(struct page *memmap)
struct page * __meminit populate_section_memmap(unsigned long pfn,
unsigned long nr_pages, int nid, struct vmem_altmap *altmap)
struct page *page, *ret;
unsigned long memmap_size = sizeof(struct page) * PAGES_PER_SECTION;
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;
ret = (struct page *)pfn_to_kaddr(page_to_pfn(page));
return ret;
return kvmalloc(array_size(sizeof(struct page),
static void depopulate_section_memmap(unsigned long pfn, unsigned long nr_pages,
struct vmem_altmap *altmap)
struct page *memmap = pfn_to_page(pfn);
if (is_vmalloc_addr(memmap))
free_pages((unsigned long)memmap,
get_order(sizeof(struct page) * PAGES_PER_SECTION));
static void free_map_bootmem(struct page *memmap)
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