All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] powerpc/fadump: reserve memory at an offset closer to bottom of RAM
@ 2017-03-16 21:05 Hari Bathini
  2017-03-16 21:05 ` [PATCH v2 2/2] powerpc/fadump: update fadump documentation Hari Bathini
  2017-04-03 10:13 ` [v2, 1/2] powerpc/fadump: reserve memory at an offset closer to bottom of RAM Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Hari Bathini @ 2017-03-16 21:05 UTC (permalink / raw)
  To: Mahesh J Salgaonkar, linuxppc-dev, Michael Ellerman

Currently, the area to preserve boot memory is reserved at the top of
RAM. This leaves fadump vulnerable to memory hot-remove operations. As
memory for fadump has to be reserved early in the boot process, fadump
can't be registered after a memory hot-remove operation. Though this
problem can't be eleminated completely, the impact can be minimized by
reserving memory at an offset closer to bottom of the RAM. The offset
for fadump memory reservation can be any value greater than fadump boot
memory size.

Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
---

Changes from v1:
* Finding the offset based on memory holes/availability
* Improved error checking


 arch/powerpc/kernel/fadump.c |   33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 8ff0dd4..33b2da3 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -319,15 +319,34 @@ int __init fadump_reserve_mem(void)
 		pr_debug("fadumphdr_addr = %p\n",
 				(void *) fw_dump.fadumphdr_addr);
 	} else {
-		/* Reserve the memory at the top of memory. */
 		size = get_fadump_area_size();
-		base = memory_boundary - size;
-		memblock_reserve(base, size);
-		printk(KERN_INFO "Reserved %ldMB of memory at %ldMB "
-				"for firmware-assisted dump\n",
-				(unsigned long)(size >> 20),
-				(unsigned long)(base >> 20));
+
+		/*
+		 * Reserve memory at an offset closer to bottom of the RAM to
+		 * minimize the impact of memory hot-remove operation. We can't
+		 * use memblock_find_in_range() here since it doesn't allocate
+		 * from bottom to top.
+		 */
+		for (base = fw_dump.boot_memory_size;
+		     base <= (memory_boundary - size);
+		     base += size) {
+			if (memblock_is_region_memory(base, size) &&
+			    !memblock_is_region_reserved(base, size))
+				break;
+		}
+		if ((base > (memory_boundary - size)) ||
+		    memblock_reserve(base, size)) {
+			pr_err("Failed to reserve memory\n");
+			return 0;
+		}
+
+		pr_info("Reserved %ldMB of memory at %ldMB for firmware-"
+			"assisted dump (System RAM: %ldMB)\n",
+			(unsigned long)(size >> 20),
+			(unsigned long)(base >> 20),
+			(unsigned long)(memblock_phys_mem_size() >> 20));
 	}
+
 	fw_dump.reserve_dump_area_start = base;
 	fw_dump.reserve_dump_area_size = size;
 	return 1;

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

* [PATCH v2 2/2] powerpc/fadump: update fadump documentation
  2017-03-16 21:05 [PATCH v2 1/2] powerpc/fadump: reserve memory at an offset closer to bottom of RAM Hari Bathini
@ 2017-03-16 21:05 ` Hari Bathini
  2017-04-03 10:13 ` [v2, 1/2] powerpc/fadump: reserve memory at an offset closer to bottom of RAM Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Hari Bathini @ 2017-03-16 21:05 UTC (permalink / raw)
  To: Mahesh J Salgaonkar, linuxppc-dev, Michael Ellerman

With the unnecessary restriction to reserve memory for fadump at the
top of RAM forgone, update the documentation accordingly.

Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
---
 Documentation/powerpc/firmware-assisted-dump.txt |   34 +++++++++++-----------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/Documentation/powerpc/firmware-assisted-dump.txt b/Documentation/powerpc/firmware-assisted-dump.txt
