All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] x86: make sure wakeup code is below 1M
@ 2009-11-09  8:51 Yinghai Lu
  2009-11-09 12:15 ` Rafael J. Wysocki
  2009-11-09 12:15 ` [RFC PATCH] x86: make sure wakeup code is below 1M Rafael J. Wysocki
  0 siblings, 2 replies; 44+ messages in thread
From: Yinghai Lu @ 2009-11-09  8:51 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Rafael J. Wysocki,
	Len Brown
  Cc: linux-kernel


try to find_e820_area/reserve_early, and call acpi_reserve_memory early

to get area is below 1M

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 arch/x86/include/asm/acpi.h  |    2 +-
 arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
 arch/x86/kernel/setup.c      |   13 +++++++------
 3 files changed, 17 insertions(+), 13 deletions(-)

Index: linux-2.6/arch/x86/include/asm/acpi.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/acpi.h
+++ linux-2.6/arch/x86/include/asm/acpi.h
@@ -118,7 +118,7 @@ extern void acpi_restore_state_mem(void)
 extern unsigned long acpi_wakeup_address;
 
 /* early initialization routine */
-extern void acpi_reserve_bootmem(void);
+extern void acpi_reserve_memory(void);
 
 /*
  * Check if the CPU can handle C2 and deeper
Index: linux-2.6/arch/x86/kernel/acpi/sleep.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/acpi/sleep.c
+++ linux-2.6/arch/x86/kernel/acpi/sleep.c
@@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
 
 
 /**
- * acpi_reserve_bootmem - do _very_ early ACPI initialisation
+ * acpi_reserve_memory - do _very_ early ACPI initialisation
  *
  * We allocate a page from the first 1MB of memory for the wakeup
  * routine for when we come back from a sleep state. The
  * runtime allocator allows specification of <16MB pages, but not
  * <1MB pages.
  */
-void __init acpi_reserve_bootmem(void)
+void __init acpi_reserve_memory(void)
 {
+	unsigned long mem;
+
 	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
 		printk(KERN_ERR
 		       "ACPI: Wakeup code way too big, S3 disabled.\n");
 		return;
 	}
 
-	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
+	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
 
-	if (!acpi_realmode) {
+	if (mem == -1L) {
 		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
 		return;
 	}
-
-	acpi_wakeup_address = virt_to_phys((void *)acpi_realmode);
+	acpi_realmode = (unsigned long) phys_to_virt(mem);
+	acpi_wakeup_address = mem;
+	reserve_early(mem, mem + WAKEUP_SIZE, "WAKEUP");
 }
 
 
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
@@ -897,6 +897,13 @@ void __init setup_arch(char **cmdline_p)
 
 	reserve_brk();
 
+#ifdef CONFIG_ACPI_SLEEP
+	/*
+	 * Reserve low memory region for sleep support.
+	 * even before init_memory_mapping
+	 */
+	acpi_reserve_bootmem();
+#endif
 	init_gbpages();
 
 	/* max_pfn_mapped is updated here */
@@ -948,12 +955,6 @@ void __init setup_arch(char **cmdline_p)
 
 	initmem_init(0, max_pfn, acpi, k8);
 
-#ifdef CONFIG_ACPI_SLEEP
-	/*
-	 * Reserve low memory region for sleep support.
-	 */
-	acpi_reserve_bootmem();
-#endif
 	/*
 	 * Find and reserve possible boot-time SMP configuration:
 	 */

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

* Re: [RFC PATCH] x86: make sure wakeup code is below 1M
  2009-11-09  8:51 [RFC PATCH] x86: make sure wakeup code is below 1M Yinghai Lu
@ 2009-11-09 12:15 ` Rafael J. Wysocki
  2009-11-11  2:27   ` [PATCH] x86: make sure wakeup code is below 1M -v2 Yinghai Lu
  2009-11-11  2:27   ` Yinghai Lu
  2009-11-09 12:15 ` [RFC PATCH] x86: make sure wakeup code is below 1M Rafael J. Wysocki
  1 sibling, 2 replies; 44+ messages in thread
From: Rafael J. Wysocki @ 2009-11-09 12:15 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Len Brown,
	linux-kernel, ACPI Devel Maling List, pm list

On Monday 09 November 2009, Yinghai Lu wrote:
> 
> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> 
> to get area is below 1M
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>

I generally like it, two comments below.

> ---
>  arch/x86/include/asm/acpi.h  |    2 +-
>  arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
>  arch/x86/kernel/setup.c      |   13 +++++++------
>  3 files changed, 17 insertions(+), 13 deletions(-)
> 
> Index: linux-2.6/arch/x86/include/asm/acpi.h
> ===================================================================
> --- linux-2.6.orig/arch/x86/include/asm/acpi.h
> +++ linux-2.6/arch/x86/include/asm/acpi.h
> @@ -118,7 +118,7 @@ extern void acpi_restore_state_mem(void)
>  extern unsigned long acpi_wakeup_address;
>  
>  /* early initialization routine */
> -extern void acpi_reserve_bootmem(void);
> +extern void acpi_reserve_memory(void);

If you change the name of the function, IMO it would be better to call it
something like acpi_reserve_wakeup_memory().  This way it would be clear what
the memory is reserved for.
  
>  /*
>   * Check if the CPU can handle C2 and deeper
> Index: linux-2.6/arch/x86/kernel/acpi/sleep.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/kernel/acpi/sleep.c
> +++ linux-2.6/arch/x86/kernel/acpi/sleep.c
> @@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
>  
>  
>  /**
> - * acpi_reserve_bootmem - do _very_ early ACPI initialisation
> + * acpi_reserve_memory - do _very_ early ACPI initialisation
>   *
>   * We allocate a page from the first 1MB of memory for the wakeup
>   * routine for when we come back from a sleep state. The
>   * runtime allocator allows specification of <16MB pages, but not
>   * <1MB pages.
>   */
> -void __init acpi_reserve_bootmem(void)
> +void __init acpi_reserve_memory(void)
>  {
> +	unsigned long mem;
> +
>  	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
>  		printk(KERN_ERR
>  		       "ACPI: Wakeup code way too big, S3 disabled.\n");
>  		return;
>  	}
>  
> -	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
> +	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
>  
> -	if (!acpi_realmode) {
> +	if (mem == -1L) {

Could we change the condition to avoid the "-1L" here?  It doesn't look very
nice.

>  		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
>  		return;
>  	}
> -
> -	acpi_wakeup_address = virt_to_phys((void *)acpi_realmode);
> +	acpi_realmode = (unsigned long) phys_to_virt(mem);
> +	acpi_wakeup_address = mem;
> +	reserve_early(mem, mem + WAKEUP_SIZE, "WAKEUP");
>  }

Thanks,
Rafael

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

* Re: [RFC PATCH] x86: make sure wakeup code is below 1M
  2009-11-09  8:51 [RFC PATCH] x86: make sure wakeup code is below 1M Yinghai Lu
  2009-11-09 12:15 ` Rafael J. Wysocki
@ 2009-11-09 12:15 ` Rafael J. Wysocki
  1 sibling, 0 replies; 44+ messages in thread
From: Rafael J. Wysocki @ 2009-11-09 12:15 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, pm list, Thomas Gleixner

On Monday 09 November 2009, Yinghai Lu wrote:
> 
> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> 
> to get area is below 1M
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>

I generally like it, two comments below.

> ---
>  arch/x86/include/asm/acpi.h  |    2 +-
>  arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
>  arch/x86/kernel/setup.c      |   13 +++++++------
>  3 files changed, 17 insertions(+), 13 deletions(-)
> 
> Index: linux-2.6/arch/x86/include/asm/acpi.h
> ===================================================================
> --- linux-2.6.orig/arch/x86/include/asm/acpi.h
> +++ linux-2.6/arch/x86/include/asm/acpi.h
> @@ -118,7 +118,7 @@ extern void acpi_restore_state_mem(void)
>  extern unsigned long acpi_wakeup_address;
>  
>  /* early initialization routine */
> -extern void acpi_reserve_bootmem(void);
> +extern void acpi_reserve_memory(void);

If you change the name of the function, IMO it would be better to call it
something like acpi_reserve_wakeup_memory().  This way it would be clear what
the memory is reserved for.
  
>  /*
>   * Check if the CPU can handle C2 and deeper
> Index: linux-2.6/arch/x86/kernel/acpi/sleep.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/kernel/acpi/sleep.c
> +++ linux-2.6/arch/x86/kernel/acpi/sleep.c
> @@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
>  
>  
>  /**
> - * acpi_reserve_bootmem - do _very_ early ACPI initialisation
> + * acpi_reserve_memory - do _very_ early ACPI initialisation
>   *
>   * We allocate a page from the first 1MB of memory for the wakeup
>   * routine for when we come back from a sleep state. The
>   * runtime allocator allows specification of <16MB pages, but not
>   * <1MB pages.
>   */
> -void __init acpi_reserve_bootmem(void)
> +void __init acpi_reserve_memory(void)
>  {
> +	unsigned long mem;
> +
>  	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
>  		printk(KERN_ERR
>  		       "ACPI: Wakeup code way too big, S3 disabled.\n");
>  		return;
>  	}
>  
> -	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
> +	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
>  
> -	if (!acpi_realmode) {
> +	if (mem == -1L) {

Could we change the condition to avoid the "-1L" here?  It doesn't look very
nice.

>  		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
>  		return;
>  	}
> -
> -	acpi_wakeup_address = virt_to_phys((void *)acpi_realmode);
> +	acpi_realmode = (unsigned long) phys_to_virt(mem);
> +	acpi_wakeup_address = mem;
> +	reserve_early(mem, mem + WAKEUP_SIZE, "WAKEUP");
>  }

Thanks,
Rafael

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

