Search code examples
x86intelcpu-architecturemsr

Reading Current Uncore Frequency and Setting Uncore Frequency Multipliers


I'm working on a project that requires reading and setting Uncore Frequency on an Intel Skylake Xeon Gold 6126 Server CPU (I will need to do the same for another Haswell based processor). I'm running an Ubuntu with Linux 4.15.0-134. I've loaded the msr kernel module. I am now trying to first read the current Uncore frequency. I am doing the following:

sudo wrmsr 0x700 0x2000000000000000
sudo wrmsr 0x703 0x400000
sudo rdmsr 0x704

I found the above solution on an Intel discussion thread

However, I am now trying to modify the minimum and maximum uncore frequencies. To do that I am first trying to read the minimum frequency (to store it for later reference):

sudo rdmsr 0x620

The above returns 1818. I'm not sure what this number is. The technical document calls the first 7 bits of it a minimum frequency ratio (which would have a value of 24 in decimal). But I am not sure what this value is. Furthermore, according to the document, bits 8-14 store the maximum frequency ratio. However, the bits 8-14 turn out to be 24 as well.

Could someone please explain what these values are? And which value are they calculated in respect to?

Also, would changing the uncore frequency simply require writing to the appropriate bits of register at 0x620, like so?

sudo wrmsr 0x620 0x1c18

I would be extremely grateful for any guidance with regards to the aforementioned questions.


Solution

  • Your uncore frequency monitoring approach is correct. You must enable the monitoring in (U_MSR_PMON_FIXED_CTL) and then you may read the performance counter (U_MSR_PMON_FIXED_CTR). From my experience writing to U_MSR_PMON_GLOBAL_CTL is not necessary. See Uncore performance monitoring manual.

    Your uncore frequency ration 24, represents frequency 2.4 GHz, which you will be able to see from the U_MSR_PMON_FIXED_CTR.

    In default the MSR_UNCORE_RATIO_LIMIT keeps the minimum and the maximum possible values, which are not the same. As of I know, these limits are not stored in any other available MSR, so you should store them. Rebooting the system will restore the default values.

    Two extra hints:

    To read/write MSRs on Intel (also works fine for AMD CPUs) it is good approach to use msr-safe, since it allows access registers without sudo rights based on a list of registers (specifying which register can be accessed) and their masks (specifying which bits can be written).

    To tune and monitor (not-only) uncore frequency you may use my library MERIC.