您尚未登录。

#1 2023-11-09 23:16:16

ksks
会员
注册时间: 2023-11-09
帖子: 5

[已解决] 关于内存显示的疑惑

第一次使用 archlinux,还请大佬们多多关照!
我是在实体机上安装 archlinux 的,发现内存的显示似乎不符合实际值(bios),查阅了一些资料后还是没法找到可以完全解答我疑惑的答案,所以来到这里想大佬们帮我解答一下。

Manjaro (ArchLinux):

        free

              total            used            free         shared  buff/cache   available
Mem:        15571032     1956304    12970116       34944      997156    13614728
Swap:              0           0           0

        htop
        wjPFo24q.png
        系统信息
        v29botIs.png


Ubuntu:

        free

               total           used           free          shared  buff/cache   available
Mem:        15558280     1325848     7774140      168412     6458292    13756032
Swap:              0           0           0

        资源管理器
        P1oVAd4W.png

Windows 任务管理器:
        w2UYWdbz.png

最近编辑记录 ksks (2023-11-12 19:51:54)

离线

#2 2023-11-09 23:19:49

ksks
会员
注册时间: 2023-11-09
帖子: 5

Re: [已解决] 关于内存显示的疑惑

关于系统的一些信息:

# dmidecode 3.5
Getting SMBIOS data from sysfs.
SMBIOS 3.5.0 present.

Handle 0x0010, DMI type 16, 23 bytes
Physical Memory Array
	Location: System Board Or Motherboard
	Use: System Memory
	Error Correction Type: None
	Maximum Capacity: 64 GB
	Error Information Handle: 0x000F
	Number Of Devices: 2

Handle 0x0013, DMI type 17, 92 bytes
Memory Device
	Array Handle: 0x0010
	Error Information Handle: 0x0012
	Total Width: 64 bits
	Data Width: 64 bits
	Size: 8 GB
	Form Factor: SODIMM
	Set: None
	Locator: DIMM 0
	Bank Locator: P0 CHANNEL A
	Type: DDR5
	Type Detail: Synchronous Unbuffered (Unregistered)
	Speed: 4800 MT/s
	Manufacturer: Samsung
	Serial Number: 4202E0D5
	Asset Tag: Not Specified
	Part Number: M425R1GB4BB0-CQKOL  
	Rank: 1
	Configured Memory Speed: 4800 MT/s
	Minimum Voltage: 1.1 V
	Maximum Voltage: 1.1 V
	Configured Voltage: 1.1 V
	Memory Technology: DRAM
	Memory Operating Mode Capability: Volatile memory
	Firmware Version: Unknown
	Module Manufacturer ID: Bank 1, Hex 0xCE
	Module Product ID: Unknown
	Memory Subsystem Controller Manufacturer ID: Unknown
	Memory Subsystem Controller Product ID: Unknown
	Non-Volatile Size: None
	Volatile Size: 8 GB
	Cache Size: None
	Logical Size: None

Handle 0x0016, DMI type 17, 92 bytes
Memory Device
	Array Handle: 0x0010
	Error Information Handle: 0x0015
	Total Width: 64 bits
	Data Width: 64 bits
	Size: 8 GB
	Form Factor: SODIMM
	Set: None
	Locator: DIMM 0
	Bank Locator: P0 CHANNEL B
	Type: DDR5
	Type Detail: Synchronous Unbuffered (Unregistered)
	Speed: 4800 MT/s
	Manufacturer: Samsung
	Serial Number: 4202E087
	Asset Tag: Not Specified
	Part Number: M425R1GB4BB0-CQKOL  
	Rank: 1
	Configured Memory Speed: 4800 MT/s
	Minimum Voltage: 1.1 V
	Maximum Voltage: 1.1 V
	Configured Voltage: 1.1 V
	Memory Technology: DRAM
	Memory Operating Mode Capability: Volatile memory
	Firmware Version: Unknown
	Module Manufacturer ID: Bank 1, Hex 0xCE
	Module Product ID: Unknown
	Memory Subsystem Controller Manufacturer ID: Unknown
	Memory Subsystem Controller Product ID: Unknown
	Non-Volatile Size: None
	Volatile Size: 8 GB
	Cache Size: None
	Logical Size: None