* [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-09 12:15 ` Rafael J. Wysocki
@ 2009-11-11  2:27   ` Yinghai Lu
  2009-11-11  7:48       ` Ingo Molnar
                       ` (6 more replies)
  2009-11-11  2:27   ` Yinghai Lu
  1 sibling, 7 replies; 44+ messages in thread
From: Yinghai Lu @ 2009-11-11  2:27 UTC (permalink / raw)
  To: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin
  Cc: Len Brown, linux-kernel, ACPI Devel Maling List, pm list


try to find_e820_area/reserve_early, and call acpi_reserve_memory early

to get area is below 1M

-v2: change function name to acpi_reserve_wakeup_memory according to Rafael

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 arch/x86/include/asm/acpi.h  |    2 +-
 arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
 arch/x86/kernel/setup.c      |   13 +++++++------
 3 files changed, 17 insertions(+), 13 deletions(-)

Index: linux-2.6/arch/x86/include/asm/acpi.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/acpi.h
+++ linux-2.6/arch/x86/include/asm/acpi.h
@@ -118,7 +118,7 @@ extern void acpi_restore_state_mem(void)
 extern unsigned long acpi_wakeup_address;
 
 /* early initialization routine */
-extern void acpi_reserve_bootmem(void);
+extern void acpi_reserve_wakeup_memory(void);
 
 /*
  * Check if the CPU can handle C2 and deeper
Index: linux-2.6/arch/x86/kernel/acpi/sleep.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/acpi/sleep.c
+++ linux-2.6/arch/x86/kernel/acpi/sleep.c
@@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
 
 
 /**
- * acpi_reserve_bootmem - do _very_ early ACPI initialisation
+ * acpi_reserve_wakeup_memory - do _very_ early ACPI initialisation
  *
  * We allocate a page from the first 1MB of memory for the wakeup
  * routine for when we come back from a sleep state. The
  * runtime allocator allows specification of <16MB pages, but not
  * <1MB pages.
  */
-void __init acpi_reserve_bootmem(void)
+void __init acpi_reserve_wakeup_memory(void)
 {
+	unsigned long mem;
+
 	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
 		printk(KERN_ERR
 		       "ACPI: Wakeup code way too big, S3 disabled.\n");
 		return;
 	}
 
-	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
+	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
 
-	if (!acpi_realmode) {
+	if (mem == -1L) {
 		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
 		return;
 	}
-
-	acpi_wakeup_address = virt_to_phys((void *)acpi_realmode);
+	acpi_realmode = (unsigned long) phys_to_virt(mem);
+	acpi_wakeup_address = mem;
+	reserve_early(mem, mem + WAKEUP_SIZE, "ACPI WAKEUP");
 }
 
 
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
@@ -905,6 +905,13 @@ void __init setup_arch(char **cmdline_p)
 
 	reserve_brk();
 
+#ifdef CONFIG_ACPI_SLEEP
+	/*
+	 * Reserve low memory region for sleep support.
+	 * even before init_memory_mapping
+	 */
+	acpi_reserve_wakeup_memory();
+#endif
 	init_gbpages();
 
 	/* max_pfn_mapped is updated here */
@@ -956,12 +963,6 @@ void __init setup_arch(char **cmdline_p)
 
 	initmem_init(0, max_pfn, acpi, k8);
 
-#ifdef CONFIG_ACPI_SLEEP
-	/*
-	 * Reserve low memory region for sleep support.
-	 */
-	acpi_reserve_bootmem();
-#endif
 	/*
 	 * Find and reserve possible boot-time SMP configuration:
 	 */

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

* [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-09 12:15 ` Rafael J. Wysocki
  2009-11-11  2:27   ` [PATCH] x86: make sure wakeup code is below 1M -v2 Yinghai Lu
@ 2009-11-11  2:27   ` Yinghai Lu
  1 sibling, 0 replies; 44+ messages in thread
From: Yinghai Lu @ 2009-11-11  2:27 UTC (permalink / raw)
  To: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin
  Cc: ACPI Devel Maling List, pm list, linux-kernel


try to find_e820_area/reserve_early, and call acpi_reserve_memory early

to get area is below 1M

-v2: change function name to acpi_reserve_wakeup_memory according to Rafael

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 arch/x86/include/asm/acpi.h  |    2 +-
 arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
 arch/x86/kernel/setup.c      |   13 +++++++------
 3 files changed, 17 insertions(+), 13 deletions(-)

Index: linux-2.6/arch/x86/include/asm/acpi.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/acpi.h
+++ linux-2.6/arch/x86/include/asm/acpi.h
@@ -118,7 +118,7 @@ extern void acpi_restore_state_mem(void)
 extern unsigned long acpi_wakeup_address;
 
 /* early initialization routine */
-extern void acpi_reserve_bootmem(void);
+extern void acpi_reserve_wakeup_memory(void);
 
 /*
  * Check if the CPU can handle C2 and deeper
Index: linux-2.6/arch/x86/kernel/acpi/sleep.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/acpi/sleep.c
+++ linux-2.6/arch/x86/kernel/acpi/sleep.c
@@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
 
 
 /**
- * acpi_reserve_bootmem - do _very_ early ACPI initialisation
+ * acpi_reserve_wakeup_memory - do _very_ early ACPI initialisation
  *
  * We allocate a page from the first 1MB of memory for the wakeup
  * routine for when we come back from a sleep state. The
  * runtime allocator allows specification of <16MB pages, but not
  * <1MB pages.
  */
-void __init acpi_reserve_bootmem(void)
+void __init acpi_reserve_wakeup_memory(void)
 {
+	unsigned long mem;
+
 	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
 		printk(KERN_ERR
 		       "ACPI: Wakeup code way too big, S3 disabled.\n");
 		return;
 	}
 
-	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
+	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
 
-	if (!acpi_realmode) {
+	if (mem == -1L) {
 		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
 		return;
 	}
-
-	acpi_wakeup_address = virt_to_phys((void *)acpi_realmode);
+	acpi_realmode = (unsigned long) phys_to_virt(mem);
+	acpi_wakeup_address = mem;
+	reserve_early(mem, mem + WAKEUP_SIZE, "ACPI WAKEUP");
 }
 
 
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
@@ -905,6 +905,13 @@ void __init setup_arch(char **cmdline_p)
 
 	reserve_brk();
 
+#ifdef CONFIG_ACPI_SLEEP
+	/*
+	 * Reserve low memory region for sleep support.
+	 * even before init_memory_mapping
+	 */
+	acpi_reserve_wakeup_memory();
+#endif
 	init_gbpages();
 
 	/* max_pfn_mapped is updated here */
@@ -956,12 +963,6 @@ void __init setup_arch(char **cmdline_p)
 
 	initmem_init(0, max_pfn, acpi, k8);
 
-#ifdef CONFIG_ACPI_SLEEP
-	/*
-	 * Reserve low memory region for sleep support.
-	 */
-	acpi_reserve_bootmem();
-#endif
 	/*
 	 * Find and reserve possible boot-time SMP configuration:
 	 */

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11  2:27   ` [PATCH] x86: make sure wakeup code is below 1M -v2 Yinghai Lu
@ 2009-11-11  7:48       ` Ingo Molnar
  2009-11-11  7:48     ` Ingo Molnar
                         ` (5 subsequent siblings)
  6 siblings, 0 replies; 44+ messages in thread
From: Ingo Molnar @ 2009-11-11  7:48 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Thomas Gleixner, H. Peter Anvin, Len Brown,
	linux-kernel, ACPI Devel Maling List, pm list


* Yinghai Lu <yinghai@kernel.org> wrote:

> 
> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> 
> to get area is below 1M
> 
> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> 
> ---
>  arch/x86/include/asm/acpi.h  |    2 +-
>  arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
>  arch/x86/kernel/setup.c      |   13 +++++++------
>  3 files changed, 17 insertions(+), 13 deletions(-)

Looks good. Rafael, Peter, does it look good to you too?

	Ingo

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
@ 2009-11-11  7:48       ` Ingo Molnar
  0 siblings, 0 replies; 44+ messages in thread
From: Ingo Molnar @ 2009-11-11  7:48 UTC (permalink / raw)
  To: Yinghai Lu, H. Peter Anvin
  Cc: Rafael J. Wysocki, Thomas Gleixner, H. Peter Anvin, Len Brown,
	linux-kernel, ACPI Devel Maling List, pm list


* Yinghai Lu <yinghai@kernel.org> wrote:

> 
> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> 
> to get area is below 1M
> 
> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> 
> ---
>  arch/x86/include/asm/acpi.h  |    2 +-
>  arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
>  arch/x86/kernel/setup.c      |   13 +++++++------
>  3 files changed, 17 insertions(+), 13 deletions(-)

Looks good. Rafael, Peter, does it look good to you too?

	Ingo

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11  2:27   ` [PATCH] x86: make sure wakeup code is below 1M -v2 Yinghai Lu
  2009-11-11  7:48       ` Ingo Molnar
@ 2009-11-11  7:48     ` Ingo Molnar
  2009-11-11  9:12     ` ykzhao
                       ` (4 subsequent siblings)
  6 siblings, 0 replies; 44+ messages in thread
From: Ingo Molnar @ 2009-11-11  7:48 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Thomas Gleixner, pm list


* Yinghai Lu <yinghai@kernel.org> wrote:

> 
> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> 
> to get area is below 1M
> 
> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> 
> ---
>  arch/x86/include/asm/acpi.h  |    2 +-
>  arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
>  arch/x86/kernel/setup.c      |   13 +++++++------
>  3 files changed, 17 insertions(+), 13 deletions(-)

Looks good. Rafael, Peter, does it look good to you too?

	Ingo

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11  7:48       ` Ingo Molnar
  (?)
  (?)
@ 2009-11-11  7:57       ` H. Peter Anvin
  -1 siblings, 0 replies; 44+ messages in thread
From: H. Peter Anvin @ 2009-11-11  7:57 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Yinghai Lu, Rafael J. Wysocki, Thomas Gleixner, Len Brown,
	linux-kernel, ACPI Devel Maling List, pm list

On 11/10/2009 11:48 PM, Ingo Molnar wrote:
> 
> * Yinghai Lu <yinghai@kernel.org> wrote:
> 
>>
>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
>>
>> to get area is below 1M
>>
>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
>>
>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>>
>> ---
>>  arch/x86/include/asm/acpi.h  |    2 +-
>>  arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
>>  arch/x86/kernel/setup.c      |   13 +++++++------
>>  3 files changed, 17 insertions(+), 13 deletions(-)
> 
> Looks good. Rafael, Peter, does it look good to you too?
> 

Looks sane to me.

Acked-by: H. Peter Anvin <hpa@zytor.com>

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11  7:48       ` Ingo Molnar
  (?)
@ 2009-11-11  7:57       ` H. Peter Anvin
  -1 siblings, 0 replies; 44+ messages in thread
From: H. Peter Anvin @ 2009-11-11  7:57 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, ACPI Devel Maling List, Thomas Gleixner,
	Yinghai Lu, pm list

On 11/10/2009 11:48 PM, Ingo Molnar wrote:
> 
> * Yinghai Lu <yinghai@kernel.org> wrote:
> 
>>
>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
>>
>> to get area is below 1M
>>
>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
>>
>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>>
>> ---
>>  arch/x86/include/asm/acpi.h  |    2 +-
>>  arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
>>  arch/x86/kernel/setup.c      |   13 +++++++------
>>  3 files changed, 17 insertions(+), 13 deletions(-)
> 
> Looks good. Rafael, Peter, does it look good to you too?
> 

Looks sane to me.

Acked-by: H. Peter Anvin <hpa@zytor.com>

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11  2:27   ` [PATCH] x86: make sure wakeup code is below 1M -v2 Yinghai Lu
  2009-11-11  7:48       ` Ingo Molnar
  2009-11-11  7:48     ` Ingo Molnar
@ 2009-11-11  9:12     ` ykzhao
  2009-11-11 19:05       ` Yinghai Lu
  2009-11-11 19:05       ` Yinghai Lu
  2009-11-11  9:12     ` ykzhao
                       ` (3 subsequent siblings)
  6 siblings, 2 replies; 44+ messages in thread
From: ykzhao @ 2009-11-11  9:12 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> 
> to get area is below 1M
> 
> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
It seems that the function of find_e820_area is called in several
places.
   >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
bootmap_size, PAGE_SIZE);
   
