File kdump-calibrate-boot-requirements.patch of Package kdump
From: Petr Tesarik <ptesarik@suse.com>
Date: Thu Nov 5 11:20:54 2015 +0100
Subject: Ensure that high crash kernel area covers at least boot requirements
References: bsc#953732
Patch-mainline: v.0.8.16
Git-commit: 2c06f099124ff6f2e5275b4068984b99e2ebbfd2
The total memory requirements at boot are temporarily higher, because
kernel init sections and initrd are present. At this point, the kernel
starts unpacking initramfs. Although this data may be allocated
anywhere, there isn't enough space in the Normal zone, so the kernel
must allocate a large part of the unpacked root file system in DMA32.
Of course, this data stays there, significantly reducing available
DMA32 memory.
Note that this increases total memory reserved for crash kernel. The
ideal solution would be to load init data into low memory (where it
could be freed afterwards), but that's not worth the effort, because
systems with little memory (<4G), where a few additional megabytes
might matter, do not make any high allocations.
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
kdumptool/calibrate.cc | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
--- a/kdumptool/calibrate.cc
+++ b/kdumptool/calibrate.cc
@@ -228,6 +228,13 @@ static inline unsigned long s390x_align_
// for overflow, DMA buffers, etc.
#define MINLOW_KB MB(64 + 8)
+// Default (pessimistic) boot-time requirements.
+// This value is used if exact calculation fails.
+#define DEF_BOOTSIZE \
+ (KERNEL_KB + \
+ INIT_KB + INIT_NET_KB + \
+ ((INIT_KB + INIT_NET_KB) * INITRD_COMPRESS) / 100)
+
using std::cout;
using std::endl;
using std::ifstream;
@@ -885,6 +892,7 @@ void Calibrate::execute()
unsigned long required, prev;
unsigned long pagesize = sysconf(_SC_PAGESIZE);
unsigned long memtotal = shr_round_up(mm.total(), 10);
+ unsigned long bootsize = DEF_BOOTSIZE;
try {
Configuration *config = Configuration::config();
@@ -898,7 +906,7 @@ void Calibrate::execute()
if (needsnet)
ramfs += INIT_NET_KB;
unsigned long initrd = (ramfs * INITRD_COMPRESS) / 100;
- unsigned long bootsize = KERNEL_KB + initrd + ramfs;
+ bootsize = KERNEL_KB + initrd + ramfs;
Debug::debug()->dbg("Memory needed at boot: %lu KiB", bootsize);
// Run-time kernel requirements
@@ -1017,6 +1025,8 @@ void Calibrate::execute()
} else {
low = MINLOW_KB;
high = (required > low ? required - low : 0);
+ if (high < bootsize)
+ high = bootsize;
}
cout << "Low: " << shr_round_up(low, 10) << endl;
cout << "High: " << shr_round_up(high, 10) << endl;