linux查看CPU高速缓存(cache)信息
2015-11-24 12:26
776 查看
一、Linux下查看CPU Cache级数,每级大小
(1) 第一种方法:
dmesg | grep cache
(2) 第二种方法:
[root@gc15 ~]# ls /sys/devices/system/cpu/cpu0/cache/index
index0/ index1/ index2/ index3/
一级cache, Data cache
index0和Index1是一级cache中的data和instruction cache
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index0/level
1
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index0/type
Data
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index0/size
32K
一级cache, Instruction cache
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index1/level
1
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index1/type
Instruction
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index1/size
32K
二级cache,共享的
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index2/level
2
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index3/type
Unified
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index2/size
256K
三级cache,共享的
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index3/level
3
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index3/type
Unified
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index3/size
12288K
二、查看Cache的关联方式
在 /sys/devices/system/cpu/中查看相应的文件夹
如查看cpu0 的一级缓存中的有多少组,
如查看cpu0的一级缓存中一组中的行数
三、查看cache_line的大小
上面以本人电脑的cpu一级缓存为例知道了cpu0的一级缓存的大小:32k,其包含64个(sets)组,每组有8(ways),则可以算出每一个way(cache_line)的大小 cache_line = 32*1024/(64*8)=64 bytes。当然我们也可以通过以下命令查出cache_line的大小(单位是字节)
或者
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name
: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
stepping : 3
cpu MHz : 3497.664
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq
dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm sse4_1 sse4_2 movbe popcnt aes xsave avx lahf_lm abm ida arat tpr_shadow vnmi flexpriority ept vpid
bogomips : 6995.32
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
(1) 第一种方法:
dmesg | grep cache
(2) 第二种方法:
[root@gc15 ~]# ls /sys/devices/system/cpu/cpu0/cache/index
index0/ index1/ index2/ index3/
一级cache, Data cache
index0和Index1是一级cache中的data和instruction cache
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index0/level
1
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index0/type
Data
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index0/size
32K
一级cache, Instruction cache
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index1/level
1
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index1/type
Instruction
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index1/size
32K
二级cache,共享的
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index2/level
2
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index3/type
Unified
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index2/size
256K
三级cache,共享的
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index3/level
3
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index3/type
Unified
[root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index3/size
12288K
二、查看Cache的关联方式
在 /sys/devices/system/cpu/中查看相应的文件夹
如查看cpu0 的一级缓存中的有多少组,
$ cat /sys/devices/system/cpu/cpu0/cache/index0/number_of_sets $64
如查看cpu0的一级缓存中一组中的行数
$cat /sys/devices/system/cpu/cpu0/cache/index0/ways_of_associativity $8
三、查看cache_line的大小
上面以本人电脑的cpu一级缓存为例知道了cpu0的一级缓存的大小:32k,其包含64个(sets)组,每组有8(ways),则可以算出每一个way(cache_line)的大小 cache_line = 32*1024/(64*8)=64 bytes。当然我们也可以通过以下命令查出cache_line的大小(单位是字节)
$ cat /sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size
或者
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name
: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
stepping : 3
cpu MHz : 3497.664
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq
dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm sse4_1 sse4_2 movbe popcnt aes xsave avx lahf_lm abm ida arat tpr_shadow vnmi flexpriority ept vpid
bogomips : 6995.32
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
相关文章推荐
- linux相关指令
- CentOS更改yum源与更新系统
- CentOS 修改yum源为国内源
- 通达OA2008从windows环境移植到linux部署手册
- 通达OA2008从windows环境移植到linux部署手册
- 在Linux系统上安装配置DNS服务器的教程
- CentOS6.5配置dns服务
- 在Linux系统如何让程序开机时自动启动
- Linux文件系统基本目录结构概述
- 用vsftpd搭建ftp服务器之CentOS6.7
- Linux开机启动程序详解
- centos java 之旅
- linux权限 study
- Centos7 设置IPtables
- linux系统644、755、777权限详解
- linux命令学习笔记(30): chown命令
- CentOs vim vi 上下左右键 变成ABCD 问题解决
- linux命令学习笔记( 2 ) : cd 命令
- linux命令学习笔记(1):ls命令
- linux命令学习笔记(3):pwd命令