3

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.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Tez_Nikka
  • 115
  • 7
  • 1
    Read [this](https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Skylake-Mesh-Frequency/td-p/1159733). The 0x1818 value is a pair of *ratio values*, which means they must be multiplied by the base clock to get the actual uncore clock. The ratios can be equal, to force the uncore to use a single frequency. You can probably step down the min value but I suspect you can't ramp up the max value (i.e. it is capped), but IDK. The base frequency is 100Mhz, one can guess that by the ratio values (133 or 166Mhz would give too high frequencies). You can simply write to the MSR to scale down ... – Margaret Bloom Feb 07 '21 at 15:57
  • 1
    ... the frequency but the uncore PMU may ignore your request. This should also work for Haswell. Thanks to the uncore PMC you can read back its frequency to get a feedback after writing to the MSR (give it a little time to eventually transition to the new frequency). – Margaret Bloom Feb 07 '21 at 15:58
  • Hmm. I'm sorry, I feel like I don't understand. With 0x1818 each ratio value becomes 24. Based on this the uncore frequency would be 2400Mhz, right? I feel like I have misunderstood the calculations. Additionally, when I read the uncore frequency from 0x704, I get significantly higher values than even 2400Mhz. For example: 32197801070365, 32203168839323. What are these values? Based on the link that you provided these should be uncore clock frequencies. Also, modifying the ratio values in 0x620 unfortunately does not seem to impact the values obtained by reading 0x704. – Tez_Nikka Feb 08 '21 at 17:32
  • 1
    I don't think you got it wrong. 24 is the ratio, the base clock seems to be 100Mhz according to that link. 2,4Ghz seems fine for an uncore frequency. According to the docs, the `MSR_U_PMON_UCLK_FIXED_CTR` is **incremented** by one at each tick of the uncore clock, I think you have to look at two reads separated by a known quantity of time to get the frequency. – Margaret Bloom Feb 08 '21 at 21:43

1 Answers1

1

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.

Andrew
  • 958
  • 13
  • 25