[PATCH v7 2/3] kho: fix deferred init of kho scratch
Vishal Moola (Oracle)
vishal.moola at gmail.com
Tue Mar 17 16:23:07 PDT 2026
On Tue, Mar 17, 2026 at 03:15:33PM +0100, Michal Clapinski wrote:
> Currently, if DEFERRED is enabled, kho_release_scratch will initialize
> the struct pages and set migratetype of kho scratch. Unless the whole
> scratch fit below first_deferred_pfn, some of that will be overwritten
> either by deferred_init_pages or memmap_init_reserved_pages.
>
> To fix it, I modified kho_release_scratch to only set the migratetype
> on already initialized pages. Then, modified init_pageblock_migratetype
> to set the migratetype to CMA if the page is located inside scratch.
>
> Signed-off-by: Michal Clapinski <mclapinski at google.com>
> ---
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index ee81f5c67c18..5ca078dde61d 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -55,6 +55,7 @@
> #include <linux/cacheinfo.h>
> #include <linux/pgalloc_tag.h>
> #include <linux/mmzone_lock.h>
> +#include <linux/kexec_handover.h>
> #include <asm/div64.h>
> #include "internal.h"
> #include "shuffle.h"
> @@ -549,6 +550,12 @@ void __meminit init_pageblock_migratetype(struct page *page,
> migratetype < MIGRATE_PCPTYPES))
> migratetype = MIGRATE_UNMOVABLE;
>
> + /*
> + * Mark KHO scratch as CMA so no unmovable allocations are made there.
> + */
> + if (unlikely(kho_scratch_overlap(page_to_phys(page), PAGE_SIZE)))
> + migratetype = MIGRATE_CMA;
> +
> flags = migratetype;
>
> #ifdef CONFIG_MEMORY_ISOLATION
I've just tried to build the current mm-new tree. I'm getting this
error:
error: ‘MIGRATE_CMA’ undeclared (first use in this function); did you mean ‘MIGRATE_SYNC’?
557 | migratetype = MIGRATE_CMA;
| ^~~~~~~~~~~
| MIGRATE_SYNC
>From what I can tell, MIGRATE_CMA is only defined if CONFIG_CMA is
enabled (for x86 defconfig its disabled).
More information about the kexec
mailing list