작은 재료 : 탑재 메모리 총량은 어떤 명령으로 확인해야합니까?

소개



IBM Cloud VPC에서 서버 프로파일을 살펴보면 GB(기가바이트: $10^{9}$)가 아니라 GiB(기비바이트: $2^{30}$) 표시가 되고 있다.


"호호"라고 생각하고, 16GiB의 CentOS를 주문해 메모리를 (정평의) freeコマンド 를 사용해 보면, 메모리 총량이 16GiB(=16384MiB)도 없는 것을 깨달았다.

검증 결과



free


[root@syasuda16gb ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:             15           0          15           0           0          15
Swap:             0           0           0

[root@syasuda16gb ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:          16047         177       15746          16         123       15634
Swap:             0           0           0

[root@syasuda16gb ~]# free -k
              total        used        free      shared  buff/cache   available
Mem:       16433128      183160    16122872       16816      127096    16008688
Swap:            40           0          40

[root@syasuda16gb ~]# free -b
              total        used        free      shared  buff/cache   available
Mem:    16827523072   186245120 16511647744    17219584   129630208 16394469376
Swap:         40960           0       40960

$16827523072/1024/1024=16047$ 그래서 free의 결과가 이진법으로 계산되고 있는 것은 틀림없을 것 같다.

/proc/meminfo


MemTotal 의 항을 본 느낌으로는 16433128 kB 이며 free의 결과와 같다.
[root@syasuda16gb ~]# cat /proc/meminfo
MemTotal:       16433128 kB
MemFree:        16122476 kB
MemAvailable:   16008292 kB
Buffers:           20912 kB
Cached:            88824 kB
SwapCached:            0 kB
Active:            67112 kB
Inactive:          81664 kB
Active(anon):      39236 kB
Inactive(anon):    16616 kB
Active(file):      27876 kB
Inactive(file):    65048 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:            40 kB
SwapFree:             40 kB
Dirty:                60 kB
Writeback:             0 kB
AnonPages:         39072 kB
Mapped:            23580 kB
Shmem:             16816 kB
Slab:              42144 kB
SReclaimable:      17356 kB
SUnreclaim:        24788 kB
KernelStack:        1728 kB
PageTables:         3240 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8216604 kB
Committed_AS:     185352 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       30312 kB
VmallocChunk:   34359705664 kB
HardwareCorrupted:     0 kB
AnonHugePages:      8192 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      110432 kB
DirectMap2M:     5136384 kB
DirectMap1G:    12582912 kB

top


KiB Mem 의 항을 본 느낌으로는 16433128 이며 free의 결과와 같다.
[root@syasuda16gb ~]# top
top - 07:21:13 up 15:09,  1 user,  load average: 0.00, 0.01, 0.03
Tasks:  91 total,   2 running,  89 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.1 sy,  0.0 ni, 99.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 16433128 total, 16121512 free,   184168 used,   127448 buff/cache
KiB Swap:       40 total,       40 free,        0 used. 16007508 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
    1 root      20   0   45988   6472   4136 S   0.0  0.0   0:03.24 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd
    4 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
    5 root      20   0       0      0      0 S   0.0  0.0   0:00.34 kworker/u8:0
    6 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ksoftirqd/0
    7 root      rt   0       0      0      0 S   0.0  0.0   0:00.01 migration/0
    8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh
    9 root      20   0       0      0      0 R   0.0  0.0   0:00.55 rcu_sched
   10 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 lru-add-drain
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.20 watchdog/0
   12 root      rt   0       0      0      0 S   0.0  0.0   0:00.12 watchdog/1
   13 root      rt   0       0      0      0 S   0.0  0.0   0:00.05 migration/1
   14 root      20   0       0      0      0 S   0.0  0.0   0:00.13 ksoftirqd/1
   16 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/1:0H
   17 root      rt   0       0      0      0 S   0.0  0.0   0:00.14 watchdog/2
   18 root      rt   0       0      0      0 S   0.0  0.0   0:00.01 migration/2
   19 root      20   0       0      0      0 S   0.0  0.0   0:00.01 ksoftirqd/2
   21 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/2:0H

결론



이 대답은

  • Why the server shows less total memory compared to the physical memory installed 라는 RedHat 사의 KB
  • Where did my memory go?

  • 등의 기사에 썼다. 요컨대 Kernel 자신이 메모리 관리를 위해서 일정 사이즈의 메모리량을 예약하기 때문에, 그 예약한 메모리량을 차감해 총량으로서 free/top등의 커멘드는 표시하고 있는 것 같다(이것은 사양이며 버그 아니다).

    그럼, 어떻게 하면 진짜 메모리량을 확인할 수 있을까 하면, dmidecode 라고 하는 하드웨어의 정보를 취득하는 커멘드로 확인할 수 있다. 확실히 이하의 결과로부터는 Size: 16384 MB 라고 인식되고 있다.
    [root@syasuda16gb ~]# dmidecode -t memory
    # dmidecode 3.2
    Getting SMBIOS data from sysfs.
    SMBIOS 2.8 present.
    
    Handle 0x1000, DMI type 16, 23 bytes
    Physical Memory Array
        Location: Other
        Use: System Memory
        Error Correction Type: Multi-bit ECC
        Maximum Capacity: 16388 MB
        Error Information Handle: Not Provided
        Number Of Devices: 2
    
    Handle 0x1100, DMI type 17, 40 bytes
    Memory Device
        Array Handle: 0x1000
        Error Information Handle: Not Provided
        Total Width: Unknown
        Data Width: Unknown
        Size: 16384 MB
        Form Factor: DIMM
        Set: None
        Locator: DIMM 0
        Bank Locator: Not Specified
        Type: RAM
        Type Detail: Other
        Speed: Unknown
        Manufacturer: QEMU
        Serial Number: Not Specified
        Asset Tag: Not Specified
        Part Number: Not Specified
        Rank: Unknown
        Configured Memory Speed: Unknown
        Minimum Voltage: Unknown
        Maximum Voltage: Unknown
        Configured Voltage: Unknown
    
    Handle 0x1101, DMI type 17, 40 bytes
    Memory Device
        Array Handle: 0x1000
        Error Information Handle: Not Provided
        Total Width: Unknown
        Data Width: Unknown
        Size: 4 MB
        Form Factor: DIMM
        Set: None
        Locator: DIMM 1
        Bank Locator: Not Specified
        Type: RAM
        Type Detail: Other
        Speed: Unknown
        Manufacturer: QEMU
        Serial Number: Not Specified
        Asset Tag: Not Specified
        Part Number: Not Specified
        Rank: Unknown
        Configured Memory Speed: Unknown
        Minimum Voltage: Unknown
        Maximum Voltage: Unknown
        Configured Voltage: Unknown
    

    좋은 웹페이지 즐겨찾기