If we also call it in the acpi_reserve_wakeup_memory, do we get the same
base address as that obtained in initmem_init?

Thanks.

> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> 
> ---
>  arch/x86/include/asm/acpi.h  |    2 +-
>  arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
>  arch/x86/kernel/setup.c      |   13 +++++++------
>  3 files changed, 17 insertions(+), 13 deletions(-)
> 
> Index: linux-2.6/arch/x86/include/asm/acpi.h
> ===================================================================
> --- linux-2.6.orig/arch/x86/include/asm/acpi.h
> +++ linux-2.6/arch/x86/include/asm/acpi.h
> @@ -118,7 +118,7 @@ extern void acpi_restore_state_mem(void)
>  extern unsigned long acpi_wakeup_address;
>  
>  /* early initialization routine */
> -extern void acpi_reserve_bootmem(void);
> +extern void acpi_reserve_wakeup_memory(void);
>  
>  /*
>   * Check if the CPU can handle C2 and deeper
> Index: linux-2.6/arch/x86/kernel/acpi/sleep.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/kernel/acpi/sleep.c
> +++ linux-2.6/arch/x86/kernel/acpi/sleep.c
> @@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
>  
> 
>  /**
> - * acpi_reserve_bootmem - do _very_ early ACPI initialisation
> + * acpi_reserve_wakeup_memory - do _very_ early ACPI initialisation
>   *
>   * We allocate a page from the first 1MB of memory for the wakeup
>   * routine for when we come back from a sleep state. The
>   * runtime allocator allows specification of <16MB pages, but not
>   * <1MB pages.
>   */
> -void __init acpi_reserve_bootmem(void)
> +void __init acpi_reserve_wakeup_memory(void)
>  {
> +	unsigned long mem;
> +
>  	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
>  		printk(KERN_ERR
>  		       "ACPI: Wakeup code way too big, S3 disabled.\n");
>  		return;
>  	}
>  
> -	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
> +	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
>  
> -	if (!acpi_realmode) {
> +	if (mem == -1L) {
>  		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
>  		return;
>  	}
> -
> -	acpi_wakeup_address = virt_to_phys((void *)acpi_realmode);
> +	acpi_realmode = (unsigned long) phys_to_virt(mem);
> +	acpi_wakeup_address = mem;
> +	reserve_early(mem, mem + WAKEUP_SIZE, "ACPI WAKEUP");
>  }
>  
> 
> 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
> @@ -905,6 +905,13 @@ void __init setup_arch(char **cmdline_p)
>  
>  	reserve_brk();
>  
> +#ifdef CONFIG_ACPI_SLEEP
> +	/*
> +	 * Reserve low memory region for sleep support.
> +	 * even before init_memory_mapping
> +	 */
> +	acpi_reserve_wakeup_memory();
> +#endif
>  	init_gbpages();
>  
>  	/* max_pfn_mapped is updated here */
> @@ -956,12 +963,6 @@ void __init setup_arch(char **cmdline_p)
>  
>  	initmem_init(0, max_pfn, acpi, k8);
>  
> -#ifdef CONFIG_ACPI_SLEEP
> -	/*
> -	 * Reserve low memory region for sleep support.
> -	 */
> -	acpi_reserve_bootmem();
> -#endif
>  	/*
>  	 * Find and reserve possible boot-time SMP configuration:
>  	 */
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11  2:27   ` [PATCH] x86: make sure wakeup code is below 1M -v2 Yinghai Lu
                       ` (2 preceding siblings ...)
  2009-11-11  9:12     ` ykzhao
@ 2009-11-11  9:12     ` ykzhao
  2009-11-11 20:30     ` [tip:x86/mm] x86: Make sure wakeup trampoline code is below 1MB tip-bot for Yinghai Lu
                       ` (2 subsequent siblings)
  6 siblings, 0 replies; 44+ messages in thread
From: ykzhao @ 2009-11-11  9:12 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, pm list, Thomas Gleixner

On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> 
> to get area is below 1M
> 
> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
It seems that the function of find_e820_area is called in several
places.
   >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
bootmap_size, PAGE_SIZE);
   
If we also call it in the acpi_reserve_wakeup_memory, do we get the same
base address as that obtained in initmem_init?

Thanks.

> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> 
> ---
>  arch/x86/include/asm/acpi.h  |    2 +-
>  arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
>  arch/x86/kernel/setup.c      |   13 +++++++------
>  3 files changed, 17 insertions(+), 13 deletions(-)
> 
> Index: linux-2.6/arch/x86/include/asm/acpi.h
> ===================================================================
> --- linux-2.6.orig/arch/x86/include/asm/acpi.h
> +++ linux-2.6/arch/x86/include/asm/acpi.h
> @@ -118,7 +118,7 @@ extern void acpi_restore_state_mem(void)
>  extern unsigned long acpi_wakeup_address;
>  
>  /* early initialization routine */
> -extern void acpi_reserve_bootmem(void);
> +extern void acpi_reserve_wakeup_memory(void);
>  
>  /*
>   * Check if the CPU can handle C2 and deeper
> Index: linux-2.6/arch/x86/kernel/acpi/sleep.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/kernel/acpi/sleep.c
> +++ linux-2.6/arch/x86/kernel/acpi/sleep.c
> @@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
>  
> 
>  /**
> - * acpi_reserve_bootmem - do _very_ early ACPI initialisation
> + * acpi_reserve_wakeup_memory - do _very_ early ACPI initialisation
>   *
>   * We allocate a page from the first 1MB of memory for the wakeup
>   * routine for when we come back from a sleep state. The
>   * runtime allocator allows specification of <16MB pages, but not
>   * <1MB pages.
>   */
> -void __init acpi_reserve_bootmem(void)
> +void __init acpi_reserve_wakeup_memory(void)
>  {
> +	unsigned long mem;
> +
>  	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
>  		printk(KERN_ERR
>  		       "ACPI: Wakeup code way too big, S3 disabled.\n");
>  		return;
>  	}
>  
> -	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
> +	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
>  
> -	if (!acpi_realmode) {
> +	if (mem == -1L) {
>  		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
>  		return;
>  	}
> -
> -	acpi_wakeup_address = virt_to_phys((void *)acpi_realmode);
> +	acpi_realmode = (unsigned long) phys_to_virt(mem);
> +	acpi_wakeup_address = mem;
> +	reserve_early(mem, mem + WAKEUP_SIZE, "ACPI WAKEUP");
>  }
>  
> 
> 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
> @@ -905,6 +905,13 @@ void __init setup_arch(char **cmdline_p)
>  
>  	reserve_brk();
>  
> +#ifdef CONFIG_ACPI_SLEEP
> +	/*
> +	 * Reserve low memory region for sleep support.
> +	 * even before init_memory_mapping
> +	 */
> +	acpi_reserve_wakeup_memory();
> +#endif
>  	init_gbpages();
>  
>  	/* max_pfn_mapped is updated here */
> @@ -956,12 +963,6 @@ void __init setup_arch(char **cmdline_p)
>  
>  	initmem_init(0, max_pfn, acpi, k8);
>  
> -#ifdef CONFIG_ACPI_SLEEP
> -	/*
> -	 * Reserve low memory region for sleep support.
> -	 */
> -	acpi_reserve_bootmem();
> -#endif
>  	/*
>  	 * Find and reserve possible boot-time SMP configuration:
>  	 */
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11  7:48       ` Ingo Molnar
                         ` (3 preceding siblings ...)
  (?)
@ 2009-11-11  9:56       ` Rafael J. Wysocki
  -1 siblings, 0 replies; 44+ messages in thread
From: Rafael J. Wysocki @ 2009-11-11  9:56 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Yinghai Lu, H. Peter Anvin, Thomas Gleixner, Len Brown,
	linux-kernel, ACPI Devel Maling List, pm list

On Wednesday 11 November 2009, Ingo Molnar wrote:
> 
> * Yinghai Lu <yinghai@kernel.org> wrote:
> 
> > 
> > try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> > 
> > to get area is below 1M
> > 
> > -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> > 
> > Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> > 
> > ---
> >  arch/x86/include/asm/acpi.h  |    2 +-
> >  arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
> >  arch/x86/kernel/setup.c      |   13 +++++++------
> >  3 files changed, 17 insertions(+), 13 deletions(-)
> 
> Looks good. Rafael, Peter, does it look good to you too?

Yes, it does.

Acked-by: Rafael J. Wysocki <rjw@sisk.pl>

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11  7:48       ` Ingo Molnar
                         ` (2 preceding siblings ...)
  (?)
@ 2009-11-11  9:56       ` Rafael J. Wysocki
  -1 siblings, 0 replies; 44+ messages in thread
From: Rafael J. Wysocki @ 2009-11-11  9:56 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Thomas Gleixner, Yinghai Lu, pm list

On Wednesday 11 November 2009, Ingo Molnar wrote:
> 
> * Yinghai Lu <yinghai@kernel.org> wrote:
> 
> > 
> > try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> > 
> > to get area is below 1M
> > 
> > -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> > 
> > Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> > 
> > ---
> >  arch/x86/include/asm/acpi.h  |    2 +-
> >  arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
> >  arch/x86/kernel/setup.c      |   13 +++++++------
> >  3 files changed, 17 insertions(+), 13 deletions(-)
> 
> Looks good. Rafael, Peter, does it look good to you too?

Yes, it does.

Acked-by: Rafael J. Wysocki <rjw@sisk.pl>

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11  9:12     ` ykzhao
  2009-11-11 19:05       ` Yinghai Lu
@ 2009-11-11 19:05       ` Yinghai Lu
  2009-11-12  1:17         ` ykzhao
  2009-11-12  1:17         ` ykzhao
  1 sibling, 2 replies; 44+ messages in thread
From: Yinghai Lu @ 2009-11-11 19:05 UTC (permalink / raw)
  To: ykzhao
  Cc: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

ykzhao wrote:
> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
>>
>> to get area is below 1M
>>
>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> It seems that the function of find_e820_area is called in several
> places.
>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
> bootmap_size, PAGE_SIZE);
>    
> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
> base address as that obtained in initmem_init?

no. find_e820_area will check the reserve res array that could be updated by reserve_early.

YH

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11  9:12     ` ykzhao
@ 2009-11-11 19:05       ` Yinghai Lu
  2009-11-11 19:05       ` Yinghai Lu
  1 sibling, 0 replies; 44+ messages in thread
From: Yinghai Lu @ 2009-11-11 19:05 UTC (permalink / raw)
  To: ykzhao
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, pm list, Thomas Gleixner

ykzhao wrote:
> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
>>
>> to get area is below 1M
>>
>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> It seems that the function of find_e820_area is called in several
> places.
>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
> bootmap_size, PAGE_SIZE);
>    
> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
> base address as that obtained in initmem_init?

no. find_e820_area will check the reserve res array that could be updated by reserve_early.

YH

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

* [tip:x86/mm] x86: Make sure wakeup trampoline code is below 1MB
  2009-11-11  2:27   ` [PATCH] x86: make sure wakeup code is below 1M -v2 Yinghai Lu
                       ` (3 preceding siblings ...)
  2009-11-11  9:12     ` ykzhao
@ 2009-11-11 20:30     ` tip-bot for Yinghai Lu
  2009-11-11 20:30     ` tip-bot for Yinghai Lu
  2009-11-12  7:36       ` Pavel Machek
  6 siblings, 0 replies; 44+ messages in thread
From: tip-bot for Yinghai Lu @ 2009-11-11 20:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, linux-pm, hpa, mingo, yinghai, torvalds, lenb,
	tglx, rjw, mingo

Commit-ID:  196cf0d67acad70ebb2572da489d5cc7066cdd05
Gitweb:     http://git.kernel.org/tip/196cf0d67acad70ebb2572da489d5cc7066cdd05
Author:     Yinghai Lu <yinghai@kernel.org>
AuthorDate: Tue, 10 Nov 2009 18:27:23 -0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 11 Nov 2009 20:14:32 +0100

x86: Make sure wakeup trampoline code is below 1MB

Instead of using bootmem, try find_e820_area()/reserve_early(),
and call acpi_reserve_memory() early, to allocate the wakeup
trampoline code area below 1M.

This is more reliable, and it also removes a dependency on
bootmem.

-v2: change function name to acpi_reserve_wakeup_memory(),
     as suggested by Rafael.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: pm list <linux-pm@lists.linux-foundation.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
LKML-Reference: <4AFA210B.3020207@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/include/asm/acpi.h  |    2 +-
 arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
 arch/x86/kernel/setup.c      |   13 +++++++------
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index e3d4a0d..60d2b2d 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -118,7 +118,7 @@ extern void acpi_restore_state_mem(void);
 extern unsigned long acpi_wakeup_address;
 
 /* early initialization routine */
-extern void acpi_reserve_bootmem(void);
+extern void acpi_reserve_wakeup_memory(void);
 
 /*
  * Check if the CPU can handle C2 and deeper
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index ca93638..4a41145 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
 
 
 /**
- * acpi_reserve_bootmem - do _very_ early ACPI initialisation
+ * acpi_reserve_wakeup_memory - do _very_ early ACPI initialisation
  *
  * We allocate a page from the first 1MB of memory for the wakeup
  * routine for when we come back from a sleep state. The
  * runtime allocator allows specification of <16MB pages, but not
  * <1MB pages.
  */
-void __init acpi_reserve_bootmem(void)
+void __init acpi_reserve_wakeup_memory(void)
 {
+	unsigned long mem;
+
 	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
 		printk(KERN_ERR
 		       "ACPI: Wakeup code way too big, S3 disabled.\n");
 		return;
 	}
 
-	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
+	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
 
-	if (!acpi_realmode) {
+	if (mem == -1L) {
 		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
 		return;
 	}
-
-	acpi_wakeup_address = virt_to_phys((void *)acpi_realmode);
+	acpi_realmode = (unsigned long) phys_to_virt(mem);
+	acpi_wakeup_address = mem;
+	reserve_early(mem, mem + WAKEUP_SIZE, "ACPI WAKEUP");
 }
 
 
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index f891419..0a6e94a 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -897,6 +897,13 @@ void __init setup_arch(char **cmdline_p)
 
 	reserve_brk();
 
+#ifdef CONFIG_ACPI_SLEEP
+	/*
+	 * Reserve low memory region for sleep support.
+	 * even before init_memory_mapping
+	 */
+	acpi_reserve_wakeup_memory();
+#endif
 	init_gbpages();
 
 	/* max_pfn_mapped is updated here */
@@ -948,12 +955,6 @@ void __init setup_arch(char **cmdline_p)
 
 	initmem_init(0, max_pfn, acpi, k8);
 
-#ifdef CONFIG_ACPI_SLEEP
-	/*
-	 * Reserve low memory region for sleep support.
-	 */
-	acpi_reserve_bootmem();
-#endif
 	/*
 	 * Find and reserve possible boot-time SMP configuration:
 	 */

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

