码迷,mamicode.com
首页 > 系统相关 > 详细

Linux下查询CPU 缓存的工具

时间:2014-08-01 13:38:51      阅读:376      评论:0      收藏:0      [点我收藏+]

标签:des   style   使用   os   io   数据   for   问题   

在Linux下可以使用如下工具查询CPU缓存:

方式1:

$ lscpu

L1d cache:             32K <span style="white-space:pre">	</span>(一级数据缓存)
L1i cache:             32K <span style="white-space:pre">	</span><span style="font-family: Arial, Helvetica, sans-serif;">(一级指令缓存)</span>
L2 cache:              256K <span style="white-space:pre">	</span>(二级缓存)
L3 cache:              8192K<span style="white-space:pre">	</span>(三级缓存)


方式2:

$ cat /sys/devices/system/cpu/cpu0/cache/index0/size
32K
$ cat /sys/devices/system/cpu/cpu0/cache/index0/level
1
$ cat /sys/devices/system/cpu/cpu0/cache/index1/size
32K
$ cat /sys/devices/system/cpu/cpu0/cache/index1/level
1
$ cat /sys/devices/system/cpu/cpu0/cache/index2/size
256K
$ cat /sys/devices/system/cpu/cpu0/cache/index2/level
2
$ cat /sys/devices/system/cpu/cpu0/cache/index3/size8192K
$ cat /sys/devices/system/cpu/cpu0/cache/index3/level
3

方式3:

$ sudo dmidecode -t cache
但是结果与上述的有出路, 显示的L1缓存是256kB, L2缓存是1024 kB, 算上8核, 也与实现不符.

可能程序自身有点问题, 不建议用dmidecode.


# dmidecode 2.12
SMBIOS 2.7 present.

Handle 0x003B, DMI type 7, 19 bytes
Cache Information
	Socket Designation: CPU Internal L1
	Configuration: Enabled, Not Socketed, Level 1
	Operational Mode: Write Back
	Location: Internal
	Installed Size: 256 kB
	Maximum Size: 256 kB

Handle 0x003C, DMI type 7, 19 bytes
Cache Information
	Socket Designation: CPU Internal L2
	Configuration: Enabled, Not Socketed, Level 2
	Operational Mode: Write Back
	Location: Internal
	Installed Size: 1024 kB
	Maximum Size: 1024 kB

Handle 0x003D, DMI type 7, 19 bytes
Cache Information
	Socket Designation: CPU Internal L3
	Configuration: Enabled, Not Socketed, Level 3
	Operational Mode: Write Back
	Location: Internal
	Installed Size: 8192 kB
	Maximum Size: 8192 kB


方式4:

$ cat /proc/cpuinfo 

cache size	: 8192 KB

这个只是显示出 L3 cache的大小, 也并不准确.

Linux下查询CPU 缓存的工具,布布扣,bubuko.com

Linux下查询CPU 缓存的工具

标签:des   style   使用   os   io   数据   for   问题   

原文地址:http://blog.csdn.net/robertsong2004/article/details/38334353

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!