x86intelcpu-cacheprefetchmsr

Correctly disable Hardware Prefetching with MSR in Skylake


I am trying to disable hardware prefetching on my machine:

CPU family: 6

Model: 78

Model name: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz

I have checked with: gcc -march=native -Q --help=target|grep march - command and it's Skylake microarchitecture.

I have installed msr-tools. grep -i msr /boot/config-$(uname -r) this gives result: CONFIG_X86_MSR=m - I am not sure it's necessary to set it Y, or how to do that. I was trying to use this posts:

How do I programmatically disable hardware prefetching?

Unable to disable Hardware prefetcher in Core i7

However I assume posts are a bit old and don't use 0x1a4 address. Also in comments it's not described how exactly to do it with this address, or whether there is no difference between modifying 0x1a4 or 0x1a0.

I have read this article: https://software.intel.com/en-us/articles/disclosure-of-hw-prefetcher-control-on-some-intel-processors which says that it's possible to disable prefetching with setting 0-3 bits to 1's in 0x1A4. modprobe msr - executing this command does not give errors (does not print any message either). then I am trying this two commands:

$ sudo wrmsr -p 0 0x1a4 15 //for core 0

$ sudo wrmsr -p 2 0x1a4 15 //for core 2

15 is for setting all last 4 bits to 1's

Could you help me to make sure I am correctly disabling Prefetchers? As I made a lot of assumptions for sudo wrmsr -p 0 0x1a4 15 - command I am not sure I am using it correctly. I tried to provide with all the information but if anything else is necessary let me know. (I have shortened the post as I guess it was too long to go through)


Solution

  • I found that this commands are working correctly. sudo modprobe msr - should be executed first though. The main problem was the way I was testing it with papi events