* [tip:x86/mm] x86: Make sure wakeup trampoline code is below 1MB
  2009-11-11  2:27   ` [PATCH] x86: make sure wakeup code is below 1M -v2 Yinghai Lu
                       ` (4 preceding siblings ...)
  2009-11-11 20:30     ` [tip:x86/mm] x86: Make sure wakeup trampoline code is below 1MB tip-bot for Yinghai Lu
@ 2009-11-11 20:30     ` tip-bot for Yinghai Lu
  2009-11-12  7:36       ` Pavel Machek
  6 siblings, 0 replies; 44+ messages in thread
From: tip-bot for Yinghai Lu @ 2009-11-11 20:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: yinghai, mingo, linux-kernel, mingo, hpa, linux-pm, torvalds, tglx

Commit-ID:  196cf0d67acad70ebb2572da489d5cc7066cdd05
Gitweb:     http://git.kernel.org/tip/196cf0d67acad70ebb2572da489d5cc7066cdd05
Author:     Yinghai Lu <yinghai@kernel.org>
AuthorDate: Tue, 10 Nov 2009 18:27:23 -0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 11 Nov 2009 20:14:32 +0100

x86: Make sure wakeup trampoline code is below 1MB

Instead of using bootmem, try find_e820_area()/reserve_early(),
and call acpi_reserve_memory() early, to allocate the wakeup
trampoline code area below 1M.

This is more reliable, and it also removes a dependency on
bootmem.

-v2: change function name to acpi_reserve_wakeup_memory(),
     as suggested by Rafael.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: pm list <linux-pm@lists.linux-foundation.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
LKML-Reference: <4AFA210B.3020207@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/include/asm/acpi.h  |    2 +-
 arch/x86/kernel/acpi/sleep.c |   15 +++++++++------
 arch/x86/kernel/setup.c      |   13 +++++++------
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index e3d4a0d..60d2b2d 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -118,7 +118,7 @@ extern void acpi_restore_state_mem(void);
 extern unsigned long acpi_wakeup_address;
 
 /* early initialization routine */
-extern void acpi_reserve_bootmem(void);
+extern void acpi_reserve_wakeup_memory(void);
 
 /*
  * Check if the CPU can handle C2 and deeper
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index ca93638..4a41145 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
 
 
 /**
- * acpi_reserve_bootmem - do _very_ early ACPI initialisation
+ * acpi_reserve_wakeup_memory - do _very_ early ACPI initialisation
  *
  * We allocate a page from the first 1MB of memory for the wakeup
  * routine for when we come back from a sleep state. The
  * runtime allocator allows specification of <16MB pages, but not
  * <1MB pages.
  */
-void __init acpi_reserve_bootmem(void)
+void __init acpi_reserve_wakeup_memory(void)
 {
+	unsigned long mem;
+
 	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
 		printk(KERN_ERR
 		       "ACPI: Wakeup code way too big, S3 disabled.\n");
 		return;
 	}
 
-	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
+	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
 
-	if (!acpi_realmode) {
+	if (mem == -1L) {
 		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
 		return;
 	}
-
-	acpi_wakeup_address = virt_to_phys((void *)acpi_realmode);
+	acpi_realmode = (unsigned long) phys_to_virt(mem);
+	acpi_wakeup_address = mem;
+	reserve_early(mem, mem + WAKEUP_SIZE, "ACPI WAKEUP");
 }
 
 
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index f891419..0a6e94a 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -897,6 +897,13 @@ void __init setup_arch(char **cmdline_p)
 
 	reserve_brk();
 
+#ifdef CONFIG_ACPI_SLEEP
+	/*
+	 * Reserve low memory region for sleep support.
+	 * even before init_memory_mapping
+	 */
+	acpi_reserve_wakeup_memory();
+#endif
 	init_gbpages();
 
 	/* max_pfn_mapped is updated here */
@@ -948,12 +955,6 @@ void __init setup_arch(char **cmdline_p)
 
 	initmem_init(0, max_pfn, acpi, k8);
 
-#ifdef CONFIG_ACPI_SLEEP
-	/*
-	 * Reserve low memory region for sleep support.
-	 */
-	acpi_reserve_bootmem();
-#endif
 	/*
 	 * Find and reserve possible boot-time SMP configuration:
 	 */

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11 19:05       ` Yinghai Lu
  2009-11-12  1:17         ` ykzhao
@ 2009-11-12  1:17         ` ykzhao
  2009-11-12  3:12           ` Yinghai Lu
  2009-11-12  3:12           ` Yinghai Lu
  1 sibling, 2 replies; 44+ messages in thread
From: ykzhao @ 2009-11-12  1:17 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
> ykzhao wrote:
> > On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
> >> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> >>
> >> to get area is below 1M
> >>
> >> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> > It seems that the function of find_e820_area is called in several
> > places.
> >    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
> > bootmap_size, PAGE_SIZE);
> >    
> > If we also call it in the acpi_reserve_wakeup_memory, do we get the same
> > base address as that obtained in initmem_init?
> 
> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
It will check the reserved region array when calling the function of
find_e820_area. 
But it seems that the array is not updated when the find_e820_area is
called in the function of initmem_init.

At the same time the  acpi_reserve_bootmem is called after initializing
the boot mem allocator. Can we continue to reserve some region by using
find_e820_area?

thanks.
> 
> YH


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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11 19:05       ` Yinghai Lu
@ 2009-11-12  1:17         ` ykzhao
  2009-11-12  1:17         ` ykzhao
  1 sibling, 0 replies; 44+ messages in thread
From: ykzhao @ 2009-11-12  1:17 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, pm list, Thomas Gleixner

On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
> ykzhao wrote:
> > On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
> >> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> >>
> >> to get area is below 1M
> >>
> >> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> > It seems that the function of find_e820_area is called in several
> > places.
> >    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
> > bootmap_size, PAGE_SIZE);
> >    
> > If we also call it in the acpi_reserve_wakeup_memory, do we get the same
> > base address as that obtained in initmem_init?
> 
> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
It will check the reserved region array when calling the function of
find_e820_area. 
But it seems that the array is not updated when the find_e820_area is
called in the function of initmem_init.

At the same time the  acpi_reserve_bootmem is called after initializing
the boot mem allocator. Can we continue to reserve some region by using
find_e820_area?

thanks.
> 
> YH

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  1:17         ` ykzhao
  2009-11-12  3:12           ` Yinghai Lu
@ 2009-11-12  3:12           ` Yinghai Lu
  2009-11-12  3:37             ` ykzhao
  2009-11-12  3:37             ` ykzhao
  1 sibling, 2 replies; 44+ messages in thread
From: Yinghai Lu @ 2009-11-12  3:12 UTC (permalink / raw)
  To: ykzhao
  Cc: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

ykzhao wrote:
> On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
>> ykzhao wrote:
>>> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
>>>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
>>>>
>>>> to get area is below 1M
>>>>
>>>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
>>> It seems that the function of find_e820_area is called in several
>>> places.
>>>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
>>> bootmap_size, PAGE_SIZE);
>>>    
>>> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
>>> base address as that obtained in initmem_init?
>> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
> It will check the reserved region array when calling the function of
> find_e820_area. 
> But it seems that the array is not updated when the find_e820_area is
> called in the function of initmem_init.

right after that will use reserve_bootmem for those range in initmem_init.

also we could reserve_early there and let bootmem conversion to do that for us.

but for numa there is some chance to use other node bootmem to for that bootdata and bitmap.
so make it simple just use reserve_bootmem there.

YH

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  1:17         ` ykzhao
@ 2009-11-12  3:12           ` Yinghai Lu
  2009-11-12  3:12           ` Yinghai Lu
  1 sibling, 0 replies; 44+ messages in thread
From: Yinghai Lu @ 2009-11-12  3:12 UTC (permalink / raw)
  To: ykzhao
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, pm list, Thomas Gleixner

ykzhao wrote:
> On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
>> ykzhao wrote:
>>> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
>>>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
>>>>
>>>> to get area is below 1M
>>>>
>>>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
>>> It seems that the function of find_e820_area is called in several
>>> places.
>>>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
>>> bootmap_size, PAGE_SIZE);
>>>    
>>> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
>>> base address as that obtained in initmem_init?
>> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
> It will check the reserved region array when calling the function of
> find_e820_area. 
> But it seems that the array is not updated when the find_e820_area is
> called in the function of initmem_init.

right after that will use reserve_bootmem for those range in initmem_init.

also we could reserve_early there and let bootmem conversion to do that for us.

but for numa there is some chance to use other node bootmem to for that bootdata and bitmap.
so make it simple just use reserve_bootmem there.

YH

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  3:12           ` Yinghai Lu
@ 2009-11-12  3:37             ` ykzhao
  2009-11-12  5:21               ` Yinghai Lu
  2009-11-12  5:21               ` Yinghai Lu
  2009-11-12  3:37             ` ykzhao
  1 sibling, 2 replies; 44+ messages in thread
From: ykzhao @ 2009-11-12  3:37 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

On Thu, 2009-11-12 at 11:12 +0800, Yinghai Lu wrote:
> ykzhao wrote:
> > On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
> >> ykzhao wrote:
> >>> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
> >>>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> >>>>
> >>>> to get area is below 1M
> >>>>
> >>>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> >>> It seems that the function of find_e820_area is called in several
> >>> places.
> >>>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
> >>> bootmap_size, PAGE_SIZE);
> >>>    
> >>> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
> >>> base address as that obtained in initmem_init?
> >> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
> > It will check the reserved region array when calling the function of
> > find_e820_area. 
> > But it seems that the array is not updated when the find_e820_area is
> > called in the function of initmem_init.
> 
> right after that will use reserve_bootmem for those range in initmem_init.
Yes. The reserve_bootmem is called for the range in initmem_init.
But the reserved_early array is not updated.
> 
> also we could reserve_early there and let bootmem conversion to do that for us.
> 
> but for numa there is some chance to use other node bootmem to for that bootdata and bitmap.
> so make it simple just use reserve_bootmem there.
> 
> YH


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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  3:12           ` Yinghai Lu
  2009-11-12  3:37             ` ykzhao
@ 2009-11-12  3:37             ` ykzhao
  1 sibling, 0 replies; 44+ messages in thread
From: ykzhao @ 2009-11-12  3:37 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, pm list, Thomas Gleixner

On Thu, 2009-11-12 at 11:12 +0800, Yinghai Lu wrote:
> ykzhao wrote:
> > On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
> >> ykzhao wrote:
> >>> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
> >>>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> >>>>
> >>>> to get area is below 1M
> >>>>
> >>>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> >>> It seems that the function of find_e820_area is called in several
> >>> places.
> >>>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
> >>> bootmap_size, PAGE_SIZE);
> >>>    
> >>> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
> >>> base address as that obtained in initmem_init?
> >> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
> > It will check the reserved region array when calling the function of
> > find_e820_area. 
> > But it seems that the array is not updated when the find_e820_area is
> > called in the function of initmem_init.
> 
> right after that will use reserve_bootmem for those range in initmem_init.
Yes. The reserve_bootmem is called for the range in initmem_init.
But the reserved_early array is not updated.
> 
> also we could reserve_early there and let bootmem conversion to do that for us.
> 
> but for numa there is some chance to use other node bootmem to for that bootdata and bitmap.
> so make it simple just use reserve_bootmem there.
> 
> YH

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  3:37             ` ykzhao
  2009-11-12  5:21               ` Yinghai Lu
@ 2009-11-12  5:21               ` Yinghai Lu
  2009-11-12  7:14                 ` ykzhao
                                   ` (3 more replies)
  1 sibling, 4 replies; 44+ messages in thread
From: Yinghai Lu @ 2009-11-12  5:21 UTC (permalink / raw)
  To: ykzhao
  Cc: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

