• 查看Processor Cache的6种方法 linux为主


    1. lscpu
      1 [root@localhost home]# lscpu| grep cache
      2 L1d cache: 32K
      3 L1i cache: 32K
      4 L2 cache: 1024K
      5 L3 cache: 36608K

      可以看出FLC是64KB,MLC是1MB,LLC是35.75MB

    2. getconf
       1 [root@localhost home]# getconf -a| grep CACHE
       2 LEVEL1_ICACHE_SIZE 32768
       3 LEVEL1_ICACHE_ASSOC 8
       4 LEVEL1_ICACHE_LINESIZE 64
       5 LEVEL1_DCACHE_SIZE 32768
       6 LEVEL1_DCACHE_ASSOC 8
       7 LEVEL1_DCACHE_LINESIZE 64
       8 LEVEL2_CACHE_SIZE 1048576
       9 LEVEL2_CACHE_ASSOC 16
      10 LEVEL2_CACHE_LINESIZE 64
      11 LEVEL3_CACHE_SIZE 37486592
      12 LEVEL3_CACHE_ASSOC 11
      13 LEVEL3_CACHE_LINESIZE 64
      14 LEVEL4_CACHE_SIZE 0
      15 LEVEL4_CACHE_ASSOC 0
      16 LEVEL4_CACHE_LINESIZE 0

      可以看出FLC是8路组相连,MLC是16路组相连,LLC是11路组相连

    3. lstopo-no-graphics
       1 [root@localhost home]# lstopo-no-graphics
       2 Package L#0 + L3 L#0 (36MB)
       3       L2 L#0 (1024KB) + L1d L#0 (32KB) + L1i L#0 (32KB) + Core L#0
       4         PU L#0 (P#0)
       5         PU L#1 (P#52)
       6       L2 L#1 (1024KB) + L1d L#1 (32KB) + L1i L#1 (32KB) + Core L#1
       7         PU L#2 (P#1)
       8         PU L#3 (P#53)
       9       L2 L#2 (1024KB) + L1d L#2 (32KB) + L1i L#2 (32KB) + Core L#2
      10         PU L#4 (P#2)
      11         PU L#5 (P#54)

      可以看出numa架构的关系和分布

    4. lshw
       1 *-cache:0
       2           description: L1 cache
       3           physical id: 4d
       4           slot: L1-Cache
       5           size: 1664KiB
       6           capacity: 1664KiB
       7           capabilities: synchronous internal write-back instruction
       8           configuration: level=1
       9      *-cache:1
      10           description: L2 cache
      11           physical id: 4e
      12           slot: L2-Cache
      13           size: 26MiB
      14           capacity: 26MiB
      15           capabilities: synchronous internal varies unified
      16           configuration: level=2
      17      *-cache:2
      18           description: L3 cache
      19           physical id: 4f
      20           slot: L3-Cache
      21           size: 35MiB
      22           capacity: 35MiB
      23           capabilities: synchronous internal varies unified
      24           configuration: level=3
      25 *-cache:3
      26           description: L1 cache
      27           physical id: 51
      28           slot: L1-Cache
      29           size: 1664KiB
      30           capacity: 1664KiB
      31           capabilities: synchronous internal write-back instruction
      32           configuration: level=1
      33      *-cache:4
      34           description: L2 cache
      35           physical id: 52
      36           slot: L2-Cache
      37           size: 26MiB
      38           capacity: 26MiB
      39           capabilities: synchronous internal varies unified
      40           configuration: level=2
      41      *-cache:5
      42           description: L3 cache
      43           physical id: 53
      44           slot: L3-Cache
      45           size: 35MiB
      46           capacity: 35MiB
      47           capabilities: synchronous internal varies unified
      48           configuration: level=3

      有一些属性可以参考

    5. dmidecode
        1 [root@localhost hexo]# dmidecode -t cache
        2 # dmidecode 3.0
        3 Getting SMBIOS data from sysfs.
        4 SMBIOS 2.8 present.
        5 
        6 Handle 0x004D, DMI type 7, 19 bytes
        7 Cache Information
        8  Socket Designation: L1-Cache
        9  Configuration: Enabled, Not Socketed, Level 1
       10  Operational Mode: Write Back
       11  Location: Internal
       12  Installed Size: 1664 kB
       13  Maximum Size: 1664 kB
       14  Supported SRAM Types:
       15   Synchronous
       16  Installed SRAM Type: Synchronous
       17  Speed: Unknown
       18  Error Correction Type: Parity
       19  System Type: Instruction
       20  Associativity: 8-way Set-associative
       21 
       22 Handle 0x004E, DMI type 7, 19 bytes
       23 Cache Information
       24  Socket Designation: L2-Cache
       25  Configuration: Enabled, Not Socketed, Level 2
       26  Operational Mode: Varies With Memory Address
       27  Location: Internal
       28  Installed Size: 26624 kB
       29  Maximum Size: 26624 kB
       30  Supported SRAM Types:
       31   Synchronous
       32  Installed SRAM Type: Synchronous
       33  Speed: Unknown
       34  Error Correction Type: Single-bit ECC
       35  System Type: Unified
       36  Associativity: 16-way Set-associative
       37 
       38 Handle 0x004F, DMI type 7, 19 bytes
       39 Cache Information
       40  Socket Designation: L3-Cache
       41  Configuration: Enabled, Not Socketed, Level 3
       42  Operational Mode: Varies With Memory Address
       43  Location: Internal
       44  Installed Size: 36608 kB
       45  Maximum Size: 36608 kB
       46  Supported SRAM Types:
       47   Synchronous
       48  Installed SRAM Type: Synchronous
       49  Speed: Unknown
       50  Error Correction Type: Single-bit ECC
       51  System Type: Unified
       52  Associativity: Fully Associative
       53 
       54 Handle 0x0051, DMI type 7, 19 bytes
       55 Cache Information
       56  Socket Designation: L1-Cache
       57  Configuration: Enabled, Not Socketed, Level 1
       58  Operational Mode: Write Back
       59  Location: Internal
       60  Installed Size: 1664 kB
       61  Maximum Size: 1664 kB
       62  Supported SRAM Types:
       63   Synchronous
       64  Installed SRAM Type: Synchronous
       65  Speed: Unknown
       66  Error Correction Type: Parity
       67  System Type: Instruction
       68  Associativity: 8-way Set-associative
       69 
       70 Handle 0x0052, DMI type 7, 19 bytes
       71 Cache Information
       72  Socket Designation: L2-Cache
       73  Configuration: Enabled, Not Socketed, Level 2
       74  Operational Mode: Varies With Memory Address
       75  Location: Internal
       76  Installed Size: 26624 kB
       77  Maximum Size: 26624 kB
       78  Supported SRAM Types:
       79   Synchronous
       80  Installed SRAM Type: Synchronous
       81  Speed: Unknown
       82  Error Correction Type: Single-bit ECC
       83  System Type: Unified
       84  Associativity: 16-way Set-associative
       85 
       86 Handle 0x0053, DMI type 7, 19 bytes
       87 Cache Information
       88  Socket Designation: L3-Cache
       89  Configuration: Enabled, Not Socketed, Level 3
       90  Operational Mode: Varies With Memory Address
       91  Location: Internal
       92  Installed Size: 36608 kB
       93  Maximum Size: 36608 kB
       94  Supported SRAM Types:
       95   Synchronous
       96  Installed SRAM Type: Synchronous
       97  Speed: Unknown
       98  Error Correction Type: Single-bit ECC
       99  System Type: Unified
      100  Associativity: Fully Associative

      这里面是最全面的,可以看出三级缓存是全相连。另外一级是奇偶校验的,二级和三级是ECC可以纠正一位错误的校验方式。

    6. dmesg

      

     1 [root@localhost home]# dmesg | grep cache
     2 [ 0.024720] Dentry cache hash table entries: 33554432 (order: 16, 268435456 bytes)
     3 [ 0.081708] Inode-cache hash table entries: 16777216 (order: 15, 134217728 bytes)
     4 [ 0.105769] Mount-cache hash table entries: 524288 (order: 10, 4194304 bytes)
     5 [ 0.106076] Mountpoint-cache hash table entries: 524288 (order: 10, 4194304 bytes)
     6 [ 2.743578] PCI: pci_cache_line_size set to 64 bytes
     7 [ 3.450593] Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
     8 [ 3.559022] xhci_hcd 0000:00:14.0: cache line size of 64 is not supported
     9 [688870.188178] bash (322228): drop_caches: 3
    10 [688886.365874] bash (322228): drop_caches: 2
    11 [688894.903068] bash (322228): drop_caches: 1

    参考:

    https://superuser.com/questions/55776/how-to-find-the-l2-cache-size-in-linux/55777

    windows可以下载一个工具,coreinfo

     1 Logical Processor to Cache Map:
     2 **------------------------------------------------------  Data Cache          0, Level 1,   32 KB, Assoc   8, LineSize  64
     3 **------------------------------------------------------  Instruction Cache   0, Level 1,   32 KB, Assoc   8, LineSize  64
     4 **------------------------------------------------------  Unified Cache       0, Level 2,  256 KB, Assoc   8, LineSize  64
     5 ****************************----------------------------  Unified Cache       1, Level 3,   35 MB, Assoc  20, LineSize  64
     6 --**----------------------------------------------------  Data Cache          1, Level 1,   32 KB, Assoc   8, LineSize  64
     7 --**----------------------------------------------------  Instruction Cache   1, Level 1,   32 KB, Assoc   8, LineSize  64
     8 --**----------------------------------------------------  Unified Cache       2, Level 2,  256 KB, Assoc   8, LineSize  64
     9 ----**--------------------------------------------------  Data Cache          2, Level 1,   32 KB, Assoc   8, LineSize  64
    10 ----**--------------------------------------------------  Instruction Cache   2, Level 1,   32 KB, Assoc   8, LineSize  64
    11 ----**--------------------------------------------------  Unified Cache       3, Level 2,  256 KB, Assoc   8, LineSize  64
    12 ------**------------------------------------------------  Data Cache          3, Level 1,   32 KB, Assoc   8, LineSize  64
    13 ------**------------------------------------------------  Instruction Cache   3, Level 1,   32 KB, Assoc   8, LineSize  64
    14 ------**------------------------------------------------  Unified Cache       4, Level 2,  256 KB, Assoc   8, LineSize  64
    15 --------**----------------------------------------------  Data Cache          4, Level 1,   32 KB, Assoc   8, LineSize  64
    16 --------**----------------------------------------------  Instruction Cache   4, Level 1,   32 KB, Assoc   8, LineSize  64
    17 --------**----------------------------------------------  Unified Cache       5, Level 2,  256 KB, Assoc   8, LineSize  64
    18 ----------**--------------------------------------------  Data Cache          5, Level 1,   32 KB, Assoc   8, LineSize  64
    19 ----------**--------------------------------------------  Instruction Cache   5, Level 1,   32 KB, Assoc   8, LineSize  64
    20 ----------**--------------------------------------------  Unified Cache       6, Level 2,  256 KB, Assoc   8, LineSize  64
    21 ------------**------------------------------------------  Data Cache          6, Level 1,   32 KB, Assoc   8, LineSize  64
    22 ------------**------------------------------------------  Instruction Cache   6, Level 1,   32 KB, Assoc   8, LineSize  64
    23 ------------**------------------------------------------  Unified Cache       7, Level 2,  256 KB, Assoc   8, LineSize  64
    24 --------------**----------------------------------------  Data Cache          7, Level 1,   32 KB, Assoc   8, LineSize  64
    25 --------------**----------------------------------------  Instruction Cache   7, Level 1,   32 KB, Assoc   8, LineSize  64
    26 --------------**----------------------------------------  Unified Cache       8, Level 2,  256 KB, Assoc   8, LineSize  64
    27 ----------------**--------------------------------------  Data Cache          8, Level 1,   32 KB, Assoc   8, LineSize  64
    28 ----------------**--------------------------------------  Instruction Cache   8, Level 1,   32 KB, Assoc   8, LineSize  64
    29 ----------------**--------------------------------------  Unified Cache       9, Level 2,  256 KB, Assoc   8, LineSize  64
    30 ------------------**------------------------------------  Data Cache          9, Level 1,   32 KB, Assoc   8, LineSize  64
    31 ------------------**------------------------------------  Instruction Cache   9, Level 1,   32 KB, Assoc   8, LineSize  64
    32 ------------------**------------------------------------  Unified Cache      10, Level 2,  256 KB, Assoc   8, LineSize  64
    33 --------------------**----------------------------------  Data Cache         10, Level 1,   32 KB, Assoc   8, LineSize  64
    34 --------------------**----------------------------------  Instruction Cache  10, Level 1,   32 KB, Assoc   8, LineSize  64
    35 --------------------**----------------------------------  Unified Cache      11, Level 2,  256 KB, Assoc   8, LineSize  64
    36 ----------------------**--------------------------------  Data Cache         11, Level 1,   32 KB, Assoc   8, LineSize  64
    37 ----------------------**--------------------------------  Instruction Cache  11, Level 1,   32 KB, Assoc   8, LineSize  64
    38 ----------------------**--------------------------------  Unified Cache      12, Level 2,  256 KB, Assoc   8, LineSize  64
    39 ------------------------**------------------------------  Data Cache         12, Level 1,   32 KB, Assoc   8, LineSize  64
    40 ------------------------**------------------------------  Instruction Cache  12, Level 1,   32 KB, Assoc   8, LineSize  64
    41 ------------------------**------------------------------  Unified Cache      13, Level 2,  256 KB, Assoc   8, LineSize  64
    42 --------------------------**----------------------------  Data Cache         13, Level 1,   32 KB, Assoc   8, LineSize  64
    43 --------------------------**----------------------------  Instruction Cache  13, Level 1,   32 KB, Assoc   8, LineSize  64
    44 --------------------------**----------------------------  Unified Cache      14, Level 2,  256 KB, Assoc   8, LineSize  64
    45 ----------------------------**--------------------------  Data Cache         14, Level 1,   32 KB, Assoc   8, LineSize  64
    46 ----------------------------**--------------------------  Instruction Cache  14, Level 1,   32 KB, Assoc   8, LineSize  64
    47 ----------------------------**--------------------------  Unified Cache      15, Level 2,  256 KB, Assoc   8, LineSize  64
    48 ----------------------------****************************  Unified Cache      16, Level 3,   35 MB, Assoc  20, LineSize  64
    49 ------------------------------**------------------------  Data Cache         15, Level 1,   32 KB, Assoc   8, LineSize  64
    50 ------------------------------**------------------------  Instruction Cache  15, Level 1,   32 KB, Assoc   8, LineSize  64
    51 ------------------------------**------------------------  Unified Cache      17, Level 2,  256 KB, Assoc   8, LineSize  64
    52 --------------------------------**----------------------  Data Cache         16, Level 1,   32 KB, Assoc   8, LineSize  64
    53 --------------------------------**----------------------  Instruction Cache  16, Level 1,   32 KB, Assoc   8, LineSize  64
    54 --------------------------------**----------------------  Unified Cache      18, Level 2,  256 KB, Assoc   8, LineSize  64
    55 ----------------------------------**--------------------  Data Cache         17, Level 1,   32 KB, Assoc   8, LineSize  64
    56 ----------------------------------**--------------------  Instruction Cache  17, Level 1,   32 KB, Assoc   8, LineSize  64
    57 ----------------------------------**--------------------  Unified Cache      19, Level 2,  256 KB, Assoc   8, LineSize  64
    58 ------------------------------------**------------------  Data Cache         18, Level 1,   32 KB, Assoc   8, LineSize  64
    59 ------------------------------------**------------------  Instruction Cache  18, Level 1,   32 KB, Assoc   8, LineSize  64
    60 ------------------------------------**------------------  Unified Cache      20, Level 2,  256 KB, Assoc   8, LineSize  64
    61 --------------------------------------**----------------  Data Cache         19, Level 1,   32 KB, Assoc   8, LineSize  64
    62 --------------------------------------**----------------  Instruction Cache  19, Level 1,   32 KB, Assoc   8, LineSize  64
    63 --------------------------------------**----------------  Unified Cache      21, Level 2,  256 KB, Assoc   8, LineSize  64
    64 ----------------------------------------**--------------  Data Cache         20, Level 1,   32 KB, Assoc   8, LineSize  64
    65 ----------------------------------------**--------------  Instruction Cache  20, Level 1,   32 KB, Assoc   8, LineSize  64
    66 ----------------------------------------**--------------  Unified Cache      22, Level 2,  256 KB, Assoc   8, LineSize  64
    67 ------------------------------------------**------------  Data Cache         21, Level 1,   32 KB, Assoc   8, LineSize  64
    68 ------------------------------------------**------------  Instruction Cache  21, Level 1,   32 KB, Assoc   8, LineSize  64
    69 ------------------------------------------**------------  Unified Cache      23, Level 2,  256 KB, Assoc   8, LineSize  64
    70 --------------------------------------------**----------  Data Cache         22, Level 1,   32 KB, Assoc   8, LineSize  64
    71 --------------------------------------------**----------  Instruction Cache  22, Level 1,   32 KB, Assoc   8, LineSize  64
    72 --------------------------------------------**----------  Unified Cache      24, Level 2,  256 KB, Assoc   8, LineSize  64
    73 ----------------------------------------------**--------  Data Cache         23, Level 1,   32 KB, Assoc   8, LineSize  64
    74 ----------------------------------------------**--------  Instruction Cache  23, Level 1,   32 KB, Assoc   8, LineSize  64
    75 ----------------------------------------------**--------  Unified Cache      25, Level 2,  256 KB, Assoc   8, LineSize  64
    76 ------------------------------------------------**------  Data Cache         24, Level 1,   32 KB, Assoc   8, LineSize  64
    77 ------------------------------------------------**------  Instruction Cache  24, Level 1,   32 KB, Assoc   8, LineSize  64
    78 ------------------------------------------------**------  Unified Cache      26, Level 2,  256 KB, Assoc   8, LineSize  64
    79 --------------------------------------------------**----  Data Cache         25, Level 1,   32 KB, Assoc   8, LineSize  64
    80 --------------------------------------------------**----  Instruction Cache  25, Level 1,   32 KB, Assoc   8, LineSize  64
    81 --------------------------------------------------**----  Unified Cache      27, Level 2,  256 KB, Assoc   8, LineSize  64
    82 ----------------------------------------------------**--  Data Cache         26, Level 1,   32 KB, Assoc   8, LineSize  64
    83 ----------------------------------------------------**--  Instruction Cache  26, Level 1,   32 KB, Assoc   8, LineSize  64
    84 ----------------------------------------------------**--  Unified Cache      28, Level 2,  256 KB, Assoc   8, LineSize  64
    85 ------------------------------------------------------**  Data Cache         27, Level 1,   32 KB, Assoc   8, LineSize  64
    86 ------------------------------------------------------**  Instruction Cache  27, Level 1,   32 KB, Assoc   8, LineSize  64
    87 ------------------------------------------------------**  Unified Cache      29, Level 2,  256 KB, Assoc   8, LineSize  64

    参考:


    万事走心 精益求美


  • 相关阅读:
    家里蹲大学数学杂志期刊模式目录
    [历朝通俗演义-蔡东藩-前汉]第008回 葬始皇骊山成巨冢 戮宗室豻狱构奇冤
    [历朝通俗演义-蔡东藩-前汉]第007回 寻生路徐市垦荒 从逆谋李斯矫诏
    [历朝通俗演义-蔡东藩-前汉]第006回 阬深谷诸儒毙命 得原璧暴主惊心
    [历朝通俗演义-蔡东藩-前汉]第005回 信佞臣尽毁诗书 筑阿房大兴土木
    [历朝通俗演义-蔡东藩-前汉]第004回 误椎击逃生遇异士 见图谶遣将造长城
    [历朝通俗演义-蔡东藩-前汉]第003回 封泰岱下山避雨 过湘江中渡惊风
    [历朝通俗演义-蔡东藩]
    [历朝通俗演义-蔡东藩-前汉]第002回 诛假父纳言迎母 称皇帝立法愚民
    [历朝通俗演义-蔡东藩-前汉]第001回 移花接木计献美姬 用李代桃欢承淫后
  • 原文地址:https://www.cnblogs.com/kongchung/p/9334782.html
Copyright © 2020-2023  润新知