Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 99990
b: refs/heads/master
c: 32105f7
h: refs/heads/master
v: v3
  • Loading branch information
Bernhard Walle authored and Ingo Molnar committed Jul 8, 2008
1 parent 0492120 commit e997d66
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fd6493e16625b92a506fba13deda31c0be5f1cd4
refs/heads/master: 32105f7fd8faa7bc3d101dcc3eabc0ae1ac375a7
70 changes: 52 additions & 18 deletions trunk/arch/x86/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,34 @@ static void __init reserve_setup_data(void)
*/

#ifdef CONFIG_KEXEC

/**
* Reserve @size bytes of crashkernel memory at any suitable offset.
*
* @size: Size of the crashkernel memory to reserve.
* Returns the base address on success, and -1ULL on failure.
*/
unsigned long long find_and_reserve_crashkernel(unsigned long long size)
{
const unsigned long long alignment = 16<<20; /* 16M */
unsigned long long start = 0LL;

while (1) {
int ret;

start = find_e820_area(start, ULONG_MAX, size, alignment);
if (start == -1ULL)
return start;

/* try to reserve it */
ret = reserve_bootmem_generic(start, size, BOOTMEM_EXCLUSIVE);
if (ret >= 0)
return start;

start += alignment;
}
}

static inline unsigned long long get_total_mem(void)
{
unsigned long long total;
Expand All @@ -444,30 +472,36 @@ static void __init reserve_crashkernel(void)

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 "crashkernel reservation failed - "
"you have to specify a base address\n");
if (ret != 0 || crash_size <= 0)
return;

/* 0 means: find the address automatically */
if (crash_base <= 0) {
crash_base = find_and_reserve_crashkernel(crash_size);
if (crash_base == -1ULL) {
pr_info("crashkernel reservation failed. "
"No suitable area found.\n");
return;
}

if (reserve_bootmem_generic(crash_base, crash_size,
BOOTMEM_EXCLUSIVE) < 0) {
printk(KERN_INFO "crashkernel reservation failed - "
"memory is in use\n");
} else {
ret = reserve_bootmem_generic(crash_base, crash_size,
BOOTMEM_EXCLUSIVE);
if (ret < 0) {
pr_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));
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;
insert_resource(&iomem_resource, &crashk_res);
}
crashk_res.start = crash_base;
crashk_res.end = crash_base + crash_size - 1;
insert_resource(&iomem_resource, &crashk_res);
}
#else
static void __init reserve_crashkernel(void)
Expand Down

0 comments on commit e997d66

Please sign in to comment.