What frees the `.init.ramfs` image after it is unpacked into the `rootfs`?
Clash Royale CLAN TAG#URR8PPP
Under the old initrd
system, Linux used to free the initrd
image. This was traced on the console:
Freeing initrd memory: xxxxk freed.
What this referred to was actually releasing the memory occupied by the original compressed image. The live, mounted filesystem was released via unmounting (via pivot_root
to the replacement root).
Under initramfs
, the filesystem is released by a recursive removal using some utility like switch_root
, and is never unmounted. I understand that, but where is the original image (the compressed .cpio
archive) freed?
I'm looking at init/initramfs.c (populate_rootfs)
and see that in fact initramfs
can unpack data from either __initramfs_start
or initrd_start
, or even both! The initrd
area is freed by free_initrd()
, but there is no logic here for doing the analogous freeing for the memory starting at __initramfs_start
.
Can someone shed some light on how this memory is freed? Or else confirm that it's not freed? Is it in a section that gets discarded along with other unused memory?
I added some diagnostics which show that __initramfs_start
is outside of the unused memory that is freed. This is on an ARM embedded system:
[ 1.241857] Freeing unused kernel memory: 3240K [c0c01000, c0f2b000)
[ 1.241874] Initramfs image starts at: e7fddef0
But then, if I look at the linker script, I see that the INITRAMFS
is placed between __init_start
and __init_end
symbols, so maybe this discrepancy is due to some run-time relocation? The size is about right: the original compressed image is 2958550 bytes, which could reasonably account for the bulk of this reported 3240K.
linux-kernel initramfs arch-arm
add a comment |
Under the old initrd
system, Linux used to free the initrd
image. This was traced on the console:
Freeing initrd memory: xxxxk freed.
What this referred to was actually releasing the memory occupied by the original compressed image. The live, mounted filesystem was released via unmounting (via pivot_root
to the replacement root).
Under initramfs
, the filesystem is released by a recursive removal using some utility like switch_root
, and is never unmounted. I understand that, but where is the original image (the compressed .cpio
archive) freed?
I'm looking at init/initramfs.c (populate_rootfs)
and see that in fact initramfs
can unpack data from either __initramfs_start
or initrd_start
, or even both! The initrd
area is freed by free_initrd()
, but there is no logic here for doing the analogous freeing for the memory starting at __initramfs_start
.
Can someone shed some light on how this memory is freed? Or else confirm that it's not freed? Is it in a section that gets discarded along with other unused memory?
I added some diagnostics which show that __initramfs_start
is outside of the unused memory that is freed. This is on an ARM embedded system:
[ 1.241857] Freeing unused kernel memory: 3240K [c0c01000, c0f2b000)
[ 1.241874] Initramfs image starts at: e7fddef0
But then, if I look at the linker script, I see that the INITRAMFS
is placed between __init_start
and __init_end
symbols, so maybe this discrepancy is due to some run-time relocation? The size is about right: the original compressed image is 2958550 bytes, which could reasonably account for the bulk of this reported 3240K.
linux-kernel initramfs arch-arm
add a comment |
Under the old initrd
system, Linux used to free the initrd
image. This was traced on the console:
Freeing initrd memory: xxxxk freed.
What this referred to was actually releasing the memory occupied by the original compressed image. The live, mounted filesystem was released via unmounting (via pivot_root
to the replacement root).
Under initramfs
, the filesystem is released by a recursive removal using some utility like switch_root
, and is never unmounted. I understand that, but where is the original image (the compressed .cpio
archive) freed?
I'm looking at init/initramfs.c (populate_rootfs)
and see that in fact initramfs
can unpack data from either __initramfs_start
or initrd_start
, or even both! The initrd
area is freed by free_initrd()
, but there is no logic here for doing the analogous freeing for the memory starting at __initramfs_start
.
Can someone shed some light on how this memory is freed? Or else confirm that it's not freed? Is it in a section that gets discarded along with other unused memory?
I added some diagnostics which show that __initramfs_start
is outside of the unused memory that is freed. This is on an ARM embedded system:
[ 1.241857] Freeing unused kernel memory: 3240K [c0c01000, c0f2b000)
[ 1.241874] Initramfs image starts at: e7fddef0
But then, if I look at the linker script, I see that the INITRAMFS
is placed between __init_start
and __init_end
symbols, so maybe this discrepancy is due to some run-time relocation? The size is about right: the original compressed image is 2958550 bytes, which could reasonably account for the bulk of this reported 3240K.
linux-kernel initramfs arch-arm
Under the old initrd
system, Linux used to free the initrd
image. This was traced on the console:
Freeing initrd memory: xxxxk freed.
What this referred to was actually releasing the memory occupied by the original compressed image. The live, mounted filesystem was released via unmounting (via pivot_root
to the replacement root).
Under initramfs
, the filesystem is released by a recursive removal using some utility like switch_root
, and is never unmounted. I understand that, but where is the original image (the compressed .cpio
archive) freed?
I'm looking at init/initramfs.c (populate_rootfs)
and see that in fact initramfs
can unpack data from either __initramfs_start
or initrd_start
, or even both! The initrd
area is freed by free_initrd()
, but there is no logic here for doing the analogous freeing for the memory starting at __initramfs_start
.
Can someone shed some light on how this memory is freed? Or else confirm that it's not freed? Is it in a section that gets discarded along with other unused memory?
I added some diagnostics which show that __initramfs_start
is outside of the unused memory that is freed. This is on an ARM embedded system:
[ 1.241857] Freeing unused kernel memory: 3240K [c0c01000, c0f2b000)
[ 1.241874] Initramfs image starts at: e7fddef0
But then, if I look at the linker script, I see that the INITRAMFS
is placed between __init_start
and __init_end
symbols, so maybe this discrepancy is due to some run-time relocation? The size is about right: the original compressed image is 2958550 bytes, which could reasonably account for the bulk of this reported 3240K.
linux-kernel initramfs arch-arm
linux-kernel initramfs arch-arm
edited Feb 6 at 23:32
Kaz
asked Feb 6 at 23:11
KazKaz
4,64811532
4,64811532
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Well, I've confirmed that the memory gets freed by the following experiment. I added a few megabytes of random junk into the initramfs
, built the kernel and booted. The Freeing unused kernel memory
reported size increased by about the size of that junk. Furthermore, this bloat made no difference to the free memory seen just after boot via free
and /proc/meminfo
.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499180%2fwhat-frees-the-init-ramfs-image-after-it-is-unpacked-into-the-rootfs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Well, I've confirmed that the memory gets freed by the following experiment. I added a few megabytes of random junk into the initramfs
, built the kernel and booted. The Freeing unused kernel memory
reported size increased by about the size of that junk. Furthermore, this bloat made no difference to the free memory seen just after boot via free
and /proc/meminfo
.
add a comment |
Well, I've confirmed that the memory gets freed by the following experiment. I added a few megabytes of random junk into the initramfs
, built the kernel and booted. The Freeing unused kernel memory
reported size increased by about the size of that junk. Furthermore, this bloat made no difference to the free memory seen just after boot via free
and /proc/meminfo
.
add a comment |
Well, I've confirmed that the memory gets freed by the following experiment. I added a few megabytes of random junk into the initramfs
, built the kernel and booted. The Freeing unused kernel memory
reported size increased by about the size of that junk. Furthermore, this bloat made no difference to the free memory seen just after boot via free
and /proc/meminfo
.
Well, I've confirmed that the memory gets freed by the following experiment. I added a few megabytes of random junk into the initramfs
, built the kernel and booted. The Freeing unused kernel memory
reported size increased by about the size of that junk. Furthermore, this bloat made no difference to the free memory seen just after boot via free
and /proc/meminfo
.
edited Feb 7 at 20:43
answered Feb 7 at 0:09
KazKaz
4,64811532
4,64811532
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499180%2fwhat-frees-the-init-ramfs-image-after-it-is-unpacked-into-the-rootfs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown