The patch titled Subject: mm/hotplug: prepare shrink_{zone, pgdat}_span for sub-section removal has been added to the -mm tree. Its filename is mm-hotplug-prepare-shrink_zone-pgdat_span-for-sub-section-removal.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.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-hotplug-prepare-shrink_zone-pgdat_span-for-sub-section-removal.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: Dan Williams <dan.j.williams@xxxxxxxxx> Subject: mm/hotplug: prepare shrink_{zone, pgdat}_span for sub-section removal Sub-section hotplug support reduces the unit of operation of hotplug from section-sized-units (PAGES_PER_SECTION) to sub-section-sized units (PAGES_PER_SUBSECTION). Teach shrink_{zone,pgdat}_span() to consider PAGES_PER_SUBSECTION boundaries as the points where pfn_valid(), not valid_section(), can toggle. Link: http://lkml.kernel.org/r/155552635609.2015392.6246305135559796835.stgit@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Logan Gunthorpe <logang@xxxxxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Jeff Moyer <jmoyer@xxxxxxxxxx> Cc: Jérôme Glisse <jglisse@xxxxxxxxxx> Cc: Toshi Kani <toshi.kani@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/mmzone.h | 2 ++ mm/memory_hotplug.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) --- a/include/linux/mmzone.h~mm-hotplug-prepare-shrink_zone-pgdat_span-for-sub-section-removal +++ a/include/linux/mmzone.h @@ -1106,6 +1106,8 @@ static inline unsigned long section_nr_t #define SECTION_ACTIVE_SIZE ((1UL << SECTION_SIZE_BITS) / BITS_PER_LONG) #define SECTION_ACTIVE_MASK (~(SECTION_ACTIVE_SIZE - 1)) +#define PAGES_PER_SUB_SECTION (SECTION_ACTIVE_SIZE / PAGE_SIZE) +#define PAGE_SUB_SECTION_MASK (~(PAGES_PER_SUB_SECTION-1)) struct mem_section_usage { /* --- a/mm/memory_hotplug.c~mm-hotplug-prepare-shrink_zone-pgdat_span-for-sub-section-removal +++ a/mm/memory_hotplug.c @@ -326,10 +326,10 @@ static unsigned long find_smallest_secti { struct mem_section *ms; - for (; start_pfn < end_pfn; start_pfn += PAGES_PER_SECTION) { + for (; start_pfn < end_pfn; start_pfn += PAGES_PER_SUB_SECTION) { ms = __pfn_to_section(start_pfn); - if (unlikely(!valid_section(ms))) + if (unlikely(!pfn_valid(start_pfn))) continue; if (unlikely(pfn_to_nid(start_pfn) != nid)) @@ -354,10 +354,10 @@ static unsigned long find_biggest_sectio /* pfn is the end pfn of a memory section. */ pfn = end_pfn - 1; - for (; pfn >= start_pfn; pfn -= PAGES_PER_SECTION) { + for (; pfn >= start_pfn; pfn -= PAGES_PER_SUB_SECTION) { ms = __pfn_to_section(pfn); - if (unlikely(!valid_section(ms))) + if (unlikely(!pfn_valid(pfn))) continue; if (unlikely(pfn_to_nid(pfn) != nid)) @@ -416,10 +416,10 @@ static void shrink_zone_span(struct zone * it check the zone has only hole or not. */ pfn = zone_start_pfn; - for (; pfn < zone_end_pfn; pfn += PAGES_PER_SECTION) { + for (; pfn < zone_end_pfn; pfn += PAGES_PER_SUB_SECTION) { ms = __pfn_to_section(pfn); - if (unlikely(!valid_section(ms))) + if (unlikely(!pfn_valid(pfn))) continue; if (page_zone(pfn_to_page(pfn)) != zone) @@ -484,10 +484,10 @@ static void shrink_pgdat_span(struct pgl * has only hole or not. */ pfn = pgdat_start_pfn; - for (; pfn < pgdat_end_pfn; pfn += PAGES_PER_SECTION) { + for (; pfn < pgdat_end_pfn; pfn += PAGES_PER_SUB_SECTION) { ms = __pfn_to_section(pfn); - if (unlikely(!valid_section(ms))) + if (unlikely(!pfn_valid(pfn))) continue; if (pfn_to_nid(pfn) != nid) _ Patches currently in -mm which might be from dan.j.williams@xxxxxxxxx are init-initialize-jump-labels-before-command-line-option-parsing.patch mm-sparsemem-introduce-struct-mem_section_usage.patch mm-sparsemem-introduce-common-definitions-for-the-size-and-mask-of-a-section.patch mm-sparsemem-add-helpers-track-active-portions-of-a-section-at-boot.patch mm-hotplug-prepare-shrink_zone-pgdat_span-for-sub-section-removal.patch mm-sparsemem-convert-kmalloc_section_memmap-to-populate_section_memmap.patch mm-hotplug-add-mem-hotplug-restrictions-for-remove_memory.patch mm-kill-is_dev_zone-helper.patch mm-sparsemem-prepare-for-sub-section-ranges.patch mm-sparsemem-support-sub-section-hotplug.patch mm-devm_memremap_pages-enable-sub-section-remap.patch libnvdimm-pfn-fix-fsdax-mode-namespace-info-block-zero-fields.patch libnvdimm-pfn-stop-padding-pmem-namespaces-to-section-alignment.patch mm-shuffle-initial-free-memory-to-improve-memory-side-cache-utilization.patch mm-shuffle-initial-free-memory-to-improve-memory-side-cache-utilization-fix.patch mm-move-buddy-list-manipulations-into-helpers.patch mm-move-buddy-list-manipulations-into-helpers-fix.patch mm-maintain-randomization-of-page-free-lists.patch