From: Bernhard Walle <bwalle@suse.de>
To: linux-kernel@vger.kernel.org, kexec@lists.infradead.org
Cc: akpm@linux-foundation.org, ak@suse.de, vgoyal@in.ibm.com
Subject: [patch 3/3] Use BOOTMEM_EXCLUSIVE on x86
Date: Thu, 18 Oct 2007 13:15:38 +0200 [thread overview]
Message-ID: <20071018111536.623351733@strauss.suse.de> (raw)
In-Reply-To: 20071018111535.356215664@strauss.suse.de
[-- Attachment #1: bootmem-alloc-use-crashkernel --]
[-- Type: text/plain, Size: 3492 bytes --]
This patch uses the BOOTMEM_EXCLUSIVE, introduced in the previous patch,
to avoid conflicts while reserving the memory for the kdump carpture kernel
(crashkernel=).
The modification has been tested on i386.
Signed-off-by: Bernhard Walle <bwalle@suse.de>
---
arch/x86/kernel/setup_32.c | 28 ++++++++++++++++++----------
arch/x86/kernel/setup_64.c | 35 +++++++++++++++++++++--------------
2 files changed, 39 insertions(+), 24 deletions(-)
--- a/arch/x86/kernel/setup_32.c
+++ b/arch/x86/kernel/setup_32.c
@@ -403,18 +403,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
--
next prev parent reply other threads:[~2007-10-18 11:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-18 11:15 [patch 0/3] Protect crashkernel against BSS overlap Bernhard Walle
2007-10-18 11:15 ` [patch 1/3] Add BSS to resource tree Bernhard Walle
2007-10-18 21:26 ` Andrew Morton
2007-10-18 21:48 ` Andi Kleen
2007-10-18 21:58 ` Sam Ravnborg
2007-10-18 22:00 ` Andi Kleen
2007-10-18 22:18 ` Sam Ravnborg
2007-10-18 22:20 ` Andi Kleen
2007-10-18 22:37 ` Andrew Morton
2007-10-18 22:45 ` Andi Kleen
2007-10-19 0:27 ` Jeremy Fitzhardinge
2007-10-19 12:52 ` Bernhard Walle
2007-10-19 14:48 ` Bernhard Walle
2007-10-18 11:15 ` [patch 2/3] Introduce BOOTMEM_EXCLUSIVE Bernhard Walle
2007-10-18 11:15 ` Bernhard Walle [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-10-16 16:28 [patch 0/3] Protect crashkernel against BSS overlap Bernhard Walle
2007-10-16 16:29 ` [patch 3/3] Use BOOTMEM_EXCLUSIVE on x86 Bernhard Walle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071018111536.623351733@strauss.suse.de \
--to=bwalle@suse.de \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vgoyal@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox