Commit 0a7b35cb18c52d651f6ed9cd59edc979200ab880
Committed by
Linus Torvalds
1 parent
70e840499a
Exists in
master
and in
20 other branches
[PATCH] Add retain_initrd boot option
Add retain_initrd option to control freeing of initrd memory after extraction. By default, free memory as previously. The first boot will need to hold a copy of the in memory fs for the second boot. This image can be large (much larger than the kernel), hence we can save time when the memory loader is slow. Also, it reduces the memory footprint while extracting the first boot since you don't need another copy of the fs. Signed-off-by: Michael Neuling <mikey@neuling.org> Cc: "Randy.Dunlap" <rdunlap@xenotime.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 2 changed files with 18 additions and 1 deletions Side-by-side Diff
Documentation/kernel-parameters.txt
... | ... | @@ -1396,6 +1396,8 @@ |
1396 | 1396 | in <PAGE_SIZE> units (needed only for swap files). |
1397 | 1397 | See Documentation/power/swsusp-and-swap-files.txt |
1398 | 1398 | |
1399 | + retain_initrd [RAM] Keep initrd memory after extraction | |
1400 | + | |
1399 | 1401 | rhash_entries= [KNL,NET] |
1400 | 1402 | Set number of hash buckets for route cache |
1401 | 1403 |
init/initramfs.c
... | ... | @@ -491,6 +491,17 @@ |
491 | 491 | return message; |
492 | 492 | } |
493 | 493 | |
494 | +static int __initdata do_retain_initrd; | |
495 | + | |
496 | +static int __init retain_initrd_param(char *str) | |
497 | +{ | |
498 | + if (*str) | |
499 | + return 0; | |
500 | + do_retain_initrd = 1; | |
501 | + return 1; | |
502 | +} | |
503 | +__setup("retain_initrd", retain_initrd_param); | |
504 | + | |
494 | 505 | extern char __initramfs_start[], __initramfs_end[]; |
495 | 506 | #ifdef CONFIG_BLK_DEV_INITRD |
496 | 507 | #include <linux/initrd.h> |
497 | 508 | |
... | ... | @@ -501,7 +512,11 @@ |
501 | 512 | #ifdef CONFIG_KEXEC |
502 | 513 | unsigned long crashk_start = (unsigned long)__va(crashk_res.start); |
503 | 514 | unsigned long crashk_end = (unsigned long)__va(crashk_res.end); |
515 | +#endif | |
516 | + if (do_retain_initrd) | |
517 | + goto skip; | |
504 | 518 | |
519 | +#ifdef CONFIG_KEXEC | |
505 | 520 | /* |
506 | 521 | * If the initrd region is overlapped with crashkernel reserved region, |
507 | 522 | * free only memory that is not part of crashkernel region. |
... | ... | @@ -519,7 +534,7 @@ |
519 | 534 | } else |
520 | 535 | #endif |
521 | 536 | free_initrd_mem(initrd_start, initrd_end); |
522 | - | |
537 | +skip: | |
523 | 538 | initrd_start = 0; |
524 | 539 | initrd_end = 0; |
525 | 540 | } |