How do I programmatically disable hardware prefetching?

前端 未结 4 1665
别那么骄傲
别那么骄傲 2020-11-27 03:05

I would like to programmatically disable hardware prefetching.

From Optimizing Application Performance on Intel® Core™ Microarchitecture Using Hardware-Implemented

4条回答
  •  渐次进展
    2020-11-27 03:54

    You can enable or disable the hardware prefetchers using msr-tools http://www.kernel.org/pub/linux/utils/cpu/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 
    60628e2089
    

    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 
    60628e2289
    

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

提交回复
热议问题