The patch titled Subject: mm,memory_hotplug: fix shrink_{zone,node}_span has been added to the -mm tree. Its filename is mm-hotplug-prepare-shrink_zone-pgdat_span-for-sub-section-removal-fix.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-hotplug-prepare-shrink_zone-pgdat_span-for-sub-section-removal-fix.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-hotplug-prepare-shrink_zone-pgdat_span-for-sub-section-removal-fix.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Oscar Salvador <osalvador@xxxxxxx> Subject: mm,memory_hotplug: fix shrink_{zone,node}_span Since [1], shrink_{zone,node}_span work on PAGES_PER_SUBSECTION granularity. We need to adapt the loop that checks whether a zone/node contains only holes, and skip the whole range to be removed. Otherwise, since sub-sections belonging to the range to be removed have not yet been deactivated, pfn_valid() will return true on those and we will be left with a wrong accounting of spanned_pages, both for the zone and the node. Link: http://lkml.kernel.org/r/20190717090725.23618-3-osalvador@xxxxxxx Fixes: mmotm ("mm/hotplug: prepare shrink_{zone, pgdat}_span for sub-section removal") Signed-off-by: Oscar Salvador <osalvador@xxxxxxx> Reviewed-by: Dan Williams <dan.j.williams@xxxxxxxxx> Cc: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memory_hotplug.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/mm/memory_hotplug.c~mm-hotplug-prepare-shrink_zone-pgdat_span-for-sub-section-removal-fix +++ a/mm/memory_hotplug.c @@ -409,8 +409,8 @@ static void shrink_zone_span(struct zone if (page_zone(pfn_to_page(pfn)) != zone) continue; - /* If the section is current section, it continues the loop */ - if (start_pfn == pfn) + /* Skip range to be removed */ + if (pfn >= start_pfn && pfn < end_pfn) continue; /* If we find valid section, we have nothing to do */ @@ -474,8 +474,8 @@ static void shrink_pgdat_span(struct pgl if (pfn_to_nid(pfn) != nid) continue; - /* If the section is current section, it continues the loop */ - if (start_pfn == pfn) + /* Skip range to be removed */ + if (pfn >= start_pfn && pfn < end_pfn) continue; /* If we find valid section, we have nothing to do */ _ Patches currently in -mm which might be from osalvador@xxxxxxx are mm-hotplug-prepare-shrink_zone-pgdat_span-for-sub-section-removal-fix.patch mm-sparsemem-support-sub-section-hotplug-fix.patch mm-sparsemem-support-sub-section-hotplug-fix-fix.patch