Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] makedumpfile: Use max_pfn from mem_map array
@ 2014-03-25 16:14 Michael Holzheu
  2014-03-26  9:55 ` HATAYAMA Daisuke
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Holzheu @ 2014-03-25 16:14 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: d.hatayama, kexec

There are dump mechansims like s390 stand-alond dump or KVM virsh dump
that write the physical memory of a machine and are not aware of the
dumped operating system. For those dump mechanisms it can happen
that for the Linux kernel of the dumped system the "mem=" kernel
parameter has been specified. In this case max_mapnr that makedumpfile
gets from the ELF header can be bigger than the maximum page frame number
used by the dumped Linux kernel.

With this patch makedumpfile gets the maximum page frame number from
the mem_map array and adjusts info->max_mapnr if this value is smaller
than the value calculated from the ELF header.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
---
 makedumpfile.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -2829,7 +2829,8 @@ get_mem_map_without_mm(void)
 int
 get_mem_map(void)
 {
-	int ret;
+	unsigned long max_pfn = 0;
+	int ret, i;
 
 	switch (get_mem_type()) {
 	case SPARSEMEM:
@@ -2861,6 +2862,17 @@ get_mem_map(void)
 		ret = FALSE;
 		break;
 	}
+	/*
+	 * Adjust "max_mapnr" for the case that Linux uses less memory
+	 * than is dumped. For example when "mem=" has been used for the
+	 * dumped system.
+	 */
+	for (i = 0; i < info->num_mem_map; i++) {
+		if (info->mem_map_data[i].mem_map == NOT_MEMMAP_ADDR)
+			continue;
+		max_pfn = MAX(max_pfn, info->mem_map_data[i].pfn_end);
+	}
+	info->max_mapnr = MIN(info->max_mapnr, max_pfn);
 	return ret;
 }
 


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

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

end of thread, other threads:[~2014-04-03  2:43 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-25 16:14 [PATCH 2/2] makedumpfile: Use max_pfn from mem_map array Michael Holzheu
2014-03-26  9:55 ` HATAYAMA Daisuke
2014-03-26 17:54   ` Michael Holzheu
2014-03-27  5:19     ` Atsushi Kumagai
2014-03-27 13:54       ` Michael Holzheu
2014-03-28 11:00         ` Petr Tesarik
2014-03-28 15:54           ` Michael Holzheu
2014-03-28 16:46           ` Michael Holzheu
2014-03-28 16:53             ` Petr Tesarik
2014-03-31  9:48               ` Atsushi Kumagai
2014-03-31 10:37                 ` Petr Tesarik
2014-04-01  5:06                   ` Atsushi Kumagai
2014-04-01  8:11                     ` Petr Tesarik
2014-04-01  9:20                     ` Michael Holzheu
2014-04-03  2:38                       ` Atsushi Kumagai
2014-03-31 12:59                 ` Michael Holzheu
2014-03-31 10:27             ` Petr Tesarik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox