Author Topic: Linux, kernel 5.4, mysterious reserved ram  (Read 929 times)

0 Members and 1 Guest are viewing this topic.

Online DiTBho

  • Frequent Contributor
  • **
  • Posts: 964
  • Country: gb
Linux, kernel 5.4, mysterious reserved ram
« on: July 29, 2021, 01:36:14 pm »
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 what
Code: [Select]
Memory: 32768K physical <--------------- 32MB
Memory: 24628K free  <------------------ only 24Mbyte available
Memory: 5913K kernel code
Memory: 193K rwdata
Memory: 1312K rodata
Memory: 184K init
Memory: 184K bss
Memory: 8140K reserved <---------------- reserved to what?!?
Memory: 0K cma-reserved

There is no framebuffer. What is this reserved memory? How can it be reduced?  :-//
 

Offline aix

  • Regular Contributor
  • *
  • Posts: 145
  • Country: gb
Re: Linux, kernel 5.4, mysterious reserved ram
« Reply #1 on: July 30, 2021, 07:12:15 am »
Is this related to /proc/sys/vm/min_free_kbytes?

https://linuxhint.com/vm_min_free_kbytes_sysctl/
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 3692
  • Country: pl
Re: Linux, kernel 5.4, mysterious reserved ram
« Reply #2 on: July 30, 2021, 08:20:22 am »
Most likely by the firmware.
Code: [Select]
[    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
 

Online DiTBho

  • Frequent Contributor
  • **
  • Posts: 964
  • Country: gb
Re: Linux, kernel 5.4, mysterious reserved ram
« Reply #3 on: July 30, 2021, 08:52:39 am »
Is this related to /proc/sys/vm/min_free_kbytes?

Code: [Select]
#cat /proc/sys/vm/min_free_kbytes
627

it doesn't seem so  :-//
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 7316
  • Country: fr
Re: Linux, kernel 5.4, mysterious reserved ram
« Reply #4 on: July 30, 2021, 05:58:59 pm »
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.txt
I'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.
 

Offline Monkeh

  • Super Contributor
  • ***
  • Posts: 7234
  • Country: gb
Re: Linux, kernel 5.4, mysterious reserved ram
« Reply #5 on: July 30, 2021, 07:07:04 pm »
it's not clear for what

Quote
Memory: 5913K kernel code
Memory: 193K rwdata
Memory: 1312K rodata
Memory: 184K init
Memory: 184K bss

This accounts for the majority. Where do you expect the kernel to go, exactly?
 

Online DiTBho

  • Frequent Contributor
  • **
  • Posts: 964
  • Country: gb
Re: Linux, kernel 5.4, mysterious reserved ram
« Reply #6 on: July 30, 2021, 07:11:47 pm »
You'd probably have to configure (and compile yourself) the kernel to modify the amount of reserved memory

I am already configuring and compiling the kernel by myself.
There is no GPU, no framebuffer.
 

Online DiTBho

  • Frequent Contributor
  • **
  • Posts: 964
  • Country: gb
Re: Linux, kernel 5.4, mysterious reserved ram
« Reply #7 on: July 30, 2021, 07:25:34 pm »
it's not clear for what

Quote
Memory: 5913K kernel code
Memory: 193K rwdata
Memory: 1312K rodata
Memory: 184K init
Memory: 184K bss

This accounts for the majority. Where do you expect the kernel to go, exactly?

In 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  :-//
« Last Edit: July 30, 2021, 07:31:51 pm by DiTBho »
 

Offline MarginallyStable

  • Contributor
  • Posts: 21
  • Country: us
Re: Linux, kernel 5.4, mysterious reserved ram
« Reply #8 on: July 31, 2021, 05:33:21 am »
That is the memory reserved for kernel use. I.E. Code, data, bss, page tables, etc.
 
The following users thanked this post: DiTBho


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf