Re: [PATCH] kdump: Defer the insertion of crashkernel resources

From: Andrew Morton
Date: Fri Jan 05 2024 - 11:49:45 EST


On Fri, 29 Dec 2023 16:02:13 +0800 Huacai Chen <chenhuacai@xxxxxxxxxxx> wrote:

> In /proc/iomem, sub-regions should be inserted after their parent,
> otherwise the insertion of parent resource fails. But after generic
> crashkernel reservation applied, in both RISC-V and ARM64 (LoongArch
> will also use generic reservation later on), crashkernel resources are
> inserted before their parent, which causes the parent disappear in
> /proc/iomem. So we defer the insertion of crashkernel resources to an
> early_initcall().
>
> ...
>
> --- a/kernel/crash_core.c
> +++ b/kernel/crash_core.c
> @@ -377,7 +377,6 @@ static int __init reserve_crashkernel_low(unsigned long long low_size)
>
> crashk_low_res.start = low_base;
> crashk_low_res.end = low_base + low_size - 1;
> - insert_resource(&iomem_resource, &crashk_low_res);
> #endif
> return 0;
> }
> @@ -459,8 +458,19 @@ void __init reserve_crashkernel_generic(char *cmdline,
>
> crashk_res.start = crash_base;
> crashk_res.end = crash_base + crash_size - 1;
> - insert_resource(&iomem_resource, &crashk_res);
> }
> +
> +static __init int insert_crashkernel_resources(void)
> +{
> + if (crashk_res.start < crashk_res.end)
> + insert_resource(&iomem_resource, &crashk_res);
> +
> + if (crashk_low_res.start < crashk_low_res.end)
> + insert_resource(&iomem_resource, &crashk_low_res);
> +
> + return 0;
> +}
> +early_initcall(insert_crashkernel_resources);
> #endif
>
> int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,

I'm thinking

Fixes: 0ab97169aa0 ("crash_core: add generic function to do reservation").

Also, is this a regression? Were earlier kernels OK?