# cat /proc/meminfo (under archlinux)
MemTotal:       15571032 kB
MemFree:        11071328 kB
MemAvailable:   12556556 kB
Buffers:          121276 kB
Cached:          1611540 kB
SwapCached:            0 kB
Active:          1911148 kB
Inactive:        1247952 kB
Active(anon):    1386956 kB
Inactive(anon):   106252 kB
Active(file):     524192 kB
Inactive(file):  1141700 kB
Unevictable:          32 kB
Mlocked:              32 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Zswap:                 0 kB
Zswapped:              0 kB
Dirty:                16 kB
Writeback:             0 kB
AnonPages:       1375616 kB
Mapped:           660240 kB
Shmem:             66920 kB
KReclaimable:     144548 kB
Slab:             281704 kB
SReclaimable:     144548 kB
SUnreclaim:       137156 kB
KernelStack:       15088 kB
PageTables:        30424 kB
SecPageTables:         0 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     7785516 kB
Committed_AS:   10907356 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      170884 kB
VmallocChunk:          0 kB
Percpu:            12800 kB
HardwareCorrupted:     0 kB
AnonHugePages:    221184 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:    186368 kB
FilePmdMapped:     94208 kB
CmaTotal:              0 kB
CmaFree:               0 kB
Unaccepted:            0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:     1072984 kB
DirectMap2M:     6498304 kB
DirectMap1G:     8388608 kB
# lspci (显卡)
01:00.0 VGA compatible controller: NVIDIA Corporation AD107M [GeForce RTX 4050 Max-Q / Mobile] (rev a1) (prog-if 00 [VGA controller])
	Subsystem: ASUSTeK Computer Inc. AD107M [GeForce RTX 4050 Max-Q / Mobile]
	Physical Slot: 0
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin A routed to IRQ 105
	IOMMU group: 15
	Region 0: Memory at dc000000 (32-bit, non-prefetchable) [size=16M]
	Region 1: Memory at 7c00000000 (64-bit, prefetchable) [size=8G]
	Region 3: Memory at 7e00000000 (64-bit, prefetchable) [size=32M]
	Region 5: I/O ports at f000 [size=128]
	Expansion ROM at dd000000 [virtual] [disabled] [size=512K]
	Capabilities: <access denied>
	Kernel driver in use: nvidia
	Kernel modules: nouveau, nvidia_drm, nvidia

66:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Phoenix1 (rev c1) (prog-if 00 [VGA controller])
	Subsystem: ASUSTeK Computer Inc. Phoenix1
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Interrupt: pin A routed to IRQ 43
	IOMMU group: 20
	Region 0: Memory at 7e10000000 (64-bit, prefetchable) [size=256M]
	Region 2: Memory at dd200000 (64-bit, prefetchable) [size=2M]
	Region 4: I/O ports at d000 [size=256]
	Region 5: Memory at dd700000 (32-bit, non-prefetchable) [size=512K]
	Capabilities: <access denied>
	Kernel driver in use: amdgpu
	Kernel modules: amdgpu

最近编辑记录 ksks (2023-11-09 23:20:25)

离线

#3 2023-11-09 23:48:23

Mr.I
路人丙
所在地: Kerbal
注册时间: 2015-08-29
帖子: 292

Re: [已解决] 关于内存显示的疑惑

没什么问题啊。

如果你是想问 “我的系统有 16G 内存,为什么这里只有 14.8G” 的话,那么答案是:内核会从你的内存中预留一部分给它自己用。这些预留出来的内存对于系统中的其它应用来说是不可用的,所以内核会把这部分预留的内存直接从用户空间中剔除,于是就有了你看到的 “我的内存变少了”的现象。

最近编辑记录 Mr.I (2023-11-09 23:53:16)

离线

#4 2023-11-10 00:03:00

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,109
个人网站

Re: [已解决] 关于内存显示的疑惑

不太对。被保留的内存都是保留给硬件使用的,因此无论是内核还是用户态进程,都对其没有完整的控制权。AMD 集成显卡就会从内存里保留一部分空间用作显存。(而 Intel 集成显卡会按需分配内存,不用启动就保留起来。)
journalctl -k | grep -i reserve 可以看到这些信息。

内核自己用的内存也是通过正常途径分配的,不属于保留内存。

离线

#5 2023-11-10 00:20:22

Mr.I
路人丙
所在地: Kerbal
注册时间: 2015-08-29
帖子: 292

Re: [已解决] 关于内存显示的疑惑

咦?!这样的啊。感谢依云的纠正。

我一直以为那部分内存是由内核模块控制的。我之前的理解是 AMD 集成显卡的预留显存是由 amdgpu 操作的,而 amdgpu 是内核的一部分。

-----------------------------------

我想问一下,如果预留给硬件的内存不是由对应的内核模块在操作的话,那么是谁的代码在操作那些内存呢?
以 amdgpu 为例,如果不是 amdgpu 内核模块在读写显存的话,那么这些显存由谁在操作呢?是 AMD 的 firmware 在做这个事情吗?

离线

#6 2023-11-10 00:36:28

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,109
个人网站

Re: [已解决] 关于内存显示的疑惑

是硬件通过 DMA 操作。显卡的运作我不太了解,给你举个网卡的例子。网卡收到数据包,把它写到内存里,然后通过中断告诉内核它收到数据了、请处理。这样接收的过程就不需要走常规的需要 CPU 参与的方式了,能快速很多。

