Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

How can I lock my Xeon CPU frequency in Ubuntu?

pang__pu
Beginner
12,250 Views

Hi, 

Recently I'm trying to set my CPU frequency to a fixed value for my research. It seems a simply issue but there is a problem.

My machine is a Server (Dell PowerEdge R730xd). The CPU is Intel Xeon E5 2630 v4 2.2GHz. The OS and kernel is Ubuntu 16.04 and 4.15.0-33-generic. The current settings are as follows:

1) intel_pstate driver is disabled (Add "intel_pstate=disable" to /etc/default/grub)

    cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver will show acpi-cpufreq

2) userspace governor is used (sudo cpupower frequency-set -g userspace)

    cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor will show userspace

3) the target frequency is set (sudo cpupower frequency-set -f 2.2G)

    cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq will show 2200000

4) the current BIOS power management settings are as follows:

  • CPU Power Management -> OS DBPM (i.e., OS Control)
  • Memory Frequency -> Maximum Performance
  • Turbo Boost -> Disabled
  • C1E -> Disabled (When set to Enabled, the processor is allowed to switch to minimum performance state when idle)
  • C States -> Disabled (C States allow the processor to enter lower power states when idle)
  • Collaborative CPU Performace Control -> Enabled
  • Uncore Frequency -> Maximum
  • Energy Efficient Policy -> Performance (And there are other options, e.g., Balanced Performance / Balanced Energy / Energy Efficient
  • Monitor/Mwait -> Enabled    

However, by using watch -n 1 "cat /proc/cpuinfo | grep MHz" to monitor the current CPU frequency, I find that the frequency is always changing. (Using i7z is the same). Only when the load becomes higher (e.g., use stress -c 40) the CPU frequency will remain stable in 2.2GHz.

So, how can I lock my CPU frequency? Any help is really appreciated!

0 Kudos
1 Solution
McCalpinJohn
Honored Contributor III
12,250 Views

Your configuration options look good.  The only other obvious option is to add "poll=idle" to the boot line (to eliminate the use of C1 state), but that may be a big problem if you have HyperThreading enabled.

Due to the inability to control the duration of the timing interval, I would not trust /proc/cpuinfo for (or "cpupower frequency-info") to get the frequency.   I often find that the frequency reported by these varies between 1.2 GHz and the requested frequency.  I get much more stable numbers with my own "active spinner" program that reads the fixed-function counters and the TSC, increments a counter a billion times,  reads the counters again, reports the elapsed core cycles, reference cycles, instructions, and the computed average utilization, average frequency, and average IPC.  (The program repeats forever until killed.)   

 

You might also want to check the value in MSR 0x64c (MSR_TURBO_ACTIVATION_RATIO).  Requests for this frequency or higher are considered by the hardware to be requests for the maximum Turbo frequency.  I have seen this configured incorrectly on some systems to be lower than the nominal frequency -- so requests for the nominal frequency are interpreted as "max Turbo" requests.

View solution in original post

0 Kudos
7 Replies
pang__pu
Beginner
12,250 Views

Help!

0 Kudos
Kishore__Nanda
Beginner
12,250 Views

What happens when you do,

sudo cpupower frequency-set -g performance ?

This should put the CPU to max non-turbo freq. which is 2.2GHz.

userspace governor is similar to ondemand which is Demand based P-state switching.

0 Kudos
McCalpinJohn
Honored Contributor III
12,251 Views

Your configuration options look good.  The only other obvious option is to add "poll=idle" to the boot line (to eliminate the use of C1 state), but that may be a big problem if you have HyperThreading enabled.

Due to the inability to control the duration of the timing interval, I would not trust /proc/cpuinfo for (or "cpupower frequency-info") to get the frequency.   I often find that the frequency reported by these varies between 1.2 GHz and the requested frequency.  I get much more stable numbers with my own "active spinner" program that reads the fixed-function counters and the TSC, increments a counter a billion times,  reads the counters again, reports the elapsed core cycles, reference cycles, instructions, and the computed average utilization, average frequency, and average IPC.  (The program repeats forever until killed.)   

 

You might also want to check the value in MSR 0x64c (MSR_TURBO_ACTIVATION_RATIO).  Requests for this frequency or higher are considered by the hardware to be requests for the maximum Turbo frequency.  I have seen this configured incorrectly on some systems to be lower than the nominal frequency -- so requests for the nominal frequency are interpreted as "max Turbo" requests.

0 Kudos
pang__pu
Beginner
12,250 Views

Hi, Kishore

Thank you for your reply.

If I run sudo cpupower frequency-set -g performance, the frequencies of cores will change from 1.2GHz to 2.2GHz at all times, but they will not stay at 2.2 GHz.

 

0 Kudos
pang__pu
Beginner
12,250 Views

Hi, Dr. Bandwidth

Thank you for your reply.

Add idel = poll to grub has solved my problem. That is great!

0 Kudos
Kishore__Nanda
Beginner
12,250 Views

Thanks Dr. Bandwidth,

Yes, I have seen "idle=poll" pegging the CPU to constant freq. (if Turbo is ON, max all core Turbo. If not, max non-turbo ratio).

You can do this w/o having to reboot the host by:

cpupower idle-set -D 0 -----> -D 0 means exit latency is 0 microSec. Always in C0 state.

0 Kudos
Muyassarov__Feruz
12,250 Views

Hello everyone,

I have a question regarding the fixed value for the CPU frequency and  cooling fan speed.

I have Intel NUC ( Intel Core, i7-6770 HQ CPU@ 2.60 GHz)

1. Is it possible to run CPU at some fixed frequency? If yes, is it suppose to be configured from BIOS?

2. Is there are any way to configure the cooling fan speed for a fixed value? If yes, how?

 

Thank you very much in advance.

0 Kudos
Reply