mm/sparsemem: introduce a SECTION_IS_EARLY flag

In preparation for sub-section hotplug, track whether a given section
was created during early memory initialization, or later via memory
hotplug.  This distinction is needed to maintain the coarse expectation
that pfn_valid() returns true for any pfn within a given section even if
that section has pages that are reserved from the page allocator.

For example one of the of goals of subsection hotplug is to support
cases where the system physical memory layout collides System RAM and
PMEM within a section.  Several pfn_valid() users expect to just check
if a section is valid, but they are not careful to check if the given
pfn is within a "System RAM" boundary and instead expect pgdat
information to further validate the pfn.

Rather than unwind those paths to make their pfn_valid() queries more
precise a follow on patch uses the SECTION_IS_EARLY flag to maintain the
traditional expectation that pfn_valid() returns true for all early

Signed-off-by: Dan Williams <>
Reported-by: Qian Cai <>
Tested-by: Aneesh Kumar K.V <>	[ppc64]
Reviewed-by: Oscar Salvador <>
Cc: Michal Hocko <>
Cc: Logan Gunthorpe <>
Cc: David Hildenbrand <>
Cc: Pavel Tatashin <>
Cc: Jane Chu <>
Cc: Jeff Moyer <>
Cc: Jérôme Glisse <>
Cc: Jonathan Corbet <>
Cc: Mike Rapoport <>
Cc: Toshi Kani <>
Cc: Vlastimil Babka <>
Cc: Wei Yang <>
Cc: Jason Gunthorpe <>
Cc: Christoph Hellwig <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
2 files changed