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

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 <mhocko@kernel.org>
Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
Reviewed-by: default avatarPankaj Gupta <pankaj.gupta.linux@gmail.com>
Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarWei Yang <richard.weiyang@gmail.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Link: http://lkml.kernel.org/r/20200316125450.GG3486@MiWiFi-R3L-srvSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e03d1f78
...@@ -664,35 +664,14 @@ static void free_map_bootmem(struct page *memmap) ...@@ -664,35 +664,14 @@ static void free_map_bootmem(struct page *memmap)
struct page * __meminit populate_section_memmap(unsigned long pfn, struct page * __meminit populate_section_memmap(unsigned long pfn,
unsigned long nr_pages, int nid, struct vmem_altmap *altmap) unsigned long nr_pages, int nid, struct vmem_altmap *altmap)
{ {
struct page *page, *ret; return kvmalloc(array_size(sizeof(struct page),
unsigned long memmap_size = sizeof(struct page) * PAGES_PER_SECTION; PAGES_PER_SECTION), GFP_KERNEL);
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:
return ret;
} }
static void depopulate_section_memmap(unsigned long pfn, unsigned long nr_pages, static void depopulate_section_memmap(unsigned long pfn, unsigned long nr_pages,
struct vmem_altmap *altmap) struct vmem_altmap *altmap)
{ {
struct page *memmap = pfn_to_page(pfn); kvfree(pfn_to_page(pfn));
if (is_vmalloc_addr(memmap))
vfree(memmap);
else
free_pages((unsigned long)memmap,
get_order(sizeof(struct page) * PAGES_PER_SECTION));
} }
static void free_map_bootmem(struct page *memmap) 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