Linux – Why is the size of “/proc/kcore” file so bigger than the physical memory size

linuxmemoryproc

From proc manual:

/proc/kcore

This file represents the physical memory of the system and is stored in the ELF core file format. With this pseudo-file, and an unstripped kernel (/usr/src/linux/vmlinux) binary, GDB can be used to examine the current state of any kernel data structures.

The total length of the file is the size of physical memory (RAM) plus 4KB.

I can see the size of /proc/kcore is the size of physical memory (RAM) plus 4KB.

But on my SuSE Linux:

# ls -lt  --block-size=M /proc/kcore
-r-------- 1 root root 134217727M Nov 15 21:09 /proc/kcore

    # cat /proc/meminfo
MemTotal:         792680 kB
MemFree:           79960 kB
MemAvailable:     351664 kB
Buffers:              40 kB
Cached:           246588 kB
SwapCached:          212 kB
Active:           282992 kB
Inactive:         292896 kB
Active(anon):     122652 kB
Inactive(anon):   214164 kB
Active(file):     160340 kB
Inactive(file):    78732 kB
Unevictable:         100 kB
Mlocked:             100 kB
SwapTotal:       1532924 kB
SwapFree:        1531088 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:        329148 kB
Mapped:            71888 kB
Shmem:              7556 kB
Slab:              63088 kB
SReclaimable:      46300 kB
SUnreclaim:        16788 kB
KernelStack:        1888 kB
PageTables:            0 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     1929264 kB
Committed_AS:    1451492 kB
VmallocTotal:   34359738367 kB
VmallocUsed:        7580 kB
VmallocChunk:   34359726080 kB
HardwareCorrupted:     0 kB
DirectMap4k:      867568 kB
DirectMap2M:           0 kB

Why is the size of /proc/kcore file so bigger than the physical memory size?

Best Answer

kcore is the virtual allocation of your RAM for the kernel. On 64 bit systems that size can be an absolute limit of 128T since that is the most the system can allocate.

Related Question