姬長信(Redy)

linux – 如何以编程方式禁用硬件预取?


我想以编程方式禁用硬件预取.

Optimizing Application Performance on Intel? Core? Microarchitecture Using Hardware-Implemented Prefetchers
How to Choose between Hardware and Software Prefetch on 32-Bit Intel? Architecture,
我需要更新MSR以禁用硬件预取.

这是一个相关的片段:

“DPL Prefetch and L2 Streaming Prefetch settings can also be changed programmatically
by writing a device driver utility for changing the bits in the IA32_MISC_ENABLE
register – MSR 0x1A0. Such a utility offers the ability to enable or disable prefetch
mechanisms without requiring any server downtime.

下表显示了IA32_MISC_ENABLE MSR中为了控制DPL和L2 Streaming Prefetch而必须更改的位:

Prefetcher Type MSR (0x1A0) Bit Value 
DPL (Hardware Prefetch) Bit 9 0 = Enable 1 = Disable 
L2 Streamer (Adjacent Cache Line Prefetch) Bit 19 0 = Enable 1 = Disable"

我尝试使用http://etallen.com/msr.html,但这不起作用.
我也尝试直接在asm / msr.h中使用wrmsr但是段错误.
我尝试在内核模块中执行此操作…并杀死了计算机.

BTW – 我使用的是内核2.6.18-92.el5,它在内核中链接了MSR:

$grep -i msr /boot/config-$(uname -r)
CONFIG_X86_MSR=y
...