![Debian Linux 伺服器 - L1 和 L2 快取的大小](https://rvso.com/image/1313334/Debian%20Linux%20%E4%BC%BA%E6%9C%8D%E5%99%A8%20-%20L1%20%E5%92%8C%20L2%20%E5%BF%AB%E5%8F%96%E7%9A%84%E5%A4%A7%E5%B0%8F%20.png)
答案1
dmidecode
應該會給你這個訊息。
例如,對於我的 CPU,它顯示以下輸出:
Handle 0x0002, DMI type 7, 19 bytes
Cache Information
Socket Designation: L1-Cache
Configuration: Enabled, Not Socketed, Level 1
Operational Mode: Write Through
Location: Internal
Installed Size: 64 KB
Maximum Size: 64 KB
Supported SRAM Types:
Synchronous
Installed SRAM Type: Synchronous
Speed: Unknown
Error Correction Type: Single-bit ECC
System Type: Data
Associativity: 8-way Set-associative
Handle 0x0003, DMI type 7, 19 bytes
Cache Information
Socket Designation: L2-Cache
Configuration: Enabled, Not Socketed, Level 2
Operational Mode: Write Through
Location: Internal
Installed Size: 256 KB
Maximum Size: 256 KB
Supported SRAM Types:
Synchronous
Installed SRAM Type: Synchronous
Speed: Unknown
Error Correction Type: Single-bit ECC
System Type: Data
Associativity: 8-way Set-associative
Handle 0x0004, DMI type 7, 19 bytes
Cache Information
Socket Designation: L3-Cache
Configuration: Enabled, Not Socketed, Level 3
Operational Mode: Write Back
Location: Internal
Installed Size: 3072 KB
Maximum Size: 3072 KB
Supported SRAM Types:
Synchronous
Installed SRAM Type: Synchronous
Speed: Unknown
Error Correction Type: Single-bit ECC
System Type: Unified
Associativity: <OUT OF SPEC>
從這裡你可以看到我有一個64kb的L1緩存,一個256kb的L2快取和一個3072kb的L3快取。
答案2
看起來這是重複的
然而,在這兩種情況下,dmidecode 對我都不起作用,這是有道理的,因為它報告 BIOS 訊息,而這些訊息並不總是存在或準確。所以,對我來說最好的選擇是:
find /sys/devices/system/cpu/*/cache/index*/size -print -exec cat {} \;
/sys/devices/system/cpu/cpu0/cache/index0/size
32K
/sys/devices/system/cpu/cpu0/cache/index1/size
32K
/sys/devices/system/cpu/cpu0/cache/index2/size
6144K
/sys/devices/system/cpu/cpu1/cache/index0/size
32K
/sys/devices/system/cpu/cpu1/cache/index1/size
32K
/sys/devices/system/cpu/cpu1/cache/index2/size
6144K
答案3
您可以使用 lshw 來尋找快取資訊。如果未安裝,您應該從儲存庫中取得它。
答案4
如果您運行的是 i386/amd64 機器,x86info 是一個不錯的獲取處理器資訊的工具。