离线

#7 2023-11-10 01:04:10

Mr.I
路人丙
所在地: Kerbal
注册时间: 2015-08-29
帖子: 292

Re: [已解决] 关于内存显示的疑惑

突然发现我多年前学过你说的网卡的这个例子  😅 我以为这个只是高性能网卡的东西,并没有想到过大多数硬件都是这样子的。我刚翻了一下内核的 DRM Memory Management,似乎显卡的 DMA 和高性能网卡的 DMA 挺像的(只看懂了一点皮毛)

离线

#8 2023-11-10 09:53:17

ksks
会员
注册时间: 2023-11-09
帖子: 5

Re: [已解决] 关于内存显示的疑惑

依云 说:

不太对。被保留的内存都是保留给硬件使用的,因此无论是内核还是用户态进程,都对其没有完整的控制权。AMD 集成显卡就会从内存里保留一部分空间用作显存。(而 Intel 集成显卡会按需分配内存,不用启动就保留起来。)
journalctl -k | grep -i reserve 可以看到这些信息。

内核自己用的内存也是通过正常途径分配的,不属于保留内存。

看起来似乎是被其他硬件占用了:

Nov 10 09:37:14 aaa kernel: BIOS-e820: [mem 0x00000000000a0000-0x00000000000fffff] reserved
Nov 10 09:37:14 aaa kernel: BIOS-e820: [mem 0x0000000009a7f000-0x0000000009ffffff] reserved
Nov 10 09:37:14 aaa kernel: BIOS-e820: [mem 0x000000008ea97000-0x00000000915f0fff] reserved
Nov 10 09:37:14 aaa kernel: BIOS-e820: [mem 0x000000009699b000-0x000000009a5fefff] reserved
Nov 10 09:37:14 aaa kernel: BIOS-e820: [mem 0x000000009bffb000-0x000000009cffffff] reserved
Nov 10 09:37:14 aaa kernel: BIOS-e820: [mem 0x000000009d790000-0x000000009d7effff] reserved
Nov 10 09:37:14 aaa kernel: BIOS-e820: [mem 0x000000009d7f5000-0x000000009fffffff] reserved
Nov 10 09:37:14 aaa kernel: BIOS-e820: [mem 0x00000000e0000000-0x00000000efffffff] reserved
Nov 10 09:37:14 aaa kernel: BIOS-e820: [mem 0x00000000fd000000-0x00000000ffffffff] reserved
Nov 10 09:37:14 aaa kernel: BIOS-e820: [mem 0x000000043f340000-0x00000004801fffff] reserved
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x0000000000000000-0x000000000009ffff] usable
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x00000000000a0000-0x00000000000fffff] reserved
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x0000000000100000-0x0000000009a7efff] usable
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x0000000009a7f000-0x0000000009ffffff] reserved
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x000000000a000000-0x000000000a1fffff] usable
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x000000000a200000-0x000000000a23bfff] ACPI NVS
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x000000000a23c000-0x0000000086c59017] usable
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x0000000086c59018-0x0000000086c5c057] usable
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x0000000086c5c058-0x000000008ea96fff] usable
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x000000008ea97000-0x00000000915f0fff] reserved
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x00000000915f1000-0x0000000091668fff] ACPI data
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x0000000091669000-0x000000009699afff] ACPI NVS
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x000000009699b000-0x000000009a5fefff] reserved
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x000000009a5ff000-0x000000009bffafff] usable
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x000000009bffb000-0x000000009cffffff] reserved
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x000000009d790000-0x000000009d7effff] reserved
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x000000009d7f5000-0x000000009fffffff] reserved
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x00000000e0000000-0x00000000efffffff] reserved
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x00000000fd000000-0x00000000ffffffff] reserved
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x0000000100000000-0x000000043e2fffff] usable
Nov 10 09:37:14 aaa kernel: reserve setup_data: [mem 0x000000043f340000-0x00000004801fffff] reserved
Nov 10 09:37:14 aaa kernel: e820: remove [mem 0xe0000000-0xefffffff] reserved
Nov 10 09:37:14 aaa kernel: e820: remove [mem 0xfd000000-0xfedfffff] reserved
Nov 10 09:37:14 aaa kernel: e820: remove [mem 0xfee01000-0xffffffff] reserved
Nov 10 09:37:14 aaa kernel: e820: remove [mem 0x460000000-0x4801fffff] reserved
Nov 10 09:37:14 aaa kernel: e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
Nov 10 09:37:14 aaa kernel: e820: update [mem 0xa0000000-0xffffffff] usable ==> reserved
Nov 10 09:37:14 aaa kernel: e820: update [mem 0x8846e000-0x8846efff] usable ==> reserved
Nov 10 09:37:14 aaa kernel: e820: update [mem 0x8a06d000-0x8a0b9fff] usable ==> reserved
Nov 10 09:37:14 aaa kernel: Memory: 15395648K/15959508K available (16384K kernel code, 2141K rwdata, 13036K rodata, 3400K init, 3856K bss, 563600K reserved, 0K cma-reserved)
Nov 10 09:37:14 aaa kernel: PCI: MMCONFIG at [mem 0xe0000000-0xefffffff] reserved as ACPI motherboard resource
Nov 10 09:37:14 aaa kernel: e820: reserve RAM buffer [mem 0x09a7f000-0x0bffffff]
Nov 10 09:37:14 aaa kernel: e820: reserve RAM buffer [mem 0x0a200000-0x0bffffff]
Nov 10 09:37:14 aaa kernel: e820: reserve RAM buffer [mem 0x86c59018-0x87ffffff]
Nov 10 09:37:14 aaa kernel: e820: reserve RAM buffer [mem 0x8846e000-0x8bffffff]
Nov 10 09:37:14 aaa kernel: e820: reserve RAM buffer [mem 0x8a06d000-0x8bffffff]
Nov 10 09:37:14 aaa kernel: e820: reserve RAM buffer [mem 0x8ea97000-0x8fffffff]
Nov 10 09:37:14 aaa kernel: e820: reserve RAM buffer [mem 0x9bffb000-0x9bffffff]
Nov 10 09:37:14 aaa kernel: e820: reserve RAM buffer [mem 0x43e300000-0x43fffffff]
Nov 10 09:37:14 aaa kernel: system 00:00: [mem 0xe0000000-0xefffffff] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x04d0-0x04d1] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x040b] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x04d6] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0c00-0x0c01] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0c14] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0c50-0x0c51] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0c52] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0c6c] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0c6f] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0cd0-0x0cd1] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0cd2-0x0cd3] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0cd4-0x0cd5] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0cd6-0x0cd7] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0cd8-0x0cdf] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0800-0x089f] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0b00-0x0b0f] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0b20-0x0b3f] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0900-0x090f] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [io  0x0910-0x091f] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [mem 0xfec00000-0xfec00fff] could not be reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [mem 0xfec01000-0xfec01fff] could not be reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [mem 0xfedc0000-0xfedc0fff] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [mem 0xfee00000-0xfee00fff] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [mem 0xfed80000-0xfed8ffff] could not be reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [mem 0xfec10000-0xfec10fff] has been reserved
Nov 10 09:37:14 aaa kernel: system 00:03: [mem 0xff000000-0xffffffff] has been reserved
Nov 10 09:37:15 aaa kernel: [drm] reserve 0x4a00000 from 0x8010000000 for PSP TMR

