0

I have a 128GB RAM server, kernel 4.18.0-305.7.1.el8_4.x86_64, "dmesg | grep Memory" outputs as follows:

[ 0.000000] Memory: 1282732K/133708404K available (12293K kernel code, 2225K rwdata, 7708K rodata, 2476K init, 14048K bss, 2721876K reserved, 0K cma-reserved)

What confuse me is "1282732K".

I know "133708404K" stands for total RAM the system has, so What does kernel mean by "1282732K"? Only 1.2GB out of 128GB can be used ?

"cat /proc/meminfo" shows:

MemTotal:       131494424 kB
MemFree:        25128904 kB
MemAvailable:   29625476 kB
Buffers:         4751752 kB
Cached:           570920 kB
SwapCached:       353700 kB
Active:         91801188 kB
Inactive:        6120828 kB
Active(anon):   87248832 kB
Inactive(anon):  5473052 kB
Active(file):    4552356 kB
Inactive(file):   647776 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:      16777212 kB
SwapFree:       16345892 kB
Dirty:                16 kB
Writeback:             0 kB
AnonPages:      92242344 kB
Mapped:           127760 kB
Shmem:            122540 kB
KReclaimable:     273356 kB
Slab:             759136 kB
SReclaimable:     273356 kB
SUnreclaim:       485780 kB
KernelStack:       18704 kB
PageTables:       196364 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    82524424 kB
Committed_AS:   153723376 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
Percpu:            77760 kB
HardwareCorrupted:     0 kB
AnonHugePages:  88938496 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      508928 kB
DirectMap2M:    30439424 kB
DirectMap1G:    104857600 kB
Tao Lei
  • 3
  • 2
  • Probably. Read `dmesg` further. What `cat /proc/meminfo` says? – Nikita Kipriyanov Aug 21 '22 at 03:49
  • @NikitaKipriyanov, /proc/meminfo added. – Tao Lei Aug 21 '22 at 04:07
  • So it has `131494424 kB` of usable memory. What practical problem do you have? – Nikita Kipriyanov Aug 21 '22 at 05:56
  • @NikitaKipriyanov I wonder why kernel reports “1282732K” in the dmesg, which is only 1% of total RAM. Another machine reports "[ 0.000000] Memory: 66097600K/67104576K available (9724K kernel code, 4594K rwdata, 6912K rodata, 5248K init, 17406K bss, 1006976K reserved, 0K cma-reserved)", the two numbers are both approximately equal to 64GB. – Tao Lei Aug 21 '22 at 07:16
  • Then I am sorry, this is off topic. SF is for concrete business problems, but your question is just out of pure curiosity. There is an (not very explanatory) answer below which is enough from admin point of view. I can speculate Linux reported that before it had any chance to do its own memory initialization routine. This is the state as came from the boot loader, probably, this is how memory was set up by the EFI firmware. Enough to boot Linux, anything else doesn't matter. – Nikita Kipriyanov Aug 21 '22 at 16:37

1 Answers1

2

That kernel message comes from the mem_init_print_info() function. Called early at boot, maybe halfway through start_kernel()

A time stamp of 0.000000 means this was the available pages (and kernel size), as of the first microsecond the system was booted. Short time even for computers. A few seconds later, when you log in and can check /proc/meminfo yourself, is millions of times longer, a relative eternity.

I don't know Linux virtual memory well enough to explain exactly what initialization the kernel could be up to this early in boot. But it does not represent memory usage now.

Use /proc/meminfo based memory monitoring once the system is up. Whatever your favorite host metrics tool is.

Init info might still be useful in rare circumstances, like forensics to determine if the kernel changed in size.

John Mahowald
  • 32,050
  • 2
  • 19
  • 34
  • I think you're referring to: https://docs.kernel.org/core-api/boot-time-mm.html : *Early system initialization cannot use “normal” memory management simply because it is not set up yet. But there is still need to allocate memory for various data structures, for instance for the physical page allocator. A specialized allocator called `memblock` performs the boot time memory management. The architecture specific initialization must set it up in `setup_arch()` and tear it down in `mem_init()` functions. ...* – HBruijn Aug 22 '22 at 10:09
  • @HBruijn A very valuable reference, thank you. – Tao Lei Aug 22 '22 at 12:23