ykzhao wrote:
> On Thu, 2009-11-12 at 11:12 +0800, Yinghai Lu wrote:
>> ykzhao wrote:
>>> On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
>>>> ykzhao wrote:
>>>>> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
>>>>>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
>>>>>>
>>>>>> to get area is below 1M
>>>>>>
>>>>>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
>>>>> It seems that the function of find_e820_area is called in several
>>>>> places.
>>>>>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
>>>>> bootmap_size, PAGE_SIZE);
>>>>>    
>>>>> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
>>>>> base address as that obtained in initmem_init?
>>>> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
>>> It will check the reserved region array when calling the function of
>>> find_e820_area. 
>>> But it seems that the array is not updated when the find_e820_area is
>>> called in the function of initmem_init.
>> right after that will use reserve_bootmem for those range in initmem_init.
> Yes. The reserve_bootmem is called for the range in initmem_init.
> But the reserved_early array is not updated.

it is not needed anymore because bootmem for that node is ready at that point, could use 
reserve_bootmem_node directly. and before that early_res_to_bootmem will convert that early resource that 
fall into that node range to bootmem reserved too.

please check code setup_node_bootmem/early_node_mem/early_res_to_bootmem ...and reserve_bootmem_node...

YH

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  3:37             ` ykzhao
@ 2009-11-12  5:21               ` Yinghai Lu
  2009-11-12  5:21               ` Yinghai Lu
  1 sibling, 0 replies; 44+ messages in thread
From: Yinghai Lu @ 2009-11-12  5:21 UTC (permalink / raw)
  To: ykzhao
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, pm list, Thomas Gleixner

ykzhao wrote:
> On Thu, 2009-11-12 at 11:12 +0800, Yinghai Lu wrote:
>> ykzhao wrote:
>>> On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
>>>> ykzhao wrote:
>>>>> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
>>>>>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
>>>>>>
>>>>>> to get area is below 1M
>>>>>>
>>>>>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
>>>>> It seems that the function of find_e820_area is called in several
>>>>> places.
>>>>>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
>>>>> bootmap_size, PAGE_SIZE);
>>>>>    
>>>>> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
>>>>> base address as that obtained in initmem_init?
>>>> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
>>> It will check the reserved region array when calling the function of
>>> find_e820_area. 
>>> But it seems that the array is not updated when the find_e820_area is
>>> called in the function of initmem_init.
>> right after that will use reserve_bootmem for those range in initmem_init.
> Yes. The reserve_bootmem is called for the range in initmem_init.
> But the reserved_early array is not updated.

it is not needed anymore because bootmem for that node is ready at that point, could use 
reserve_bootmem_node directly. and before that early_res_to_bootmem will convert that early resource that 
fall into that node range to bootmem reserved too.

please check code setup_node_bootmem/early_node_mem/early_res_to_bootmem ...and reserve_bootmem_node...

YH

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  5:21               ` Yinghai Lu
  2009-11-12  7:14                 ` ykzhao
@ 2009-11-12  7:14                 ` ykzhao
  2009-11-12  7:20                   ` H. Peter Anvin
  2009-11-12  7:20                   ` H. Peter Anvin
  2009-11-12  7:43                 ` ykzhao
  2009-11-12  7:43                 ` ykzhao
  3 siblings, 2 replies; 44+ messages in thread
From: ykzhao @ 2009-11-12  7:14 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

On Thu, 2009-11-12 at 13:21 +0800, Yinghai Lu wrote:
> ykzhao wrote:
> > On Thu, 2009-11-12 at 11:12 +0800, Yinghai Lu wrote:
> >> ykzhao wrote:
> >>> On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
> >>>> ykzhao wrote:
> >>>>> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
> >>>>>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> >>>>>>
> >>>>>> to get area is below 1M
> >>>>>>
> >>>>>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> >>>>> It seems that the function of find_e820_area is called in several
> >>>>> places.
> >>>>>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
> >>>>> bootmap_size, PAGE_SIZE);
> >>>>>    
> >>>>> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
> >>>>> base address as that obtained in initmem_init?
> >>>> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
> >>> It will check the reserved region array when calling the function of
> >>> find_e820_area. 
> >>> But it seems that the array is not updated when the find_e820_area is
> >>> called in the function of initmem_init.
> >> right after that will use reserve_bootmem for those range in initmem_init.
> > Yes. The reserve_bootmem is called for the range in initmem_init.
> > But the reserved_early array is not updated.
> 
> it is not needed anymore because bootmem for that node is ready at that point, could use 
> reserve_bootmem_node directly. and before that early_res_to_bootmem will convert that early resource that 
> fall into that node range to bootmem reserved too.
After the bootmem allocator is initialized, the early_res_to_bootmem
will convert the resource in reserved_early array and reserve them in
the bootmem. 

In this patch the find_e820_area is used in the
acpi_reserve_wakeup_memory, which is called after initializing the
bootmem allocator.
Can we still use the find_e820_area after the bootmem allocator is
initialized? 
It seems that the bootmem bitmap is also found by using the
find_e820_area. But we don't update the reserved_early array any more.
Maybe we will get the overlap address with the bootmem bitmap for the
wakeup code.

thanks.
> 
> please check code setup_node_bootmem/early_node_mem/early_res_to_bootmem ...and reserve_bootmem_node...

> 
> YH


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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  5:21               ` Yinghai Lu
@ 2009-11-12  7:14                 ` ykzhao
  2009-11-12  7:14                 ` ykzhao
                                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 44+ messages in thread
From: ykzhao @ 2009-11-12  7:14 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, pm list, Thomas Gleixner

On Thu, 2009-11-12 at 13:21 +0800, Yinghai Lu wrote:
> ykzhao wrote:
> > On Thu, 2009-11-12 at 11:12 +0800, Yinghai Lu wrote:
> >> ykzhao wrote:
> >>> On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
> >>>> ykzhao wrote:
> >>>>> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
> >>>>>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> >>>>>>
> >>>>>> to get area is below 1M
> >>>>>>
> >>>>>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> >>>>> It seems that the function of find_e820_area is called in several
> >>>>> places.
> >>>>>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
> >>>>> bootmap_size, PAGE_SIZE);
> >>>>>    
> >>>>> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
> >>>>> base address as that obtained in initmem_init?
> >>>> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
> >>> It will check the reserved region array when calling the function of
> >>> find_e820_area. 
> >>> But it seems that the array is not updated when the find_e820_area is
> >>> called in the function of initmem_init.
> >> right after that will use reserve_bootmem for those range in initmem_init.
> > Yes. The reserve_bootmem is called for the range in initmem_init.
> > But the reserved_early array is not updated.
> 
> it is not needed anymore because bootmem for that node is ready at that point, could use 
> reserve_bootmem_node directly. and before that early_res_to_bootmem will convert that early resource that 
> fall into that node range to bootmem reserved too.
After the bootmem allocator is initialized, the early_res_to_bootmem
will convert the resource in reserved_early array and reserve them in
the bootmem. 

In this patch the find_e820_area is used in the
acpi_reserve_wakeup_memory, which is called after initializing the
bootmem allocator.
Can we still use the find_e820_area after the bootmem allocator is
initialized? 
It seems that the bootmem bitmap is also found by using the
find_e820_area. But we don't update the reserved_early array any more.
Maybe we will get the overlap address with the bootmem bitmap for the
wakeup code.

thanks.
> 
> please check code setup_node_bootmem/early_node_mem/early_res_to_bootmem ...and reserve_bootmem_node...

> 
> YH

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  7:14                 ` ykzhao
  2009-11-12  7:20                   ` H. Peter Anvin
@ 2009-11-12  7:20                   ` H. Peter Anvin
  1 sibling, 0 replies; 44+ messages in thread
From: H. Peter Anvin @ 2009-11-12  7:20 UTC (permalink / raw)
  To: ykzhao
  Cc: Yinghai Lu, Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

On 11/11/2009 11:14 PM, ykzhao wrote:
> 
> In this patch the find_e820_area is used in the
> acpi_reserve_wakeup_memory, which is called after initializing the
> bootmem allocator.
> Can we still use the find_e820_area after the bootmem allocator is
> initialized? 

Obviously not: the bootmem allocator now thinks it owns memory, and it
wouldn't know not to allocate something that is later claimed by
find_e820_area.  Problem.

> It seems that the bootmem bitmap is also found by using the
> find_e820_area. But we don't update the reserved_early array any more.
> Maybe we will get the overlap address with the bootmem bitmap for the
> wakeup code.

Not just the bitmap, but any bootmem allocation could conflict...

	-hpa
