All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: crash kernel reserve with reserve_early
@ 2009-11-22 10:26 ` Yinghai Lu
  0 siblings, 0 replies; 6+ messages in thread
From: Yinghai Lu @ 2009-11-22 10:26 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin, Thomas Gleixner, Eric W. Biederman,
	Vivek Goyal
  Cc: linux-kernel, kexec

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: crashkernel_early.patch --]
[-- Type: text/x-diff, Size: 3140 bytes --]

[PATCH] x86: crash kernel reserve with reserve_early

use find_e820_area/reserve_early instead.
will get next good one automatically with alignment

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 arch/x86/kernel/setup.c |   60 ++++++++++--------------------------------------
 1 file changed, 13 insertions(+), 47 deletions(-)

Index: linux-2.6/arch/x86/kernel/setup.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/setup.c
+++ linux-2.6/arch/x86/kernel/setup.c
@@ -488,42 +488,11 @@ static void __init reserve_early_setup_d
 
 #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.
- */
-static
-unsigned long long __init 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;
 
-	total = max_low_pfn - min_low_pfn;
-#ifdef CONFIG_HIGHMEM
-	total += highend_pfn - highstart_pfn;
-#endif
+	total = max_pfn - min_low_pfn;
 
 	return total << PAGE_SHIFT;
 }
@@ -532,6 +501,8 @@ static void __init reserve_crashkernel(v
 {
 	unsigned long long total_mem;
 	unsigned long long crash_size, crash_base;
+	const unsigned long long alignment = 16<<20;	/* 16M */
+	unsigned long long start;
 	int ret;
 
 	total_mem = get_total_mem();
@@ -543,21 +514,16 @@ static void __init reserve_crashkernel(v
 
 	/* 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;
-		}
+		start = alignment;
 	} 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;
-		}
+		start = crash_base;
+	}
+	crash_base = find_e820_area(start, ULONG_MAX, crash_size, alignment);
+	if (crash_base == -1ULL) {
+		pr_info("crashkernel reservation failed - No suitable area found.\n");
+		return;
 	}
+	reserve_early(crash_base, crash_base + crash_size, "CRASH KERNEL");
 
 	printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
 			"for crashkernel (System RAM: %ldMB)\n",
@@ -935,6 +901,8 @@ void __init setup_arch(char **cmdline_p)
 
 	reserve_initrd();
 
+	reserve_crashkernel();
+
 	vsmp_init();
 
 	io_delay_init();
@@ -965,8 +933,6 @@ void __init setup_arch(char **cmdline_p)
 
 	initmem_init(0, max_pfn, acpi, k8);
 
-	reserve_crashkernel();
-
 #ifdef CONFIG_X86_64
 	/*
 	 * dma32_reserve_bootmem() allocates bootmem which may conflict

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] x86: crash kernel reserve with reserve_early
@ 2009-11-22 10:26 ` Yinghai Lu
  0 siblings, 0 replies; 6+ messages in thread
From: Yinghai Lu @ 2009-11-22 10:26 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin, Thomas Gleixner, Eric W. Biederman,
	Vivek Goyal
  Cc: kexec, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: crashkernel_early.patch --]
[-- Type: text/x-diff, Size: 3140 bytes --]

[PATCH] x86: crash kernel reserve with reserve_early

use find_e820_area/reserve_early instead.
will get next good one automatically with alignment

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 arch/x86/kernel/setup.c |   60 ++++++++++--------------------------------------
 1 file changed, 13 insertions(+), 47 deletions(-)

Index: linux-2.6/arch/x86/kernel/setup.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/setup.c
+++ linux-2.6/arch/x86/kernel/setup.c
@@ -488,42 +488,11 @@ static void __init reserve_early_setup_d
 
 #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.
- */
-static
-unsigned long long __init 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;
 
-	total = max_low_pfn - min_low_pfn;
-#ifdef CONFIG_HIGHMEM
-	total += highend_pfn - highstart_pfn;
-#endif
+	total = max_pfn - min_low_pfn;
 
 	return total << PAGE_SHIFT;
 }