离线

#9 2023-11-10 10:05:49

ksks
会员
注册时间: 2023-11-09
帖子: 5

Re: [已解决] 关于内存显示的疑惑

看起来是给核显和独显都留了512MB内存?(哭笑)

# glxinfo (part)
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: AMD (0x1002)
    Device: AMD Radeon Graphics (gfx1103_r1, LLVM 16.0.6, DRM 3.54, 6.5.9-1-MANJARO) (0x15bf)
    Version: 23.1.9
    Accelerated: yes
    Video memory: 512MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 4.6
    Max compat profile version: 4.6
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
Memory info (GL_ATI_meminfo):
    VBO free memory - total: 33 MB, largest block: 33 MB
    VBO free aux. memory - total: 7229 MB, largest block: 7229 MB
    Texture free memory - total: 33 MB, largest block: 33 MB
    Texture free aux. memory - total: 7229 MB, largest block: 7229 MB
    Renderbuffer free memory - total: 33 MB, largest block: 33 MB
    Renderbuffer free aux. memory - total: 7229 MB, largest block: 7229 MB
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 512 MB
    Total available memory: 8115 MB
    Currently available dedicated video memory: 33 MB
OpenGL vendor string: AMD
OpenGL renderer string: AMD Radeon Graphics (gfx1103_r1, LLVM 16.0.6, DRM 3.54, 6.5.9-1-MANJARO)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 23.1.9-manjaro1.1
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

最近编辑记录 ksks (2023-11-10 10:07:28)

离线

#10 2023-11-10 10:51:15

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,109
个人网站

Re: [已解决] 关于内存显示的疑惑

独显应该有自己的显存,保留一点用于通信就够了吧。

离线

#11 2023-11-10 11:09:21

ksks
会员
注册时间: 2023-11-09
帖子: 5

Re: [已解决] 关于内存显示的疑惑

依云 说:

独显应该有自己的显存,保留一点用于通信就够了吧。

嗯,感谢大佬

离线

页脚