summaryrefslogtreecommitdiff
path: root/kexec/arch
diff options
context:
space:
mode:
authorMichael Holzheu <holzheu@linux.vnet.ibm.com>2015-10-30 16:02:04 +0100
committerSimon Horman <horms@verge.net.au>2015-11-09 10:58:53 +0900
commit95741713e790fa6bde7780bbfb772ad88e81a744 (patch)
treeee32757b0773ee921605002ecfb88d736b189edb /kexec/arch
parent8d8c6bcee59306482d86d7c524f511a08ad02de6 (diff)
kexec/s390x: use mmap instead of read for slurp_file()
The slurp_fd() function allocates memory and uses the read() system call. This results in double memory consumption for image and initrd: 1) Memory allocated in user space by the kexec tool 2) Memory allocated in kernel by the kexec() system call The following illustrates the use case that we have on s390x: 1) Boot a 4 GB Linux system 2) Copy kernel and 1,5 GB ramdisk from external source into tmpfs (ram) 3) Use kexec to boot kernel with ramdisk Therefore for kexec runtime we need: 1,5 GB (tmpfs) + 1,5 GB (kexec malloc) + 1,5 GB (kernel memory) = 4,5 GB This patch introduces slurp_file_mmap() which for "normal" files uses mmap() instead of malloc()/read(). This reduces the runtime memory consumption of the kexec tool as follows: 1,5 GB (tmpfs) + 1,5 GB (kernel memory) = 3 GB Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Reviewed-by: Dave Young <dyoung@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/arch')
-rw-r--r--kexec/arch/s390/kexec-image.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kexec/arch/s390/kexec-image.c b/kexec/arch/s390/kexec-image.c
index be1e0f8..0c8937b 100644
--- a/kexec/arch/s390/kexec-image.c
+++ b/kexec/arch/s390/kexec-image.c
@@ -101,7 +101,7 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,
* we load the ramdisk directly behind the image with 1 MiB alignment.
*/
if (ramdisk) {
- rd_buffer = slurp_file(ramdisk, &ramdisk_len);
+ rd_buffer = slurp_file_mmap(ramdisk, &ramdisk_len);
if (rd_buffer == NULL) {
fprintf(stderr, "Could not read ramdisk.\n");
return -1;