Re: [PATCH 2/2] mm/sparse.c: Add nr_present_sections to change the mem_map allocation

From: Baoquan He
Date: Thu Feb 01 2018 - 09:33:43 EST


On 02/01/18 at 06:23am, Dave Hansen wrote:
> On 02/01/2018 06:19 AM, Baoquan He wrote:
> >
> > I suppose these functions changed here are only called during system
> > bootup, namely in paging_init(). Hot-add memory goes in a different
> > path, __add_section() -> sparse_add_one_section(), different called
> > functions.
>
> But does this keep those sections that were not present on boot from
> being added later?

I think it won't. As you can see, the referred functions are only called
during init stage. If anyone try to use any of them for later hot-add memory,
that will cause problem, lucky there isn't. And this is only used to
store the allocated usemap and mem_map for each present section on boot.
After that, the usemap_map and map_map pointer array will be freed, they
are temporary here. I forget mentioning this in patch log, sorry for bringing
confusion.

void __init sparse_memory_present_with_active_regions(int nid)
void __init memory_present(int nid, unsigned long start, unsigned long end)
void __init sparse_init(void)
static void __init alloc_usemap_and_memmap(...)
static void __init sparse_early_usemaps_alloc_node(...)
static void __init sparse_early_mem_maps_alloc_node(...)
void __init sparse_mem_maps_populate_node(...)
void __init sparse_mem_maps_populate_node(...)