Re: [PATCH v5 4/4] mm/sparse: Optimize memmap allocation during sparse_init()
From: Pavel Tatashin
Date: Fri Jun 29 2018 - 13:48:50 EST
> > + * increase 'nr_consumed_maps' whether its allocation of memmap
> > + * or usemap failed or not, so that after we handle the i-th
> > + * memory section, can get memmap and usemap of (i+1)-th section
> > + * correctly. */
>
> This makes no sense to me. Why are we incrementing 'nr_consumed_maps'
> when we do not consume one?
>
> You say that we increment it so that things will work, but not how or
> why it makes things work. I'm confused.
Hi Dave,
nr_consumed_maps is a local counter. map_map contains struct pages for
each section. In order to assign them to correct sections this local
counter must be incremented even when some parts of map_map are empty.
Here is example:
Node1:
map_map[0] -> Struct pages ...
map_map[1] -> NULL
Node2:
map_map[2] -> Struct pages ...
We always want to configure section from Node2 with struct pages from
Node2. Even, if there are holes in-between. The same with usemap.
Pavel