Eu estou rodando aqui um par de Debian 9.3 VMs com o kernel 4.9.0-5-amd64 no VMware Fusion 10.1.1 (no High Sierra).
O que me preocupa é que a memória total no Free não reflete corretamente a memória que estou reservando para várias VMs.
Como teste, reservei exatamente 2 GB para a VM e, no entanto, free -m
mostra apenas 1986MB:
$ free -m
total used free shared buff/cache available
Mem: 1986 51 1864 1 70 1825
ou sem o -m
:
$ free
total used free shared buff/cache available
Mem: 2033760 52264 1909584 1108 71912 1869628
Swap: 999420 0 999420
Depurando a situação, também procurei /proc/meminfo
e achei isso:
$ egrep "MemTotal|DirectMap2M" /proc/meminfo
MemTotal: 2033760 kB
DirectMap2M: 2054144 kB
Então, na verdade, o DirectMap2M reflete os 2 GB; porque tem MemTotal aprox. menos 20MB então?
Curiosamente, enquanto Googling para MemTotal / DirectMap2M encontrou este artigo: Memória / Ram está errado
If your operating system is showing the wrong RAM allocation via the
free –m
or top
command please be assured that you really do have the
correct amount of RAM allocated to your VPS.
It is simply the reporting
that is wrong, this is due to us using the latest Xen 4.x.x Versions for performance enhancements which unfortunately can cause this anomaly, more so on 32bit OS templates than others.
Also please keep in mind that more modern kernels do not present some of the kernel reserved memory to the OS.
Então, o que está acontecendo aqui? É o kernel reservando memória como eles sugerem? Para que fim?
(sim, eles estão falando sobre o Xen e isso é sobre o VmWare Fusion, mas pode ser uma pista)
Para complementar:
saída vmstat:
$ vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 1909344 13988 57928 0 0 31 0 19 37 0 0 100 0 0
saída principal:
$ top -b -n 1 | grep Mem
KiB Mem : 2033760 total, 1906228 free, 52836 used, 74696 buff/cache
KiB Swap: 999420 total, 999420 free, 0 used. 1867664 avail Mem
dmidecode
output (parcial);
Handle 0x0085, DMI type 6, 12 bytes
Memory Module Information
Socket Designation: RAM socket #0
Bank Connections: None
Current Speed: Unknown
Type: EDO DIMM
Installed Size: 2048 MB (Single-bank Connection)
Enabled Size: 2048 MB (Single-bank Connection)
Error Status: OK
Saída de dmesg
:
$ sudo dmesg | egrep "Memory|Free|ACPI" | egrep -v "edge|wakeup|noapic|Added|Bug|IRQ|pnp|Plug"
[ 0.000000] BIOS-e820: [mem 0x000000007fee0000-0x000000007fefefff] ACPI data
[ 0.000000] BIOS-e820: [mem 0x000000007feff000-0x000000007fefffff] ACPI NVS
[ 0.000000] ACPI: Early table checksum verification disabled
[ 0.000000] ACPI: RSDP 0x00000000000F6A10 000024 (v02 PTLTD )
[ 0.000000] ACPI: XSDT 0x000000007FEEB683 00005C (v01 INTEL 440BX 06040000 VMW 01324272)
[ 0.000000] ACPI: FACP 0x000000007FEFEE73 0000F4 (v04 INTEL 440BX 06040000 PTL 000F4240)
[ 0.000000] ACPI: DSDT 0x000000007FEEC923 012550 (v01 PTLTD Custom 06040000 MSFT 03000001)
[ 0.000000] ACPI: FACS 0x000000007FEFFFC0 000040
[ 0.000000] ACPI: FACS 0x000000007FEFFFC0 000040
[ 0.000000] ACPI: BOOT 0x000000007FEEC8FB 000028 (v01 PTLTD $SBFTBL$ 06040000 LTP 00000001)
[ 0.000000] ACPI: APIC 0x000000007FEEC1B9 000742 (v01 PTLTD ? APIC 06040000 LTP 00000000)
[ 0.000000] ACPI: MCFG 0x000000007FEEC17D 00003C (v01 PTLTD $PCITBL$ 06040000 LTP 00000001)
[ 0.000000] ACPI: SRAT 0x000000007FEEB77F 000880 (v02 VMWARE MEMPLUG 06040000 VMW 00000001)
[ 0.000000] ACPI: HPET 0x000000007FEEB747 000038 (v01 VMWARE VMW HPET 06040000 VMW 00000001)
[ 0.000000] ACPI: WAET 0x000000007FEEB71F 000028 (v01 VMWARE VMW WAET 06040000 VMW 00000001)
[ 0.000000] ACPI: Local APIC address 0xfee00000
[ 0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00000000-0x0009ffff]
[ 0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00100000-0x7fffffff]
[ 0.000000] ACPI: PM-Timer IO Port: 0x1008
[ 0.000000] ACPI: Local APIC address 0xfee00000
[ 0.000000] Using ACPI for processor (LAPIC) configuration information
[ 0.000000] ACPI: HPET id: 0x8086af01 base: 0xfed00000
[ 0.000000] Memory: 2011544K/2096628K available (6196K kernel code, 1159K rwdata, 2848K rodata, 1408K init, 688K bss, 85084K reserved, 0K cma-reserved)
[ 0.005465] ACPI: 1 ACPI AML tables successfully acquired and loaded
[ 0.005475] ACPI: setting ELCR to 0200 (from 0e80)
[ 0.044362] x86/mm: Memory block size: 128MB
[ 0.046853] PM: Registering ACPI NVS region [mem 0x7feff000-0x7fefffff] (4096 bytes)
[ 0.170037] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-7f])
[ 0.178855] pci 0000:00:07.3: quirk: [io 0x1000-0x103f] claimed by PIIX4 ACPI
[ 0.282772] ACPI: Enabled 2 GPEs in block 00 to 0F
[ 0.995687] Freeing initrd memory: 17572K
[ 1.085789] Freeing unused kernel memory: 1408K
[ 1.085832] Freeing unused kernel memory: 1980K
[ 1.085873] Freeing unused kernel memory: 1248K
total /proc/meminfo
output:
$ cat /proc/meminfo
MemTotal: 2033760 kB
MemFree: 1906864 kB
MemAvailable: 1868300 kB
Buffers: 14720 kB
Cached: 50220 kB
SwapCached: 0 kB
Active: 45004 kB
Inactive: 28204 kB
Active(anon): 8308 kB
Inactive(anon): 1064 kB
Active(file): 36696 kB
Inactive(file): 27140 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 999420 kB
SwapFree: 999420 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 8284 kB
Mapped: 14860 kB
Shmem: 1108 kB
Slab: 23996 kB
SReclaimable: 9756 kB
SUnreclaim: 14240 kB
KernelStack: 3052 kB
PageTables: 1348 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 2016300 kB
Committed_AS: 38852 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 42880 kB
DirectMap2M: 2054144 kB
DirectMap1G: 0 kB