-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  7:14                 ` ykzhao
@ 2009-11-12  7:20                   ` H. Peter Anvin
  2009-11-12  7:20                   ` H. Peter Anvin
  1 sibling, 0 replies; 44+ messages in thread
From: H. Peter Anvin @ 2009-11-12  7:20 UTC (permalink / raw)
  To: ykzhao
  Cc: linux-kernel, ACPI Devel Maling List, pm list, Ingo Molnar,
	Yinghai Lu, Thomas Gleixner

On 11/11/2009 11:14 PM, ykzhao wrote:
> 
> In this patch the find_e820_area is used in the
> acpi_reserve_wakeup_memory, which is called after initializing the
> bootmem allocator.
> Can we still use the find_e820_area after the bootmem allocator is
> initialized? 

Obviously not: the bootmem allocator now thinks it owns memory, and it
wouldn't know not to allocate something that is later claimed by
find_e820_area.  Problem.

> It seems that the bootmem bitmap is also found by using the
> find_e820_area. But we don't update the reserved_early array any more.
> Maybe we will get the overlap address with the bootmem bitmap for the
> wakeup code.

Not just the bitmap, but any bootmem allocation could conflict...

	-hpa
-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-11  2:27   ` [PATCH] x86: make sure wakeup code is below 1M -v2 Yinghai Lu
@ 2009-11-12  7:36       ` Pavel Machek
  2009-11-11  7:48     ` Ingo Molnar
                         ` (5 subsequent siblings)
  6 siblings, 0 replies; 44+ messages in thread
From: Pavel Machek @ 2009-11-12  7:36 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, pm list, Thomas Gleixner

On Tue 2009-11-10 18:27:23, Yinghai Lu wrote:
> 
> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> 
> to get area is below 1M

Does it fix anything? I can't tell from the changelog...

> Signed-off-by: Yinghai Lu <yinghai@kernel.org>

Please CC me on suspend patches.
>  /*
>   * Check if the CPU can handle C2 and deeper
> Index: linux-2.6/arch/x86/kernel/acpi/sleep.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/kernel/acpi/sleep.c
> +++ linux-2.6/arch/x86/kernel/acpi/sleep.c
> @@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
>  
>  
>  /**
> - * acpi_reserve_bootmem - do _very_ early ACPI initialisation
> + * acpi_reserve_wakeup_memory - do _very_ early ACPI initialisation
>   *
>   * We allocate a page from the first 1MB of memory for the wakeup
>   * routine for when we come back from a sleep state. The
>   * runtime allocator allows specification of <16MB pages, but not
>   * <1MB pages.
>   */
> -void __init acpi_reserve_bootmem(void)
> +void __init acpi_reserve_wakeup_memory(void)
>  {
> +	unsigned long mem;
> +
>  	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
>  		printk(KERN_ERR
>  		       "ACPI: Wakeup code way too big, S3 disabled.\n");
>  		return;
>  	}
>  
> -	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
> +	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
>  
> -	if (!acpi_realmode) {
> +	if (mem == -1L) {
>  		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
>  		return;
>  	}

How is it better then old code?

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
@ 2009-11-12  7:36       ` Pavel Machek
  0 siblings, 0 replies; 44+ messages in thread
From: Pavel Machek @ 2009-11-12  7:36 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

On Tue 2009-11-10 18:27:23, Yinghai Lu wrote:
> 
> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> 
> to get area is below 1M

Does it fix anything? I can't tell from the changelog...

> Signed-off-by: Yinghai Lu <yinghai@kernel.org>

