Running XenServer at Home? Enable CPU Frequency Scaling to Save Energy

As of version 6.5, XenServer ships with the performance CPU governor selected by default. This governor, or power policy, runs the processor at its maximum frequency 100% of the time, no matter the load.

If you’re running XenServer at home or some other power-conscious environment, enabling Intel SpeedStep/AMD PowerNow! (known as frequency scaling in its brand-agnostic form) can lower processor power consumption by as much as 10-15 watts by throttling the clock speed when idle.

View the Current Governor and Clock Speed

# xenpm get-cpufreq-para
cpu id              : 0
affected_cpus       : 0
cpuinfo frequency   : max [3401000] min [1600000] cur [3401000]
scaling_driver      : acpi-cpufreq
scaling_avail_gov   : userspace performance powersave ondemand
current_governor    : performance
scaling_avail_freq  : *3401000 3400000 3300000 3100000 3000000 2900000 2800000 2600000 2500000 2400000 2200000 2100000 2000000 1900000 1700000 1600000
scaling frequency   : max [3401000] min [1600000] cur [3401000]
turbo mode          : enabled
...

My processor’s nominal clock speed is 3.4 GHz, or 3400000 Hz. The *3401000 figure shown above is Xen’s way of referring to turbo mode, which is 3.9 GHz for this processor. With the performance governor, the CPU is constantly running at 3.4-3.9 GHz, even when idle.

Switch to a Power-Saving Governor

Energy-efficient governors available on XenServer include:

  • ondemand, which dynamically scales the CPU’s clock speed based on the load, and
  • powersave, which caps the CPU at its minimum frequency 100% of the time (i.e. the opposite of the performance governor).

Unless you’re willing to substantially limit performance in favor of power savings, the ondemand governor is generally the way to go.

In the XenServer console, run:

# xenpm set-scaling-governor ondemand

To persist this change so that it sticks across reboots, run:

# /opt/xensource/libexec/xen-cmdline --set-xen cpufreq=xen:ondemand

Verify the New Governor and Clock Speed

# xenpm get-cpufreq-para
cpu id              : 0
affected_cpus       : 0
cpuinfo frequency   : max [3401000] min [1600000] cur [1600000]
scaling_driver      : acpi-cpufreq
scaling_avail_gov   : userspace performance powersave ondemand
current_governor    : ondemand
scaling_avail_freq  : 3401000 3400000 3300000 3100000 3000000 2900000 2800000 2600000 2500000 2400000 2200000 2100000 2000000 1900000 1700000 *1600000
scaling frequency   : max [3401000] min [1600000] cur [1600000]
turbo mode          : enabled
...

And, to see how much time the processor is spending at each clock speed:

# xenpm get-cpufreq-states
cpu id            : 0
total P-states    : 16
usable P-states   : 16
current frequency : 1600 MHz
P0      [3401 MHz]: transition [      150]
                    residency  [     5136 ms]
P1      [3400 MHz]: transition [        4]
                    residency  [       56 ms]
P2      [3300 MHz]: transition [        6]
                    residency  [       53 ms]
P3      [3100 MHz]: transition [        4]
                    residency  [       35 ms]
P4      [3000 MHz]: transition [        4]
                    residency  [       41 ms]
P5      [2900 MHz]: transition [        9]
                    residency  [       65 ms]
P6      [2800 MHz]: transition [        8]
                    residency  [       55 ms]
P7      [2600 MHz]: transition [        1]
                    residency  [       25 ms]
P8      [2500 MHz]: transition [        5]
                    residency  [       34 ms]
P9      [2400 MHz]: transition [        9]
                    residency  [       27 ms]
P10     [2200 MHz]: transition [        5]
                    residency  [       21 ms]
P11     [2100 MHz]: transition [        6]
                    residency  [       41 ms]
P12     [2000 MHz]: transition [        3]
                    residency  [        2 ms]
P13     [1900 MHz]: transition [        9]
                    residency  [       69 ms]
P14     [1700 MHz]: transition [        1]
                    residency  [        0 ms]
*P15    [1600 MHz]: transition [      136]
                    residency  [ 31630237 ms]
...

Further reading:

Leave a Reply

Your email address will not be published. Required fields are marked *