[PATCH v9 0/3] kho: add support for deferred struct page init

Michal Clapinski posted 3 patches 1 month, 2 weeks ago
include/linux/memblock.h              | 21 +++++++++-
kernel/liveupdate/Kconfig             |  2 -
kernel/liveupdate/kexec_handover.c    | 52 ++++++++++++-------------
mm/memblock.c                         | 56 +++++++++++----------------
mm/mm_init.c                          | 30 +++++++-------
tools/testing/selftests/kho/vmtest.sh |  4 ++
6 files changed, 88 insertions(+), 77 deletions(-)
[PATCH v9 0/3] kho: add support for deferred struct page init
Posted by Michal Clapinski 1 month, 2 weeks ago
When CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled, struct page
initialization is deferred to parallel kthreads that run later in
the boot process.

Currently, KHO is incompatible with DEFERRED.
This series fixes that incompatibility.
---
v9:
- moved init_pageblock_migratetype from memmap_init_reserved_range
  to __init_page_from_nid
- reduced number of ifdefs
- new commit to test this feature
v8:
- moved overriding the migratetype from init_pageblock_migratetype
  to callsites
v7:
- reimplemented the initialization of kho scratch again
v6:
- reimplemented the initialization of kho scratch
v5:
- rebased
v4:
- added a new commit to fix deferred init of kho scratch
- switched to ulong when refering to pfn
v3:
- changed commit msg
- don't invoke early_pfn_to_nid if CONFIG_DEFERRED_STRUCT_PAGE_INIT=n
v2:
- updated a comment

I took Evangelos's test code:
https://git.infradead.org/?p=users/vpetrog/linux.git;a=shortlog;h=refs/heads/kho-deferred-struct-page-init
and then modified it to this monster test that does 2 allocations:
at core_initcall (early) and at module_init (late). Then kexec, then
2 more allocations at these points, then restore the original 2, then
kexec, then restore the other 2. Basically I test preservation of early
and late allocation both on cold and on warm boot.
Tested it both with and without DEFERRED.
https://github.com/mclapinski/linux/commits/deferred_test/

This patch probably doesn't apply onto anything currently.
It's based on mm-new with
"memblock: move reserve_bootmem_range() to memblock.c and make it static"
cherrypicked from rppt/memblock.

Evangelos Petrongonas (1):
  kho: make preserved pages compatible with deferred struct page init

Michal Clapinski (2):
  kho: fix deferred initialization of scratch areas
  selftests: kho: test with deferred struct page init

 include/linux/memblock.h              | 21 +++++++++-
 kernel/liveupdate/Kconfig             |  2 -
 kernel/liveupdate/kexec_handover.c    | 52 ++++++++++++-------------
 mm/memblock.c                         | 56 +++++++++++----------------
 mm/mm_init.c                          | 30 +++++++-------
 tools/testing/selftests/kho/vmtest.sh |  4 ++
 6 files changed, 88 insertions(+), 77 deletions(-)

-- 
2.54.0.rc2.533.g4f5dca5207-goog
Re: [PATCH v9 0/3] kho: add support for deferred struct page init
Posted by Mike Rapoport 1 month, 1 week ago
Hi Michal,

On Thu, Apr 23, 2026 at 02:25:35PM +0200, Michal Clapinski wrote:
> When CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled, struct page
> initialization is deferred to parallel kthreads that run later in
> the boot process.

This patchset breaks memblock tests:
https://github.com/linux-mm/linux-mm/actions/runs/25259346624/job/74063911769

Can you please send a fix?
 
> Michal Clapinski (2):
>   kho: fix deferred initialization of scratch areas
>   selftests: kho: test with deferred struct page init
> 
>  include/linux/memblock.h              | 21 +++++++++-
>  kernel/liveupdate/Kconfig             |  2 -
>  kernel/liveupdate/kexec_handover.c    | 52 ++++++++++++-------------
>  mm/memblock.c                         | 56 +++++++++++----------------
>  mm/mm_init.c                          | 30 +++++++-------
>  tools/testing/selftests/kho/vmtest.sh |  4 ++
>  6 files changed, 88 insertions(+), 77 deletions(-)
> 
> -- 
> 2.54.0.rc2.533.g4f5dca5207-goog
> 

