[RFC PATCH 05/15] mm/memory_hotplug: online pages at section size.

From: Zi Yan
Date: Thu Aug 05 2021 - 15:04:04 EST


From: Zi Yan <ziy@xxxxxxxxxx>

When CONFIG_SET_MAX_ORDER is used, MAX_ORDER can be larger than section
size. Holes can appear in hotplug memory chunks with size of
2^MAX_ORDER. Use PFN_SECTION_SHIFT (the order of section size) to limit
hotplug memory size.

Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
Cc: David Hildenbrand <david@xxxxxxxxxx>
Cc: linux-mm@xxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
mm/memory_hotplug.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 85029994a494..91ca751ac20c 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -601,16 +601,16 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)
unsigned long pfn;

/*
- * Online the pages in MAX_ORDER - 1 aligned chunks. The callback might
- * decide to not expose all pages to the buddy (e.g., expose them
+ * Online the pages in PFN_SECTION_SHIFT aligned chunks. The callback
+ * might decide to not expose all pages to the buddy (e.g., expose them
* later). We account all pages as being online and belonging to this
* zone ("present").
* When using memmap_on_memory, the range might not be aligned to
- * MAX_ORDER_NR_PAGES - 1, but pageblock aligned. __ffs() will detect
- * this and the first chunk to online will be pageblock_nr_pages.
+ * PAGES_PER_SECTION - 1, but section size aligned. __ffs() will detect
+ * this and the first chunk to online will be PAGES_PER_SECTION.
*/
for (pfn = start_pfn; pfn < end_pfn;) {
- int order = min(MAX_ORDER - 1UL, __ffs(pfn));
+ int order = min_t(unsigned long, PFN_SECTION_SHIFT, __ffs(pfn));

(*online_page_callback)(pfn_to_page(pfn), order);
pfn += (1UL << order);
--
2.30.2