index 3007bc9..19b1e3d 100644
--- a/Documentation/powerpc/firmware-assisted-dump.txt
+++ b/Documentation/powerpc/firmware-assisted-dump.txt
@@ -105,21 +105,21 @@ memory is held.
 
 If there is no waiting dump data, then only the memory required
 to hold CPU state, HPTE region, boot memory dump and elfcore
-header, is reserved at the top of memory (see Fig. 1). This area
-is *not* released: this region will be kept permanently reserved,
-so that it can act as a receptacle for a copy of the boot memory
-content in addition to CPU state and HPTE region, in the case a
-crash does occur.
+header, is usually reserved at an offset greater than boot memory
+size (see Fig. 1). This area is *not* released: this region will
+be kept permanently reserved, so that it can act as a receptacle
+for a copy of the boot memory content in addition to CPU state
+and HPTE region, in the case a crash does occur.
 
   o Memory Reservation during first kernel
 
-  Low memory                                        Top of memory
+  Low memory                                         Top of memory
   0      boot memory size                                       |
-  |           |                       |<--Reserved dump area -->|
-  V           V                       |   Permanent Reservation V
-  +-----------+----------/ /----------+---+----+-----------+----+
-  |           |                       |CPU|HPTE|  DUMP     |ELF |
-  +-----------+----------/ /----------+---+----+-----------+----+
+  |           |                |<--Reserved dump area -->|      |
+  V           V                |   Permanent Reservation |      V
+  +-----------+----------/ /---+---+----+-----------+----+------+
+  |           |                |CPU|HPTE|  DUMP     |ELF |      |
+  +-----------+----------/ /---+---+----+-----------+----+------+
         |                                           ^
         |                                           |
         \                                           /
@@ -135,12 +135,12 @@ crash does occur.
   0      boot memory size                                       |
   |           |<------------- Reserved dump area ----------- -->|
   V           V                                                 V
-  +-----------+----------/ /----------+---+----+-----------+----+
-  |           |                       |CPU|HPTE|  DUMP     |ELF |
-  +-----------+----------/ /----------+---+----+-----------+----+
-        |                                                    |
-        V                                                    V
-   Used by second                                    /proc/vmcore
+  +-----------+----------/ /---+---+----+-----------+----+------+
+  |           |                |CPU|HPTE|  DUMP     |ELF |      |
+  +-----------+----------/ /---+---+----+-----------+----+------+
+        |                                              |
+        V                                              V
+   Used by second                                /proc/vmcore
    kernel to boot
                    Fig. 2
 

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

* Re: [v2, 1/2] powerpc/fadump: reserve memory at an offset closer to bottom of RAM
  2017-03-16 21:05 [PATCH v2 1/2] powerpc/fadump: reserve memory at an offset closer to bottom of RAM Hari Bathini
  2017-03-16 21:05 ` [PATCH v2 2/2] powerpc/fadump: update fadump documentation Hari Bathini
@ 2017-04-03 10:13 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2017-04-03 10:13 UTC (permalink / raw)
  To: Hari Bathini, Mahesh J Salgaonkar, linuxppc-dev

On Thu, 2017-03-16 at 21:05:26 UTC, Hari Bathini wrote:
> Currently, the area to preserve boot memory is reserved at the top of
> RAM. This leaves fadump vulnerable to memory hot-remove operations. As
> memory for fadump has to be reserved early in the boot process, fadump
> can't be registered after a memory hot-remove operation. Though this
> problem can't be eleminated completely, the impact can be minimized by
> reserving memory at an offset closer to bottom of the RAM. The offset
> for fadump memory reservation can be any value greater than fadump boot
> memory size.
> 
> Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/f6e6bedb773118713a8eb3736a4c99

cheers

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

end of thread, other threads:[~2017-04-03 10:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 21:05 [PATCH v2 1/2] powerpc/fadump: reserve memory at an offset closer to bottom of RAM Hari Bathini
2017-03-16 21:05 ` [PATCH v2 2/2] powerpc/fadump: update fadump documentation Hari Bathini
2017-04-03 10:13 ` [v2, 1/2] powerpc/fadump: reserve memory at an offset closer to bottom of RAM Michael Ellerman

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.