2007-10-24 16:53:12

by Bernhard Walle

[permalink] [raw]
Subject: [patch 2/2] Use BOOTMEM_EXCLUSIVE for kdump

This patch uses the BOOTMEM_EXCLUSIVE, introduced in the previous patch,
to avoid conflicts while reserving the memory for the kdump carpture kernel
(crashkernel=).


Signed-off-by: Bernhard Walle <[email protected]>

---
arch/sh/kernel/setup.c | 29 ++++++++++++++++++-----------
arch/x86/kernel/setup_32.c | 28 ++++++++++++++++++----------
arch/x86/kernel/setup_64.c | 35 +++++++++++++++++++++--------------
3 files changed, 57 insertions(+), 35 deletions(-)

--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -140,19 +140,26 @@ static void __init reserve_crashkernel(v
ret = parse_crashkernel(boot_command_line, free_mem,
&crash_size, &crash_base);
if (ret == 0 && crash_size) {
- if (crash_base > 0) {
- printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
- "for crashkernel (System RAM: %ldMB)\n",
- (unsigned long)(crash_size >> 20),
- (unsigned long)(crash_base >> 20),
- (unsigned long)(free_mem >> 20));
- crashk_res.start = crash_base;
- crashk_res.end = crash_base + crash_size - 1;
- reserve_bootmem(crash_base, crash_size,
- BOOTMEM_DEFAULT);
- } else
+ if (crash_base <= 0) {
printk(KERN_INFO "crashkernel reservation failed - "
"you have to specify a base address\n");
+ return;
+ }
+
+ if (reserve_bootmem(crash_base, crash_size,
+ BOOTMEM_EXCLUSIVE) < 0) {
+ printk(KERN_INFO "crashkernel reservation failed - "
+ "memory is in use\n");
+ return;
+ }
+
+ printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
+ "for crashkernel (System RAM: %ldMB)\n",
+ (unsigned long)(crash_size >> 20),
+ (unsigned long)(crash_base >> 20),
+ (unsigned long)(free_mem >> 20));
+ crashk_res.start = crash_base;
+ crashk_res.end = crash_base + crash_size - 1;
}
}
#else
--- a/arch/x86/kernel/setup_32.c
+++ b/arch/x86/kernel/setup_32.c
@@ -404,18 +404,26 @@ static void __init reserve_crashkernel(v
ret = parse_crashkernel(boot_command_line, total_mem,
&crash_size, &crash_base);
if (ret == 0 && crash_size > 0) {
- if (crash_base > 0) {
- printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
- "for crashkernel (System RAM: %ldMB)\n",
- (unsigned long)(crash_size >> 20),
- (unsigned long)(crash_base >> 20),
- (unsigned long)(total_mem >> 20));
- crashk_res.start = crash_base;
- crashk_res.end = crash_base + crash_size - 1;
- reserve_bootmem(crash_base, crash_size, BOOTMEM_DEFAULT);
- } else
+ if (crash_base <= 0) {
printk(KERN_INFO "crashkernel reservation failed - "
"you have to specify a base address\n");
+ return;
+ }
+
+ if (reserve_bootmem(crash_base, crash_size,
+ BOOTMEM_EXCLUSIVE) < 0) {
+ printk(KERN_INFO "crashkernel reservation failed - "
+ "memory is in use\n");
+ return;
+ }
+
+ printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
+ "for crashkernel (System RAM: %ldMB)\n",
+ (unsigned long)(crash_size >> 20),
+ (unsigned long)(crash_base >> 20),
+ (unsigned long)(total_mem >> 20));
+ crashk_res.start = crash_base;
+ crashk_res.end = crash_base + crash_size - 1;
}
}
#else
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -201,28 +201,35 @@ static inline void copy_edd(void)
#ifdef CONFIG_KEXEC
static void __init reserve_crashkernel(void)
{
- unsigned long long free_mem;
+ unsigned long long total_mem;
unsigned long long crash_size, crash_base;
int ret;

- free_mem = ((unsigned long long)max_low_pfn - min_low_pfn) << PAGE_SHIFT;
+ total_mem = ((unsigned long long)max_low_pfn - min_low_pfn) << PAGE_SHIFT;

- ret = parse_crashkernel(boot_command_line, free_mem,
+ ret = parse_crashkernel(boot_command_line, total_mem,
&crash_size, &crash_base);
if (ret == 0 && crash_size) {
- if (crash_base > 0) {
- printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
- "for crashkernel (System RAM: %ldMB)\n",
- (unsigned long)(crash_size >> 20),
- (unsigned long)(crash_base >> 20),
- (unsigned long)(free_mem >> 20));
- crashk_res.start = crash_base;
- crashk_res.end = crash_base + crash_size - 1;
- reserve_bootmem(crash_base, crash_size,
- BOOTMEM_DEFAULT);
- } else
+ if (crash_base <= 0) {
printk(KERN_INFO "crashkernel reservation failed - "
"you have to specify a base address\n");
+ return;
+ }
+
+ if (reserve_bootmem(crash_base, crash_size,
+ BOOTMEM_EXCLUSIVE) < 0) {
+ printk(KERN_INFO "crashkernel reservation failed - "
+ "memory is in use\n");
+ return;
+ }
+
+ printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
+ "for crashkernel (System RAM: %ldMB)\n",
+ (unsigned long)(crash_size >> 20),
+ (unsigned long)(crash_base >> 20),
+ (unsigned long)(total_mem >> 20));
+ crashk_res.start = crash_base;
+ crashk_res.end = crash_base + crash_size - 1;
}
}
#else


2007-10-25 04:06:15

by Andrew Morton

[permalink] [raw]
Subject: Re: [patch 2/2] Use BOOTMEM_EXCLUSIVE for kdump

On Wed, 24 Oct 2007 18:37:35 +0200 Bernhard Walle <[email protected]> wrote:

> This patch uses the BOOTMEM_EXCLUSIVE, introduced in the previous patch,
> to avoid conflicts while reserving the memory for the kdump carpture kernel
> (crashkernel=).
>
>
> Signed-off-by: Bernhard Walle <[email protected]>
>
> ---
> arch/sh/kernel/setup.c | 29 ++++++++++++++++++-----------
> arch/x86/kernel/setup_32.c | 28 ++++++++++++++++++----------
> arch/x86/kernel/setup_64.c | 35 +++++++++++++++++++++--------------

ia64 and powerpc support crash dump too?

2007-10-25 04:15:27

by Paul Mundt

[permalink] [raw]
Subject: Re: [patch 2/2] Use BOOTMEM_EXCLUSIVE for kdump

On Wed, Oct 24, 2007 at 09:05:33PM -0700, Andrew Morton wrote:
> On Wed, 24 Oct 2007 18:37:35 +0200 Bernhard Walle <[email protected]> wrote:
> > This patch uses the BOOTMEM_EXCLUSIVE, introduced in the previous patch,
> > to avoid conflicts while reserving the memory for the kdump carpture kernel
> > (crashkernel=).
> >
> > Signed-off-by: Bernhard Walle <[email protected]>
> >
> > ---
> > arch/sh/kernel/setup.c | 29 ++++++++++++++++++-----------
> > arch/x86/kernel/setup_32.c | 28 ++++++++++++++++++----------
> > arch/x86/kernel/setup_64.c | 35 +++++++++++++++++++++--------------
>
> ia64 and powerpc support crash dump too?
>
Not via a reserved bootmem area at least, which is what these patches
touch.

Acked-by: Paul Mundt <[email protected]>