@@ -532,6 +501,8 @@ static void __init reserve_crashkernel(v
 {
 	unsigned long long total_mem;
 	unsigned long long crash_size, crash_base;
+	const unsigned long long alignment = 16<<20;	/* 16M */
+	unsigned long long start;
 	int ret;
 
 	total_mem = get_total_mem();
@@ -543,21 +514,16 @@ static void __init reserve_crashkernel(v
 
 	/* 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;
-		}
+		start = alignment;
 	} 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;
-		}
+		start = crash_base;
+	}
+	crash_base = find_e820_area(start, ULONG_MAX, crash_size, alignment);
+	if (crash_base == -1ULL) {
+		pr_info("crashkernel reservation failed - No suitable area found.\n");
+		return;
 	}
+	reserve_early(crash_base, crash_base + crash_size, "CRASH KERNEL");
 
 	printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
 			"for crashkernel (System RAM: %ldMB)\n",
@@ -935,6 +901,8 @@ void __init setup_arch(char **cmdline_p)
 
 	reserve_initrd();
 
+	reserve_crashkernel();
+
 	vsmp_init();
 
 	io_delay_init();
@@ -965,8 +933,6 @@ void __init setup_arch(char **cmdline_p)
 
 	initmem_init(0, max_pfn, acpi, k8);
 
-	reserve_crashkernel();
-
 #ifdef CONFIG_X86_64
 	/*
 	 * dma32_reserve_bootmem() allocates bootmem which may conflict

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: crash kernel reserve with reserve_early
  2009-11-22 10:26 ` Yinghai Lu
@ 2009-11-22 12:56   ` Eric W. Biederman
  -1 siblings, 0 replies; 6+ messages in thread
From: Eric W. Biederman @ 2009-11-22 12:56 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Ingo Molnar, H. Peter Anvin, Thomas Gleixner, Vivek Goyal,
	linux-kernel, kexec

Yinghai Lu <yhlu.kernel@gmail.com> writes:

> [PATCH] x86: crash kernel reserve with reserve_early
>
> use find_e820_area/reserve_early instead.
> will get next good one automatically with alignment

Semantically this is broken, as you are now ignoring a passed in
base address if one is supplied.  What problem are you trying to fix?

Eric

>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> ---
>  arch/x86/kernel/setup.c |   60 ++++++++++--------------------------------------
>  1 file changed, 13 insertions(+), 47 deletions(-)
>
> Index: linux-2.6/arch/x86/kernel/setup.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/kernel/setup.c
> +++ linux-2.6/arch/x86/kernel/setup.c
> @@ -488,42 +488,11 @@ static void __init reserve_early_setup_d
>  
>  #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.
> - */
> -static
> -unsigned long long __init 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;
>  
> -	total = max_low_pfn - min_low_pfn;
> -#ifdef CONFIG_HIGHMEM
> -	total += highend_pfn - highstart_pfn;
> -#endif
> +	total = max_pfn - min_low_pfn;
>  
>  	return total << PAGE_SHIFT;
>  }
> @@ -532,6 +501,8 @@ static void __init reserve_crashkernel(v
>  {
>  	unsigned long long total_mem;
>  	unsigned long long crash_size, crash_base;
> +	const unsigned long long alignment = 16<<20;	/* 16M */
> +	unsigned long long start;
>  	int ret;
>  
>  	total_mem = get_total_mem();
> @@ -543,21 +514,16 @@ static void __init reserve_crashkernel(v
>  
>  	/* 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;
> -		}
> +		start = alignment;
>  	} 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;
> -		}
> +		start = crash_base;
> +	}
> +	crash_base = find_e820_area(start, ULONG_MAX, crash_size, alignment);
> +	if (crash_base == -1ULL) {
> +		pr_info("crashkernel reservation failed - No suitable area found.\n");
> +		return;
>  	}
> +	reserve_early(crash_base, crash_base + crash_size, "CRASH KERNEL");
>  
>  	printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
>  			"for crashkernel (System RAM: %ldMB)\n",
> @@ -935,6 +901,8 @@ void __init setup_arch(char **cmdline_p)
>  
>  	reserve_initrd();
>  
> +	reserve_crashkernel();
> +
>  	vsmp_init();
>  
>  	io_delay_init();
> @@ -965,8 +933,6 @@ void __init setup_arch(char **cmdline_p)
>  
>  	initmem_init(0, max_pfn, acpi, k8);
>  
> -	reserve_crashkernel();
> -
>  #ifdef CONFIG_X86_64
>  	/*
>  	 * dma32_reserve_bootmem() allocates bootmem which may conflict

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: crash kernel reserve with reserve_early
@ 2009-11-22 12:56   ` Eric W. Biederman
  0 siblings, 0 replies; 6+ messages in thread
From: Eric W. Biederman @ 2009-11-22 12:56 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: kexec, linux-kernel, H. Peter Anvin, Ingo Molnar,
	Thomas Gleixner, Vivek Goyal

Yinghai Lu <yhlu.kernel@gmail.com> writes:

> [PATCH] x86: crash kernel reserve with reserve_early
>
> use find_e820_area/reserve_early instead.
> will get next good one automatically with alignment

Semantically this is broken, as you are now ignoring a passed in
base address if one is supplied.  What problem are you trying to fix?

Eric

>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> ---
>  arch/x86/kernel/setup.c |   60 ++++++++++--------------------------------------
>  1 file changed, 13 insertions(+), 47 deletions(-)
>
> Index: linux-2.6/arch/x86/kernel/setup.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/kernel/setup.c
> +++ linux-2.6/arch/x86/kernel/setup.c
> @@ -488,42 +488,11 @@ static void __init reserve_early_setup_d
>  
>  #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.
> - */
> -static
> -unsigned long long __init 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;
>  
> -	total = max_low_pfn - min_low_pfn;
> -#ifdef CONFIG_HIGHMEM
> -	total += highend_pfn - highstart_pfn;
> -#endif
> +	total = max_pfn - min_low_pfn;
>  
>  	return total << PAGE_SHIFT;
>  }
> @@ -532,6 +501,8 @@ static void __init reserve_crashkernel(v
>  {
>  	unsigned long long total_mem;
>  	unsigned long long crash_size, crash_base;
> +	const unsigned long long alignment = 16<<20;	/* 16M */
> +	unsigned long long start;
>  	int ret;
>  
>  	total_mem = get_total_mem();
> @@ -543,21 +514,16 @@ static void __init reserve_crashkernel(v
>  
>  	/* 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;
> -		}
> +		start = alignment;
>  	} 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;
> -		}
> +		start = crash_base;
> +	}
> +	crash_base = find_e820_area(start, ULONG_MAX, crash_size, alignment);
> +	if (crash_base == -1ULL) {
> +		pr_info("crashkernel reservation failed - No suitable area found.\n");
> +		return;
>  	}
> +	reserve_early(crash_base, crash_base + crash_size, "CRASH KERNEL");
>  
>  	printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
>  			"for crashkernel (System RAM: %ldMB)\n",
> @@ -935,6 +901,8 @@ void __init setup_arch(char **cmdline_p)
>  
>  	reserve_initrd();
>  
> +	reserve_crashkernel();
> +
>  	vsmp_init();
>  
>  	io_delay_init();
> @@ -965,8 +933,6 @@ void __init setup_arch(char **cmdline_p)
>  
>  	initmem_init(0, max_pfn, acpi, k8);
>  
> -	reserve_crashkernel();
> -
>  #ifdef CONFIG_X86_64
>  	/*
>  	 * dma32_reserve_bootmem() allocates bootmem which may conflict

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: crash kernel reserve with reserve_early
  2009-11-22 12:56   ` Eric W. Biederman
@ 2009-11-23  1:18     ` Yinghai Lu
  -1 siblings, 0 replies; 6+ messages in thread
From: Yinghai Lu @ 2009-11-23  1:18 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Ingo Molnar, H. Peter Anvin, Thomas Gleixner, Vivek Goyal,
	linux-kernel, kexec

On Sun, Nov 22, 2009 at 4:56 AM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
> Yinghai Lu <yhlu.kernel@gmail.com> writes:
>
>> [PATCH] x86: crash kernel reserve with reserve_early
>>
>> use find_e820_area/reserve_early instead.
>> will get next good one automatically with alignment
>
> Semantically this is broken, as you are now ignoring a passed in
> base address if one is supplied.  What problem are you trying to fix?

avoid to use bootmem.

also simpify the code.

YH

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: crash kernel reserve with reserve_early
@ 2009-11-23  1:18     ` Yinghai Lu
  0 siblings, 0 replies; 6+ messages in thread
From: Yinghai Lu @ 2009-11-23  1:18 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: kexec, linux-kernel, H. Peter Anvin, Ingo Molnar,
	Thomas Gleixner, Vivek Goyal

On Sun, Nov 22, 2009 at 4:56 AM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
> Yinghai Lu <yhlu.kernel@gmail.com> writes:
>
>> [PATCH] x86: crash kernel reserve with reserve_early
>>
>> use find_e820_area/reserve_early instead.
>> will get next good one automatically with alignment
>
> Semantically this is broken, as you are now ignoring a passed in
> base address if one is supplied.  What problem are you trying to fix?

avoid to use bootmem.

also simpify the code.

YH

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-11-23  1:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-22 10:26 [PATCH] x86: crash kernel reserve with reserve_early Yinghai Lu
2009-11-22 10:26 ` Yinghai Lu
2009-11-22 12:56 ` Eric W. Biederman
2009-11-22 12:56   ` Eric W. Biederman
2009-11-23  1:18   ` Yinghai Lu
2009-11-23  1:18     ` Yinghai Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.