Re: [PATCH v5 17/22] mm/mm_init: don't rely on memblock to get KHO scratch migratetype
From: Pratyush Yadav
Date: Thu Jul 30 2026 - 07:58:06 EST
On Thu, Jul 30 2026, Mike Rapoport wrote:
> On Wed, Jul 29, 2026 at 04:56:02PM +0200, Pratyush Yadav wrote:
>> From: "Pratyush Yadav (Google)" <pratyush@xxxxxxxxxx>
>>
>> Currently struct page init via memmap_init() or deferred_init_memmap()
>> only queries the migrate type from KHO for each discrete memory range.
>> That works currently since KHO scratch memory has a different memory
>> type so it is always it its own region.
>>
>> An upcoming patch will add support for discovering blocks of memory with
>> no preservations and it will mark it as MEMBLOCK_KHO_SCRATCH to allow
>> allocations from them. This can lead to the bootmem KHO scratch areas to
>> be merged into larger free ranges. This merging breaks the selection of
>> migrate type.
>>
>> Get rid of memblock_is_kho_scratch_memory(). Instead, use
>> kho_scratch_overlap() to decide the migrate type of the PFN. Since
>> kho_scratch_migratetype() only uses KHO functions, move it to
>> kexec_handover.h.
>>
>> Instead of calling kho_scratch_migratetype() once for each free range,
>> call it once for each pageblock. Update
>> pageblock_migratetype_init_range() and memmap_init_range() to do so.
>>
>> Since the migrate type is now evaluated for each pageblock and not each
>> free range, drop the migratetype arguments to deferred_free_pages() and
>> memmap_init_zone_range() and use MIGRATE_MOVABLE directly.
>>
>> Signed-off-by: Pratyush Yadav (Google) <pratyush@xxxxxxxxxx>
>> ---
>> include/linux/kexec_handover.h | 15 +++++++++++++++
>> include/linux/memblock.h | 19 -------------------
>> mm/memblock.c | 10 ----------
>> mm/mm_init.c | 27 +++++++++++++--------------
>> 4 files changed, 28 insertions(+), 43 deletions(-)
>>
>> diff --git a/include/linux/kexec_handover.h b/include/linux/kexec_handover.h
>> index 18ba417f1ada..c83ec4a15fe7 100644
>> --- a/include/linux/kexec_handover.h
>> +++ b/include/linux/kexec_handover.h
>> @@ -5,6 +5,7 @@
>> #include <linux/err.h>
>> #include <linux/errno.h>
>> #include <linux/types.h>
>> +#include <linux/mmzone.h>
>
> Should have been mm.h, kbuild bot is unhappy otherwise :)
>
> https://lore.kernel.org/all/202607301001.ARjK0D4v-lkp@xxxxxxxxx
>
> I can fix it while applying.
I pulled this in for definition of enum migratetype. But I forgot about
pageblock_order. I plan to do a v6 with the lockdep and documentation
fixes anyway, so will fix that in v6.
--
Regards,
Pratyush Yadav