Re: [PATCH v2 1/7] mm,memory_hotplug: Allocate memmap from the added memory range

From: David Hildenbrand
Date: Mon Mar 01 2021 - 03:31:58 EST


+ (*online_page_callback)(pfn_to_page(pfn), pageblock_order);
+ pfn += 1 << pageblock_order;

pfn += pageblock_nr_pages;

Can you add a comment why we can be sure that we are off by a single pageblock? What about s390x where a MAX_ORDER_NR_PAGES == 4 * pageblock_nr_pages?

Would it make thing simpler to just do a

while (!IS_ALIGNED(pfn, MAX_ORDER_NR_PAGES)) {
(*online_page_callback)(pfn_to_page(pfn), 0);
pfn++;
}

Honestly, I did not spend much time thinking on other platforms other
than arm64/x86_64.
But I think that that would be the universal solution as we do not make
any assumptions.

I will replace it.

I think you could also go with

while (!IS_ALIGNED(pfn, MAX_ORDER_NR_PAGES)) {
(*online_page_callback)(pfn_to_page(pfn), pageblock_order);
pageblock_nr_pages;
}

And maybe add a comment why we can be sure it has to be aligned to pageblocks. Or maybe rather add

VM_BUG_ON(IS_ALIGNED(pfn, pageblock_nr_pages));

--
Thanks,

David / dhildenb