[PATCH v2] kho: do not reserve scratch memory in the kdump kernel

Maxi Saparov posted 1 patch 1 month, 2 weeks ago
kernel/liveupdate/kexec_handover.c | 7 +++++++
1 file changed, 7 insertions(+)
[PATCH v2] kho: do not reserve scratch memory in the kdump kernel
Posted by Maxi Saparov 1 month, 2 weeks ago
From: Maxi Saparov <masaparov@coreweave.com>

If a kernel with CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y (or kho=on)
does not receive a handover FDT, it reserves KHO scratch memory in
kho_reserve_scratch().

The kdump kernel always takes this path. Since commit a6715d7ec472
("kho: skip KHO for crash kernel"), the kernel does not add KHO
metadata to the crash kimage. As a result, the kdump kernel never
receives a handover FDT and always reserves scratch memory.

The kdump kernel boots in the small crashkernel= memory reservation.
On our x86 hosts, the kernel and initramfs make approximately 176 MB
of early reservations. The scratch areas then use approximately
650 MB more of the crashkernel memory. When a large early allocation
fails, the kdump kernel panics:

  bio: can't create integrity buf pool

A kdump kernel has nothing to hand over: its only task is to dump the
memory of the old kernel and reboot. Fix is to disable KHO at the top of
kho_memory_init() so that the kdump kernel does not reserve scratch
memory.

Fixes: 3dc92c311498 ("kexec: add Kexec HandOver (KHO) generation helpers")
Cc: stable@vger.kernel.org
Signed-off-by: Maxi Saparov <masaparov@coreweave.com>
---
v2: Move the kdump check to the top of kho_memory_init() as an early return.
v1: https://lore.kernel.org/all/20260803193938.8778-1-maxi.saparov@gmail.com/

 kernel/liveupdate/kexec_handover.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 6fad9152387a..97729dec6359 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -12,6 +12,7 @@
 
 #include <linux/cleanup.h>
 #include <linux/cma.h>
+#include <linux/crash_dump.h>
 #include <linux/kmemleak.h>
 #include <linux/count_zeros.h>
 #include <linux/kasan.h>
@@ -1631,6 +1632,12 @@ fs_initcall(kho_init);
 
 void __init kho_memory_init(void)
 {
+	if (is_kdump_kernel()) {
+		kho_enable = false;
+		pr_info("disabled in the kdump kernel\n");
+		return;
+	}
+
 	if (kho_in.scratch_phys) {
 		kho_scratch = phys_to_virt(kho_in.scratch_phys);
 

base-commit: 3a0b8fa2eb36afc88b62a95f33f0c77c71fa5ded
-- 
2.55.0
Re: [PATCH v2] kho: do not reserve scratch memory in the kdump kernel
Posted by Mike Rapoport 1 month, 1 week ago
Hi,

Please don't send vN+1 as a reply to vN next time.

On Tue, Aug 11, 2026 at 12:18:57PM -0400, Maxi Saparov wrote:
> From: Maxi Saparov <masaparov@coreweave.com>
> 
> If a kernel with CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y (or kho=on)
> does not receive a handover FDT, it reserves KHO scratch memory in
> kho_reserve_scratch().
> 
> The kdump kernel always takes this path. Since commit a6715d7ec472
> ("kho: skip KHO for crash kernel"), the kernel does not add KHO
> metadata to the crash kimage. As a result, the kdump kernel never
> receives a handover FDT and always reserves scratch memory.
> 
> The kdump kernel boots in the small crashkernel= memory reservation.
> On our x86 hosts, the kernel and initramfs make approximately 176 MB
> of early reservations. The scratch areas then use approximately
> 650 MB more of the crashkernel memory. When a large early allocation
> fails, the kdump kernel panics:
> 
>   bio: can't create integrity buf pool
> 
> A kdump kernel has nothing to hand over: its only task is to dump the
> memory of the old kernel and reboot. Fix is to disable KHO at the top of
> kho_memory_init() so that the kdump kernel does not reserve scratch
> memory.
> 
> Fixes: 3dc92c311498 ("kexec: add Kexec HandOver (KHO) generation helpers")
> Cc: stable@vger.kernel.org
> Signed-off-by: Maxi Saparov <masaparov@coreweave.com>

I queued this patch for v7.4, it'll appear in the liveupdate tree after the
merge window.

> ---
> v2: Move the kdump check to the top of kho_memory_init() as an early return.
> v1: https://lore.kernel.org/all/20260803193938.8778-1-maxi.saparov@gmail.com/
> 
>  kernel/liveupdate/kexec_handover.c | 7 +++++++
>  1 file changed, 7 insertions(+)

-- 
Sincerely yours,
Mike.
Re: [PATCH v2] kho: do not reserve scratch memory in the kdump kernel
Posted by Maxi Saparov 1 month ago
Hi,

On Sun, Aug 16, 2026 at 12:03:08PM -0500, Mike Rapoport wrote:
> Hi,
> 
> Please don't send vN+1 as a reply to vN next time.
> 

Ack, sorry about that! Thank you for the review.

Maxi