Linux, kernel 5.4, mysterious reserved ram - Page 1
Forum section: electronics / general

author: DiTBho
author_rank: Super Contributor
timestamp: July 29, 2021, 01:36:14 pm
content: I am working with Kernel 5.4, profiled for a low memory system with only 32MB soldered ram and I managed to turn off all the features that it doesn't need.However, when the kernel boots ... it reserves 8Mbyte of ram, and it's not clear for whatCode:Memory: 32768K physical <--------------- 32MBMemory: 24628K free <------------------ only 24Mbyte availableMemory: 5913K kernel codeMemory: 193K rwdataMemory: 1312K rodataMemory: 184K initMemory: 184K bssMemory: 8140K reserved <---------------- reserved to what?!?Memory: 0K cma-reservedThere is no framebuffer. What is this reserved memory? How can it be reduced?

author: aix
author_rank: Regular Contributor
timestamp: July 30, 2021, 07:12:15 am
content: Is this related to/proc/sys/vm/min_free_kbytes?https://linuxhint.com/vm_min_free_kbytes_sysctl/

author: magic
author_rank: Super Contributor
timestamp: July 30, 2021, 08:20:22 am
content: Most likely by the firmware.Code:[ 0.000000] x86/fpu: x87 FPU will use FXSAVE[ 0.000000] e820: BIOS-provided physical RAM map:[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable[ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved[ 0.000000] BIOS-e820: [mem 0x00000000000e6000-0x00000000000fffff] reserved[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000dfe8ffff] usable[ 0.000000] BIOS-e820: [mem 0x00000000dfe90000-0x00000000dfe9dfff] ACPI data[ 0.000000] BIOS-e820: [mem 0x00000000dfe9e000-0x00000000dfedffff] ACPI NVS[ 0.000000] BIOS-e820: [mem 0x00000000dfee0000-0x00000000dfefffff] reserved[ 0.000000] BIOS-e820: [mem 0x00000000fff00000-0x00000000ffffffff] reserved[ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x0000000217ffffff] usable[ 0.000000] NX (Execute Disable) protection: active

author: DiTBho
author_rank: Super Contributor
timestamp: July 30, 2021, 08:52:39 am
content: Quote from: aix on July 30, 2021, 07:12:15 amCode:#cat /proc/sys/vm/min_free_kbytes627it doesn't seem so

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 30, 2021, 05:58:59 pm
content: You'd probably have to configure (and compile yourself) the kernel to modify the amount of reserved memory. Apart from possible use by a GPU (which isn't your case here), it can also just be reserved memory for other device drivers.You could have a look there:https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txtI'm not familiar enough with this to help more than that though. But I would expect 8 MBytes to be a reasonable amout of reserved memory for a desktop computer these days, but certainly not for a small system with just 32 MBytes of RAM. So yeah, you may have to dig a little to figure out how to configure this.

author: Monkeh
author_rank: Super Contributor
timestamp: July 30, 2021, 07:07:04 pm
content: Quote from: DiTBho on July 29, 2021, 01:36:14 pmQuoteThis accounts for the majority. Where do you expect the kernel to go, exactly?

author: DiTBho
author_rank: Super Contributor
timestamp: July 30, 2021, 07:11:47 pm
content: Quote from: SiliconWizard on July 30, 2021, 05:58:59 pmI am already configuring and compiling the kernel by myself.There is no GPU, no framebuffer.

author: DiTBho
author_rank: Super Contributor
timestamp: July 30, 2021, 07:25:34 pm
content: Quote from: Monkeh on July 30, 2021, 07:07:04 pmIn that snapshot, it reserves 8Mbyte while the binary size of kernel is 6Mbyte.+2Mbyte of available ram would be precious to contain second running services, and since I can't modify the hardware, I am doing a lot of things to free more ram.For instance I hacked the kernel and removed a lot of lines of dead/unused code, and recompiled everything with -Os. I also removed the FPU emulation, saving more Kbyte.I need static kernel, I cannot use loadable modules (there is a reason, long story), anyway the new kernel is about 3.9Mbyte of ram instead of the 9.5Mbyte of the fist attempt.3.9Mbyte is << power of 2, but still I have 8Mbyte of reserved ram, and it's not clear for what

author: MarginallyStable
author_rank: Regular Contributor
timestamp: July 31, 2021, 05:33:21 am
content: That is the memory reserved for kernel use. I.E. Code, data, bss, page tables, etc.