diff mbox series

powerpc/kdump: handle crashkernel memory reservation failure

Message ID 153016319642.8584.7868984232962915832.stgit@hbathini.in.ibm.com (mailing list archive)
State Accepted
Commit 8950329c4a64c6d3ca0bc34711a1afbd9ce05657
Headers show
Series powerpc/kdump: handle crashkernel memory reservation failure | expand

Commit Message

Hari Bathini June 28, 2018, 5:19 a.m. UTC
Memory reservation for crashkernel could fail if there are holes around
kdump kernel offset (128M). Fail gracefully in such cases and print an
error message.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
---
 arch/powerpc/kernel/machine_kexec.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

David Gibson June 28, 2018, 5:32 a.m. UTC | #1
On Thu, 28 Jun 2018 10:49:56 +0530
Hari Bathini <hbathini@linux.ibm.com> wrote:

> Memory reservation for crashkernel could fail if there are holes around
> kdump kernel offset (128M). Fail gracefully in such cases and print an
> error message.
> 
> Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>

Tested-by: David Gibson <dgibson@redhat.com>

> ---
>  arch/powerpc/kernel/machine_kexec.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
> index 936c7e2..6181442 100644
> --- a/arch/powerpc/kernel/machine_kexec.c
> +++ b/arch/powerpc/kernel/machine_kexec.c
> @@ -188,7 +188,12 @@ void __init reserve_crashkernel(void)
>  			(unsigned long)(crashk_res.start >> 20),
>  			(unsigned long)(memblock_phys_mem_size() >> 20));
>  
> -	memblock_reserve(crashk_res.start, crash_size);
> +	if (!memblock_is_region_memory(crashk_res.start, crash_size) ||
> +	    memblock_reserve(crashk_res.start, crash_size)) {
> +		printk(KERN_ERR "Failed to reserve memory for crashkernel!\n");
> +		crashk_res.start = crashk_res.end = 0;
> +		return;
> +	}
>  }
>  
>  int overlaps_crashkernel(unsigned long start, unsigned long size)
>
Dave Young June 28, 2018, 6:48 a.m. UTC | #2
On 06/28/18 at 10:49am, Hari Bathini wrote:
> Memory reservation for crashkernel could fail if there are holes around
> kdump kernel offset (128M). Fail gracefully in such cases and print an
> error message.
> 
> Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
> ---
>  arch/powerpc/kernel/machine_kexec.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
> index 936c7e2..6181442 100644
> --- a/arch/powerpc/kernel/machine_kexec.c
> +++ b/arch/powerpc/kernel/machine_kexec.c
> @@ -188,7 +188,12 @@ void __init reserve_crashkernel(void)
>  			(unsigned long)(crashk_res.start >> 20),
>  			(unsigned long)(memblock_phys_mem_size() >> 20));
>  
> -	memblock_reserve(crashk_res.start, crash_size);
> +	if (!memblock_is_region_memory(crashk_res.start, crash_size) ||
> +	    memblock_reserve(crashk_res.start, crash_size)) {
> +		printk(KERN_ERR "Failed to reserve memory for crashkernel!\n");
> +		crashk_res.start = crashk_res.end = 0;
> +		return;
> +	}
>  }
>  
>  int overlaps_crashkernel(unsigned long start, unsigned long size)
> 

It would be better to print a separate error message for !memblock_is_region_memory
But I think memblock_reserve is unlikly to fail so this patch is also
good.

Reviewed-by: Dave Young <dyoung@redhat.com>

Thanks
Dave
Michael Ellerman July 19, 2018, 6:07 a.m. UTC | #3
On Thu, 2018-06-28 at 05:19:56 UTC, Hari Bathini wrote:
> Memory reservation for crashkernel could fail if there are holes around
> kdump kernel offset (128M). Fail gracefully in such cases and print an
> error message.
> 
> Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
> Tested-by: David Gibson <dgibson@redhat.com>
> Reviewed-by: Dave Young <dyoung@redhat.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/8950329c4a64c6d3ca0bc34711a1af

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index 936c7e2..6181442 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -188,7 +188,12 @@  void __init reserve_crashkernel(void)
 			(unsigned long)(crashk_res.start >> 20),
 			(unsigned long)(memblock_phys_mem_size() >> 20));
 
-	memblock_reserve(crashk_res.start, crash_size);
+	if (!memblock_is_region_memory(crashk_res.start, crash_size) ||
+	    memblock_reserve(crashk_res.start, crash_size)) {
+		printk(KERN_ERR "Failed to reserve memory for crashkernel!\n");
+		crashk_res.start = crashk_res.end = 0;
+		return;
+	}
 }
 
 int overlaps_crashkernel(unsigned long start, unsigned long size)