2012-07-21 43 views
2

我在我的PC上使用Ubuntu 12.04和Intel i5 450。 我使用了两种方法来获得1级指令缓存的缓存行大小。 但结果不同。获取2个不同的L1 icache线路尺寸

[email protected]:~/ws$ getconf LEVEL1_ICACHE_LINESIZE 

32 


[email protected]:~/ws$ cat /sys/devices/system/cpu/cpu0/cache/index1/coherency_line_size 

64 

有什么问题吗?它很混乱。

+0

你对'cat/sys/devices/system/cpu/cpu0/cache/index1/{level,type}'有什么建议? – 2012-07-21 02:48:46

+0

cat/sys/devices/system/cpu/cpu0/cache/index1/{level,type} 指令 – firo 2013-07-13 07:57:15

回答

1

鉴于英特尔的CPU,并假设标准的Linux/glibc的和没有cpuid虚拟化......

getconf/sysconf()报告的缓存值来自的glibc的i386/sysconf.c。 sysfs中的那些来自intel_cacheinfo.c

最明显的区别是,只有sysfs中从cpuid 4在cpuid 2返回值,而sysconf()第一外观和只检查cpuid 4如果其中一个字节是0xFF。有一个入口之间为0×09在sysconf.c差异:与表3-22 Intel® 64 and IA-32 Architectures Software Developer’s Manual

{ 0x09, 4, 32, M(_SC_LEVEL1_ICACHE_SIZE), 32768 }, 

09H |缓存| 1级指令缓存:32KBytes,4路组关联,64字节线路尺寸

所以它看起来像一个glibc中的错误。

0

getconf返回内核配置值,其语义由内核代码确定,而/ sys返回cpu的物理特性。为了理解这种差异,你需要检查在内核代码中如何使用内核配置变量。