AlmaLinux

20230414--RHEL/Rocky/AlmaLinux8显

2023-04-13  本文已影响0人  負笈在线

上次修改crashkernel配置将可用内存提升了至少160M,也提到可用内存与硬件内存还存在较大的差距,本文就来简单分析还有哪些硬件内存被预先分配了。

1.主要的内存数据

1)硬件内存1024M,1048576kB

# dmidecode -t 6|more
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: 1024 MB (Single-bank Connection)
        Enabled Size: 1024 MB (Single-bank Connection)
        Error Status: OK

2)可用内存959796 kB,937M

# more /proc/meminfo |grep MemTotal
MemTotal:         959796 kB
# free -m
              total        used        free      shared  buff/cache   available
Mem:            937         400          83           9         453         357
Swap:          2099         232        1867

3)预分配内存123852kB,121M

# dmesg |grep -i mem|more
[    0.000000] Memory: 261120K/1048052K available (12293K kernel code, 5878K rwdata, 8380K rodata, 2552K init, 14256K bss, 123852K reserved, 0K cma-reserved)

2.哪些资源预分配了内存:e820

在操作系统开始管理内存之前,首先要获取物理内存的信息,比如共有多少物理地址是可用的? 有哪些物理地址是被ACPI(Advanced Configuration and Power Interface)数据使用? 这些信息从何而来?e820就是x86架构(包括x86_64)上的操作系统引导程序提供物理内存信息的功能。当请求BIOS中断号15H,并且置操作码AX=E820H的时候,BIOS就会向调用者报告可用的物理地址区间等信息,e820由此得名。
什么是E820?
E820是基于X86的计算机系统的BIOS将内存映射报告给操作系统或引导加载程序的便利工具。通过将AX寄存器设置为十六进制值E820,可以通过INT15H调用对其进行访问,报告哪些内存地址范围可用,哪些保留给BIOS使用。"BIOS-e820"通常是启动Linux内核报告的第一件事,可以通过dmesg命令看到它。

Usable:表示已经被映射到物理内存的物理地址,即可用地址段
Reserved:表示这些区间是没有被映射到任何地方,不能当作RAM来使用,但是Kernel可决定将该区间映射到其他地方,比如PCI设备。通过读取/proc/iomem可以查看物理地址空间的映射情况,可以知道这些reserved的空间,是如何进一步分配给不同的设备来使用的。
ACPI data:表示映射到用来存放ACPI数据的RAM空间,操作系统应该将ACPI Table读入到这个区间内。
ACPI NVS:表示映射到用来存放ACPI数据的非易失性存储空间,操作系统不能使用。
Unusable:表示检测到发生错误的物理内存。

Usable
# dmesg |grep -i mem|grep usable
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009ebff] usable
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000003fedffff] usable
[    0.000000] BIOS-e820: [mem 0x000000003ff00000-0x000000003fffffff] usable
[    0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[    0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable
reserved
# dmesg |grep -i mem|grep reserved
[    0.000000] BIOS-e820: [mem 0x000000000009ec00-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000dc000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000f0000000-0x00000000f7ffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec0ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fffe0000-0x00000000ffffffff] reserved
[    0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[    0.000000] Memory: 261120K/1048052K available (12293K kernel code, 5878K rwdata, 8380K rodata, 2552K init, 14256K bss, 123852K reserved, 0K cma-reserved)
[    0.020659] PCI: MMCONFIG at [mem 0xf0000000-0xf7ffffff] reserved in E820
[    0.168259] system 00:04: [mem 0xfed00000-0xfed003ff] has been reserved
[    0.169441] system 00:05: [mem 0xf0000000-0xf7ffffff] has been reserved
[    0.169442] system 00:05: [mem 0xfe800000-0xfe9fffff] has been reserved

ACPI data&&ACPI NVS

# dmesg |grep -i mem|grep -i acpi
[    0.000000] BIOS-e820: [mem 0x000000003fee0000-0x000000003fefefff] ACPI data
[    0.000000] BIOS-e820: [mem 0x000000003feff000-0x000000003fefffff] ACPI NVS
[    0.000000] ACPI: SRAT 0x000000003FEE9757 0008A8 (v02 VMWARE MEMPLUG  06040000 VMW  00000001)
[    0.000000] ACPI: Reserving FACP table memory at [mem 0x3fefee73-0x3fefef66]
[    0.000000] ACPI: Reserving DSDT table memory at [mem 0x3feeaa08-0x3fefee72]
[    0.000000] ACPI: Reserving FACS table memory at [mem 0x3fefffc0-0x3fefffff]
[    0.000000] ACPI: Reserving FACS table memory at [mem 0x3fefffc0-0x3fefffff]
[    0.000000] ACPI: Reserving BOOT table memory at [mem 0x3feea9e0-0x3feeaa07]
[    0.000000] ACPI: Reserving APIC table memory at [mem 0x3feea29e-0x3feea9df]
[    0.000000] ACPI: Reserving MCFG table memory at [mem 0x3feea262-0x3feea29d]
[    0.000000] ACPI: Reserving SRAT table memory at [mem 0x3fee9757-0x3fee9ffe]
[    0.000000] ACPI: Reserving HPET table memory at [mem 0x3fee971f-0x3fee9756]
[    0.000000] ACPI: Reserving WAET table memory at [mem 0x3fee96f7-0x3fee971e]
[    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00000000-0x0009ffff]
[    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00100000-0x3fffffff]
[    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x40000000-0xbfffffff] hotplug
[    0.018861] ACPI: PM: Registering ACPI NVS region [mem 0x3feff000-0x3fefffff] (4096 bytes)

3.reserved分配情况

Reserved:是Kernel可决定将该区间映射到其他地方,比如PCI设备。通过读取/proc/iomem可以查看物理地址空间的映射情况,可以知道这些reserved的空间,是如何进一步分配给不同的设备来使用的。

# more /proc/iomem |grep -i Reserved
00000000-00000fff : Reserved         #0~4095=4096
0009ec00-0009ffff : Reserved         #650240~655359=5120
000dc000-000fffff : Reserved         #901120~1048575=147456
  000f0000-000fffff : System ROM

  f0000000-f7ffffff : PCI MMCONFIG 0000 [bus 00-7f]
    f0000000-f7ffffff : Reserved     #4026531840~4160749567=134217728
      f0000000-f7ffffff : pnp 00:05
4026531840
fec00000-fec0ffff : Reserved         #4273995776~4274061311=65536
  fec00000-fec003ff : IOAPIC 0

fee00000-fee00fff : Local APIC
  fee00000-fee00fff : Reserved       #4276092928~4276097023=4096

fffe0000-ffffffff : Reserved         #4294836224~4294967295=131071

总计:134,575,104

涉及Kernel分配Reserved,后续再分析,尤其从对比RHEL/Rocky/AlmaLinux8着手。

参考URL

https://www.jianshu.com/p/fd7f374976a6

上一篇下一篇

猜你喜欢

热点阅读