-- 
Sincerely yours,
Mike.
Re: [PATCH v9 0/3] kho: add support for deferred struct page init
Posted by Pratyush Yadav 1 month, 1 week ago
On Sun, May 03 2026, Mike Rapoport wrote:

> Hi Michal,
>
> On Thu, Apr 23, 2026 at 02:25:35PM +0200, Michal Clapinski wrote:
>> When CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled, struct page
>> initialization is deferred to parallel kthreads that run later in
>> the boot process.
>
> This patchset breaks memblock tests:
> https://github.com/linux-mm/linux-mm/actions/runs/25259346624/job/74063911769
>
> Can you please send a fix?

Would something like this do the trick? It fixes the build for me and
the tests pass.

I can send this as a proper patch if this looks good.

--- 8< ---
diff --git a/tools/testing/memblock/linux/mmzone.h b/tools/testing/memblock/linux/mmzone.h
index bb682659a12d..8d934ff5b080 100644
--- a/tools/testing/memblock/linux/mmzone.h
+++ b/tools/testing/memblock/linux/mmzone.h
@@ -35,4 +35,8 @@ typedef struct pglist_data {
 
 } pg_data_t;
 
+enum migratetype {
+	MIGRATE_CMA,
+};
+
 #endif
-- 
Regards,
Pratyush Yadav
Re: [PATCH v9 0/3] kho: add support for deferred struct page init
Posted by Mike Rapoport 1 month, 1 week ago
On Mon, May 04, 2026 at 09:53:01AM +0200, Pratyush Yadav wrote:
> On Sun, May 03 2026, Mike Rapoport wrote:
> 
> > Hi Michal,
> >
> > On Thu, Apr 23, 2026 at 02:25:35PM +0200, Michal Clapinski wrote:
> >> When CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled, struct page
> >> initialization is deferred to parallel kthreads that run later in
> >> the boot process.
> >
> > This patchset breaks memblock tests:
> > https://github.com/linux-mm/linux-mm/actions/runs/25259346624/job/74063911769
> >
> > Can you please send a fix?
> 
> Would something like this do the trick? It fixes the build for me and
> the tests pass.
> 
> I can send this as a proper patch if this looks good.

Yes, please :)
 
> --- 8< ---
> diff --git a/tools/testing/memblock/linux/mmzone.h b/tools/testing/memblock/linux/mmzone.h
> index bb682659a12d..8d934ff5b080 100644
> --- a/tools/testing/memblock/linux/mmzone.h
> +++ b/tools/testing/memblock/linux/mmzone.h
> @@ -35,4 +35,8 @@ typedef struct pglist_data {
>  
>  } pg_data_t;
>  
> +enum migratetype {
> +	MIGRATE_CMA,
> +};
> +
>  #endif
> -- 
> Regards,
> Pratyush Yadav

-- 
Sincerely yours,
Mike.
Re: [PATCH v9 0/3] kho: add support for deferred struct page init
Posted by Mike Rapoport 1 month, 2 weeks ago
From: Mike Rapoport (Microsoft) <rppt@kernel.org>

On Thu, 23 Apr 2026 14:25:35 +0200, Michal Clapinski wrote:
> When CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled, struct page
> initialization is deferred to parallel kthreads that run later in
> the boot process.
> 
> Currently, KHO is incompatible with DEFERRED.
> This series fixes that incompatibility.
> 
> [...]

Applied to next branch of liveupdate/linux.git tree, thanks!

[1/3] kho: fix deferred initialization of scratch areas
      commit: fe60961059eee7a3a303454c827bb347c45612c1
[2/3] kho: make preserved pages compatible with deferred struct page init
      commit: d4835433f4f6b5d618955a6a6eeb3e9f8b2b725e
[3/3] selftests: kho: test with deferred struct page init
      commit: eee13213401bafb7ffe3b447adffb1f570b9d813

tree: https://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux
branch: next

--
Sincerely yours,
Mike.