Correctly disable Hardware Prefetching with MSR in Skylake
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
How do I programmatically disable hardware prefetching?
From the Intel reference:
This instruction must be executed at privilege level 0 or in real-address mode; otherwise, a general protection exception #GP(0) will be generated. Specifying a reserved or unimplemented MSR address in ECX will also cause a general protection exception.
...
The CPUID instruction should be used to determine whether MSRs are supported (EDX[5]=1)
before using this instruction.
So, your fault might be related to a cpu that doesn't support MSRs or using the wrong MSR address.
There are lots of examples of using the MSRs in the kernel source:
In the kernel source, for a single cpu, it demonstrates disabling prefetch for the Xeon in arch/i386/kernel/cpu/intel.c, in the function:
static void __cpuinit Intel_errata_workarounds(struct cpuinfo_x86 *c)
The rdmsr function arguments are the msr number, a pointer to the low 32 bit word, and a pointer to the high 32 bit word.
The wrmsr function arguments are the msr number, the low 32 bit word value, and the high 32 bit word value.
multi-core or smp systems have to pass the cpu struct in as the first argument:
void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
Related Topics
How to Merge Two Rows in a Same Row from a Text File in Linux Shell Script
Compile Git for 32-Bit Linux on Shared Hosting
How to Make Linux Power Off When Halt Is Run
Curl Command Doesn't Work in Bash Script
Is Ethernet Checksum Exposed via Af_Packet
Mathematical Expression Result Assigned to a Bash Variable
Will Data Written via Write() Be Flushed to Disk If a Process Is Killed
Remove Left and Right Square Brackets Using Sed/Bash
Safely Remembering Ssh Credentials in Bash Script
How to Disable Hardware Prefetcher in Core I7
How to Set the Socket Option So_Reuseport in Rust
Why Can't Cuda's Examples Makefile Find the Cuda Libraries
Why Fftw on Windows Is Faster Than on Linux
Shell Function Does Not Return Values Greater Than 255
Average of Multiple Files Without Considering Missing Values