Re: [PATCH v3 15/17] crash: Simplify CRASH_MAX_MEMORY_RANGES handling

Mike Rapoport <[email protected]>
Newsgroups gmane.linux.ports.ppc.embedded
Message-ID <178829364021.3691424.12328056849597833403.b4-review__25210.0603118137$1788293715$gmane$org@b4>
Hi,

> Set CRASH_MAX_MEMORY_RANGES to 0 when MEMORY_HOTPLUG is disabled, then
> remove the now unnecessary IS_ENABLED(CONFIG_MEMORY_HOTPLUG) checks in
> powerpc and x86 arch_crash_get_elfcorehdr_size().
> 
> No functional change intended.
> 
> Signed-off-by: Jinjie Ruan <[email protected]>
>
> diff --git a/arch/powerpc/kexec/crash.c b/arch/powerpc/kexec/crash.c
> index fc0105c7af4c3..c47e3f867ea1f 100644
> --- a/arch/powerpc/kexec/crash.c
> +++ b/arch/powerpc/kexec/crash.c
> @@ -474,9 +474,7 @@ unsigned int arch_crash_get_elfcorehdr_size(void)
>  	unsigned long phdr_cnt;
>  
>  	/* A program header for possible CPUs + vmcoreinfo */
> -	phdr_cnt = num_possible_cpus() + 1;
> -	if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
> -		phdr_cnt += CONFIG_CRASH_MAX_MEMORY_RANGES;
> +	phdr_cnt = num_possible_cpus() + 1 + CONFIG_CRASH_MAX_MEMORY_RANGES;
>  
>  	return elf64_phdr_size(phdr_cnt);
>  }
> diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
> index 99eb8583d9321..116410ac90fb4 100644
> --- a/arch/x86/kernel/crash.c
> +++ b/arch/x86/kernel/crash.c
> @@ -407,9 +407,7 @@ unsigned int arch_crash_get_elfcorehdr_size(void)
>  	unsigned int sz;
>  
>  	/* kernel_map, VMCOREINFO and maximum CPUs */
> -	sz = 2 + num_possible_cpus();
> -	if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
> -		sz += CONFIG_CRASH_MAX_MEMORY_RANGES;
> +	sz = 2 + num_possible_cpus() + CONFIG_CRASH_MAX_MEMORY_RANGES;
>  	sz *= sizeof(Elf64_Phdr);
>  	return sz;
>  }
> diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec
> index a97ed9605602f..e6251dfe451a8 100644
> --- a/kernel/Kconfig.kexec
> +++ b/kernel/Kconfig.kexec
> @@ -160,7 +160,8 @@ config CRASH_HOTPLUG
>  
>  config CRASH_MAX_MEMORY_RANGES
>  	int "Specify the maximum number of memory regions for the elfcorehdr"
> -	default 8192
> +	default 8192 if MEMORY_HOTPLUG
> +	default 0 if !MEMORY_HOTPLUG

This only sets the default, but a user can change the value explicitly.

-- 
Sincerely yours,
Mike.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.