bump license date
make README more readable
automatic threshold was only working in battery mode
Userland CPU frequency scheduling for OpenBSD >= 7.1
pkg_add obsdfreqd
rcctl enable obsdfreqd
rcctl stop apmd ; rcctl disable apmd
rcctl start obsdfreqd
-A
-T
for temperature limitAs easy as make
Run obsdfreqd
as root, quit with Ctrl+C
.
make install
as root, enable the service using rcctl enable obsdfreqd
.
Create /etc/rc.d/obsdfreqd
with this content and make it executable:
#!/bin/ksh
daemon="/usr/local/sbin/obsdfreqd"
. /etc/rc.d/rc.subr
pexp="${daemon}.*"
rc_reload=NO
rc_bg=YES
rc_cmd $1
Start the service with rcctl start obsdfreqd
.
If you use apmd
service, you have to start it either with -H
or -L
flag, otherwise it will start after obsdfreqd and set the performance policy to automatic and obsdfreqd will crash.
Parameters are applied when both plugged on the wall or on battery, parameters can have two values comma separated to give different values when plugged on wall and for when on battery.
-h
show usage-v
verbose mode, CSV output if one wants to create diagrams-d downstepfrequency
sets the steps removed every cycle when decaying, default to 100-i inertia
sets the number of cycles after which the frequency will decay, 0 is the default-m maxfrequency
sets the maximum frequency the CPU can reach in percent, 100% is default-l minfrequency
sets the minimum frequency the CPU must be lowered to, 0% is default-r threshold
sets the CPU usage in % that will trigger the frequency increase, defaults to 80% of a single core.-s stepfrequency
sets the percent of frequency added every cycle when increasing, 10% is default-t timefreq
sets the milliseconds between each poll, 300 is the default-T maxtemperature
sets the temperature threshold under which the maximum frequency will be temporary lowered until the CPU cools down-S sensor
specify a sensor (using its sysctl path) to use with -T
Example:
obsdfreqd -T 90,65
will start the daemon, when power is plugged in, maximum temperature is set to 90°C and 65°C when on battery.
The current algorithm works this way:
If CPU usage > threshold
, increase frequency by stepfrequency
up to maxfrequency
every timefreq
milliseconds and keep this frequency at least inertia
cycles.
If CPU usage <= threshold
, reduce frequency by downstepfrequency
down to minfrequency
every timefreq
milliseconds when inertia
reached 0. inertia
lose one point every cycle the CPU usage is below threshold
.
When flag -T
is used, if the temperature exceeds the defined limit, the maxfrequency
is decremented every cycle. When the current temperature is below the limit, the frequency limit is incremented at every cycle.
When switching from/to battery, values switch to mode specific when user defined.
obsdfreqd will change the perfpolicy sysctl to manual and will change the CPU frequency by polling every often (like 100ms) the CPU load and change the frequency accordingly, the perfpolicy is set to auto upon exit.
The end goal is to provide a feature rich CPU frequency scheduler for the following use case:
obsdfreqd is available as a package in OpenBSD current. The point of this progrm is to allow OpenBSD users to have a quiet and cool system which is not possible with the current code due to this change in the kernel.