I’ve noticed that the my Intel Xeon E3-1230 v2 CPU runs at the maximum frequency on my TrueNAS Core, even at negligible load. This post describes how to configure the powerd daemon to shave off a few watts of idle power by allowin the frequencies to scale.

Observation

You can monitor the CPU frequency by watching the dev.cpu.0.freq state:

cmdwatch -n 1 sysctl dev.cpu.0.freq

Alternatively, run powerd -v in the elevated shell. If you go this route – stop the monitoring before proceeding, otherwise the actual service won’t start – it will think powerd is already running, which is not wrong.

You may notice the frequency is pegged at max all the time; this is what we are going to fix today.

Intervention

All you really need is read man powerd and enable the RC Tunable in the TrueNAS UI to configure the power management policy and launch the service at startup by adding the following two lines to /etc/rc.conf:

powerd_enable="YES"
powerd_flags="-b min -a adaptive -n adaptive"

This tells powerd to set performance to minimum when battery is connected, and to adaptive mode when on AC power, or when the power status is unknown.

Don’t directly edit the file, as the changes will be lost on restart; instead add the configuration under Tunables in the TrueNAS UI.

To add each variable, under System, Tunables click Add, input the variable name, value (sans quotes) into the appropriate boxes, select type rc.conf from the pull down, write some meaninful description, and keep Enabled flag on.

powerd rc tunables

These changes will take effect upon reboot. To start the service in the current sesion and avoid rebooting, configure and start the service manually this one time:

sysrc powerd_flags="-b min -a adaptive -n adaptive"
service powerd onestart

Verification

Revisit Observation and confim that the clock is now being scaled properly.

Advanced configuration

Minimum and maximum frequencies

Read man powerd. Of interest are -m and -M flags that limit minimum and maximum frequencies to throttle to.

-M freq     Specifies the maximum frequency to throttle up to.
-m freq     Specifies the minimum frequency to throttle down to.

The supported frequency ranges of your CPU are reported in the dev.cpu.0.freq_levels state:

% sysctl dev.cpu.0.freq_levels | tr " " "\n"
dev.cpu.0.freq_levels:
3501/69000
3500/69000
3400/66169
3200/60660
3100/57982
3000/55354
2800/50893
2700/48405
2500/43573
2400/41238
2300/38941
2100/35071
2000/32906
1900/30787
1700/26690
1600/24705

Perhaps, adding -M 2400 to the powerd_flags would not be a bad idea?

Nice processes

Another useful flag worth considering is -N:

-N          Treat "nice" time as idle for the purpose of load
calculation; i.e., do not increase the CPU frequency if the
CPU is only busy with "nice" processes.