How do I programmatically disable hardware prefetching?

You can enable or disable the hardware prefetchers using msr-tools

The following enables the hardware prefetcher (by unsetting bit 9):

[root@... msr-tools-1.2]# ./wrmsr -p 0 0x1a0 0x60628e2089 
[root@... msr-tools-1.2]# ./rdmsr 0x1a0 

The following disables the hardware prefetcher (by enabling bit 9):

[root@... msr-tools-1.2]# ./wrmsr -p 0 0x1a0 0x60628e2289 
[root@... msr-tools-1.2]# ./rdmsr 0x1a0 

Programatically, you can do this as root by opening /dev/cpu/<cpunumber>/msr and
using pwrite to write to the msr “file” at the 0x1a0 offset.

Leave a Comment