- /*
- * This can potentially allocate memory, and does its own
- * internal locking.
- */
- sparse_index_init(pfn_to_section_nr(phys_start_pfn), pgdat->node_id);
-
- pgdat_resize_lock(pgdat, &flags);
- memmap = __kmalloc_section_memmap(nr_pages);
- ret = sparse_add_one_section(zone, phys_start_pfn, memmap);
- pgdat_resize_unlock(pgdat, &flags);
-
- if (ret <= 0) {
- /* the mem_map didn't get used */
- if (memmap >= (struct page *)VMALLOC_START &&
- memmap < (struct page *)VMALLOC_END)
- vfree(memmap);
- else
- free_pages((unsigned long)memmap,
- get_order(sizeof(struct page) * nr_pages));
- }