Please CC me on suspend patches.
>  /*
>   * Check if the CPU can handle C2 and deeper
> Index: linux-2.6/arch/x86/kernel/acpi/sleep.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/kernel/acpi/sleep.c
> +++ linux-2.6/arch/x86/kernel/acpi/sleep.c
> @@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
>  
>  
>  /**
> - * acpi_reserve_bootmem - do _very_ early ACPI initialisation
> + * acpi_reserve_wakeup_memory - do _very_ early ACPI initialisation
>   *
>   * We allocate a page from the first 1MB of memory for the wakeup
>   * routine for when we come back from a sleep state. The
>   * runtime allocator allows specification of <16MB pages, but not
>   * <1MB pages.
>   */
> -void __init acpi_reserve_bootmem(void)
> +void __init acpi_reserve_wakeup_memory(void)
>  {
> +	unsigned long mem;
> +
>  	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
>  		printk(KERN_ERR
>  		       "ACPI: Wakeup code way too big, S3 disabled.\n");
>  		return;
>  	}
>  
> -	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
> +	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
>  
> -	if (!acpi_realmode) {
> +	if (mem == -1L) {
>  		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
>  		return;
>  	}

How is it better then old code?

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  5:21               ` Yinghai Lu
  2009-11-12  7:14                 ` ykzhao
  2009-11-12  7:14                 ` ykzhao
@ 2009-11-12  7:43                 ` ykzhao
  2009-11-12  7:43                 ` ykzhao
  3 siblings, 0 replies; 44+ messages in thread
From: ykzhao @ 2009-11-12  7:43 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

On Thu, 2009-11-12 at 13:21 +0800, Yinghai Lu wrote:
> ykzhao wrote:
> > On Thu, 2009-11-12 at 11:12 +0800, Yinghai Lu wrote:
> >> ykzhao wrote:
> >>> On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
> >>>> ykzhao wrote:
> >>>>> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
> >>>>>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> >>>>>>
> >>>>>> to get area is below 1M
> >>>>>>
> >>>>>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> >>>>> It seems that the function of find_e820_area is called in several
> >>>>> places.
> >>>>>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
> >>>>> bootmap_size, PAGE_SIZE);
> >>>>>    
> >>>>> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
> >>>>> base address as that obtained in initmem_init?
> >>>> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
> >>> It will check the reserved region array when calling the function of
> >>> find_e820_area. 
> >>> But it seems that the array is not updated when the find_e820_area is
> >>> called in the function of initmem_init.
> >> right after that will use reserve_bootmem for those range in initmem_init.
> > Yes. The reserve_bootmem is called for the range in initmem_init.
> > But the reserved_early array is not updated.
> 
> it is not needed anymore because bootmem for that node is ready at that point, could use 
> reserve_bootmem_node directly. and before that early_res_to_bootmem will convert that early resource that 
> fall into that node range to bootmem reserved too.
> 
> please check code setup_node_bootmem/early_node_mem/early_res_to_bootmem ...and reserve_bootmem_node...
Sorry that I don't notice that the function
of acpi_reserve_wakeup_memory is also moved early before initializing
the bootmem allocator.
If so, there is no problem.

thanks.
> 
> YH

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  5:21               ` Yinghai Lu
                                   ` (2 preceding siblings ...)
  2009-11-12  7:43                 ` ykzhao
@ 2009-11-12  7:43                 ` ykzhao
  3 siblings, 0 replies; 44+ messages in thread
From: ykzhao @ 2009-11-12  7:43 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, pm list, Thomas Gleixner

On Thu, 2009-11-12 at 13:21 +0800, Yinghai Lu wrote:
> ykzhao wrote:
> > On Thu, 2009-11-12 at 11:12 +0800, Yinghai Lu wrote:
> >> ykzhao wrote:
> >>> On Thu, 2009-11-12 at 03:05 +0800, Yinghai Lu wrote:
> >>>> ykzhao wrote:
> >>>>> On Wed, 2009-11-11 at 10:27 +0800, Yinghai Lu wrote:
> >>>>>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> >>>>>>
> >>>>>> to get area is below 1M
> >>>>>>
> >>>>>> -v2: change function name to acpi_reserve_wakeup_memory according to Rafael
> >>>>> It seems that the function of find_e820_area is called in several
> >>>>> places.
> >>>>>    >Initmem_init: bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT,
> >>>>> bootmap_size, PAGE_SIZE);
> >>>>>    
> >>>>> If we also call it in the acpi_reserve_wakeup_memory, do we get the same
> >>>>> base address as that obtained in initmem_init?
> >>>> no. find_e820_area will check the reserve res array that could be updated by reserve_early.
> >>> It will check the reserved region array when calling the function of
> >>> find_e820_area. 
> >>> But it seems that the array is not updated when the find_e820_area is
> >>> called in the function of initmem_init.
> >> right after that will use reserve_bootmem for those range in initmem_init.
> > Yes. The reserve_bootmem is called for the range in initmem_init.
> > But the reserved_early array is not updated.
> 
> it is not needed anymore because bootmem for that node is ready at that point, could use 
> reserve_bootmem_node directly. and before that early_res_to_bootmem will convert that early resource that 
> fall into that node range to bootmem reserved too.
> 
> please check code setup_node_bootmem/early_node_mem/early_res_to_bootmem ...and reserve_bootmem_node...
Sorry that I don't notice that the function
of acpi_reserve_wakeup_memory is also moved early before initializing
the bootmem allocator.
If so, there is no problem.

thanks.
> 
> YH

_______________________________________________
linux-pm mailing list
linux-pm@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  7:36       ` Pavel Machek
  (?)
  (?)
@ 2009-11-12 19:25       ` Yinghai Lu
  -1 siblings, 0 replies; 44+ messages in thread
From: Yinghai Lu @ 2009-11-12 19:25 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Rafael J. Wysocki, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

Pavel Machek wrote:
> On Tue 2009-11-10 18:27:23, Yinghai Lu wrote:
>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
>>
>> to get area is below 1M
> 
>> -	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
>> +	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
>>  
>> -	if (!acpi_realmode) {
>> +	if (mem == -1L) {
>>  		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
>>  		return;
>>  	}
> 
> How is it better then old code?

could get range below 1M.

alloc_bootmem_low can not make sure get that below 1M.

init_memory_mapping could use below 1M as page table...

so need to get some buffer for acpi wakeup realmode code.

YH

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  7:36       ` Pavel Machek
  (?)
@ 2009-11-12 19:25       ` Yinghai Lu
  -1 siblings, 0 replies; 44+ messages in thread
From: Yinghai Lu @ 2009-11-12 19:25 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, pm list, Thomas Gleixner

Pavel Machek wrote:
> On Tue 2009-11-10 18:27:23, Yinghai Lu wrote:
>> try to find_e820_area/reserve_early, and call acpi_reserve_memory early
>>
>> to get area is below 1M
> 
>> -	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
>> +	mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
>>  
>> -	if (!acpi_realmode) {
>> +	if (mem == -1L) {
>>  		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
>>  		return;
>>  	}
> 
> How is it better then old code?

could get range below 1M.

alloc_bootmem_low can not make sure get that below 1M.

init_memory_mapping could use below 1M as page table...

so need to get some buffer for acpi wakeup realmode code.

YH

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  7:36       ` Pavel Machek
                         ` (3 preceding siblings ...)
  (?)
@ 2009-11-12 19:32       ` Rafael J. Wysocki
  2009-11-13  7:36         ` Ingo Molnar
  2009-11-13  7:36         ` Ingo Molnar
  -1 siblings, 2 replies; 44+ messages in thread
From: Rafael J. Wysocki @ 2009-11-12 19:32 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Yinghai Lu, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

On Thursday 12 November 2009, Pavel Machek wrote:
> On Tue 2009-11-10 18:27:23, Yinghai Lu wrote:
> > 
> > try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> > 
> > to get area is below 1M
> 
> Does it fix anything? I can't tell from the changelog...

Yes, it does.  If the area is above 1M, we can't run real mode code from it.

This matters for NUMA machines supporting S3 (yes, there are a few models
out there).

Thanks,
Rafael

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12  7:36       ` Pavel Machek
                         ` (2 preceding siblings ...)
  (?)
@ 2009-11-12 19:32       ` Rafael J. Wysocki
  -1 siblings, 0 replies; 44+ messages in thread
From: Rafael J. Wysocki @ 2009-11-12 19:32 UTC (permalink / raw)
  To: Pavel Machek
  Cc: pm list, linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Ingo Molnar, Yinghai Lu, Thomas Gleixner

On Thursday 12 November 2009, Pavel Machek wrote:
> On Tue 2009-11-10 18:27:23, Yinghai Lu wrote:
> > 
> > try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> > 
> > to get area is below 1M
> 
> Does it fix anything? I can't tell from the changelog...

Yes, it does.  If the area is above 1M, we can't run real mode code from it.

This matters for NUMA machines supporting S3 (yes, there are a few models
out there).

Thanks,
Rafael

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12 19:32       ` Rafael J. Wysocki
  2009-11-13  7:36         ` Ingo Molnar
@ 2009-11-13  7:36         ` Ingo Molnar
  2009-11-13  8:04           ` H. Peter Anvin
  2009-11-13  8:04           ` H. Peter Anvin
  1 sibling, 2 replies; 44+ messages in thread
From: Ingo Molnar @ 2009-11-13  7:36 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Pavel Machek, Yinghai Lu, Thomas Gleixner, H. Peter Anvin,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list


* Rafael J. Wysocki <rjw@sisk.pl> wrote:

> On Thursday 12 November 2009, Pavel Machek wrote:
> > On Tue 2009-11-10 18:27:23, Yinghai Lu wrote:
> > > 
> > > try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> > > 
> > > to get area is below 1M
> > 
> > Does it fix anything? I can't tell from the changelog...
> 
> Yes, it does.  If the area is above 1M, we can't run real mode code 
> from it.
> 
> This matters for NUMA machines supporting S3 (yes, there are a few 
> models out there).

It might also matter in more exotic kernels that might do some large 
allocations. (say 'nopentium' can cause +1MB/+2MB of kernel page table 
allocations per one GB of RAM)

Physical constraints to allocations (which this is) should be expressed 
early and with high priority, to make sure they can be met.

	Ingo

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-12 19:32       ` Rafael J. Wysocki
@ 2009-11-13  7:36         ` Ingo Molnar
  2009-11-13  7:36         ` Ingo Molnar
  1 sibling, 0 replies; 44+ messages in thread
From: Ingo Molnar @ 2009-11-13  7:36 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-kernel, ACPI Devel Maling List, H. Peter Anvin,
	Thomas Gleixner, Yinghai Lu, pm list


* Rafael J. Wysocki <rjw@sisk.pl> wrote:

> On Thursday 12 November 2009, Pavel Machek wrote:
> > On Tue 2009-11-10 18:27:23, Yinghai Lu wrote:
> > > 
> > > try to find_e820_area/reserve_early, and call acpi_reserve_memory early
> > > 
> > > to get area is below 1M
> > 
> > Does it fix anything? I can't tell from the changelog...
> 
> Yes, it does.  If the area is above 1M, we can't run real mode code 
> from it.
> 
> This matters for NUMA machines supporting S3 (yes, there are a few 
> models out there).

It might also matter in more exotic kernels that might do some large 
allocations. (say 'nopentium' can cause +1MB/+2MB of kernel page table 
allocations per one GB of RAM)

Physical constraints to allocations (which this is) should be expressed 
early and with high priority, to make sure they can be met.

	Ingo

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-13  7:36         ` Ingo Molnar
@ 2009-11-13  8:04           ` H. Peter Anvin
  2009-11-13  8:12             ` Ingo Molnar
  2009-11-13  8:12             ` Ingo Molnar
  2009-11-13  8:04           ` H. Peter Anvin
  1 sibling, 2 replies; 44+ messages in thread
From: H. Peter Anvin @ 2009-11-13  8:04 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Rafael J. Wysocki, Pavel Machek, Yinghai Lu, Thomas Gleixner,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list

On 11/12/2009 11:36 PM, Ingo Molnar wrote:
> 
> Physical constraints to allocations (which this is) should be expressed 
> early and with high priority, to make sure they can be met.
> 

Indeed, and in this case this means before bootmem allocator initialization.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-13  7:36         ` Ingo Molnar
  2009-11-13  8:04           ` H. Peter Anvin
@ 2009-11-13  8:04           ` H. Peter Anvin
  1 sibling, 0 replies; 44+ messages in thread
From: H. Peter Anvin @ 2009-11-13  8:04 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, ACPI Devel Maling List, Thomas Gleixner,
	Yinghai Lu, pm list

On 11/12/2009 11:36 PM, Ingo Molnar wrote:
> 
> Physical constraints to allocations (which this is) should be expressed 
> early and with high priority, to make sure they can be met.
> 

Indeed, and in this case this means before bootmem allocator initialization.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-13  8:04           ` H. Peter Anvin
@ 2009-11-13  8:12             ` Ingo Molnar
  2009-11-13  8:12             ` Ingo Molnar
  1 sibling, 0 replies; 44+ messages in thread
From: Ingo Molnar @ 2009-11-13  8:12 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Rafael J. Wysocki, Pavel Machek, Yinghai Lu, Thomas Gleixner,
	Len Brown, linux-kernel, ACPI Devel Maling List, pm list


* H. Peter Anvin <hpa@zytor.com> wrote:

> On 11/12/2009 11:36 PM, Ingo Molnar wrote:
> > 
> > Physical constraints to allocations (which this is) should be expressed 
> > early and with high priority, to make sure they can be met.
> > 
> 
> Indeed, and in this case this means before bootmem allocator initialization.

The other advantage of Yinghai's patch is that it removes a bootmem 
usage from x86, which moves us a bit forward on the road to remove the 
bootmem allocator altogether and go from early allocators to slab 
straight away.

	Ingo

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

* Re: [PATCH] x86: make sure wakeup code is below 1M -v2
  2009-11-13  8:04           ` H. Peter Anvin
  2009-11-13  8:12             ` Ingo Molnar
@ 2009-11-13  8:12             ` Ingo Molnar
  1 sibling, 0 replies; 44+ messages in thread
From: Ingo Molnar @ 2009-11-13  8:12 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: linux-kernel, ACPI Devel Maling List, Thomas Gleixner,
	Yinghai Lu, pm list


* H. Peter Anvin <hpa@zytor.com> wrote:

> On 11/12/2009 11:36 PM, Ingo Molnar wrote:
> > 
> > Physical constraints to allocations (which this is) should be expressed 
> > early and with high priority, to make sure they can be met.
> > 
> 
> Indeed, and in this case this means before bootmem allocator initialization.

The other advantage of Yinghai's patch is that it removes a bootmem 
usage from x86, which moves us a bit forward on the road to remove the 
bootmem allocator altogether and go from early allocators to slab 
straight away.

	Ingo

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

end of thread, other threads:[~2009-11-13  8:12 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-09  8:51 [RFC PATCH] x86: make sure wakeup code is below 1M Yinghai Lu
2009-11-09 12:15 ` Rafael J. Wysocki
2009-11-11  2:27   ` [PATCH] x86: make sure wakeup code is below 1M -v2 Yinghai Lu
2009-11-11  7:48     ` Ingo Molnar
2009-11-11  7:48       ` Ingo Molnar
2009-11-11  7:57       ` H. Peter Anvin
2009-11-11  7:57       ` H. Peter Anvin
2009-11-11  9:56       ` Rafael J. Wysocki
2009-11-11  9:56       ` Rafael J. Wysocki
2009-11-11  7:48     ` Ingo Molnar
2009-11-11  9:12     ` ykzhao
2009-11-11 19:05       ` Yinghai Lu
2009-11-11 19:05       ` Yinghai Lu
2009-11-12  1:17         ` ykzhao
2009-11-12  1:17         ` ykzhao
2009-11-12  3:12           ` Yinghai Lu
2009-11-12  3:12           ` Yinghai Lu
2009-11-12  3:37             ` ykzhao
2009-11-12  5:21               ` Yinghai Lu
2009-11-12  5:21               ` Yinghai Lu
2009-11-12  7:14                 ` ykzhao
2009-11-12  7:14                 ` ykzhao
2009-11-12  7:20                   ` H. Peter Anvin
2009-11-12  7:20                   ` H. Peter Anvin
2009-11-12  7:43                 ` ykzhao
2009-11-12  7:43                 ` ykzhao
2009-11-12  3:37             ` ykzhao
2009-11-11  9:12     ` ykzhao
2009-11-11 20:30     ` [tip:x86/mm] x86: Make sure wakeup trampoline code is below 1MB tip-bot for Yinghai Lu
2009-11-11 20:30     ` tip-bot for Yinghai Lu
2009-11-12  7:36     ` [PATCH] x86: make sure wakeup code is below 1M -v2 Pavel Machek
2009-11-12  7:36       ` Pavel Machek
2009-11-12 19:25       ` Yinghai Lu
2009-11-12 19:25       ` Yinghai Lu
2009-11-12 19:32       ` Rafael J. Wysocki
2009-11-12 19:32       ` Rafael J. Wysocki
2009-11-13  7:36         ` Ingo Molnar
2009-11-13  7:36         ` Ingo Molnar
2009-11-13  8:04           ` H. Peter Anvin
2009-11-13  8:12             ` Ingo Molnar
2009-11-13  8:12             ` Ingo Molnar
2009-11-13  8:04           ` H. Peter Anvin
2009-11-11  2:27   ` Yinghai Lu
2009-11-09 12:15 ` [RFC PATCH] x86: make sure wakeup code is below 1M Rafael J. Wysocki

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.