aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/cpupower-rt29
-rwxr-xr-xscripts/cpupower-rt32
-rw-r--r--system/cpupower-rt.service12
3 files changed, 73 insertions, 0 deletions
diff --git a/config/cpupower-rt b/config/cpupower-rt
new file mode 100644
index 0000000..336a338
--- /dev/null
+++ b/config/cpupower-rt
@@ -0,0 +1,29 @@
+# Define CPUs governor
+# valid governors: ondemand, performance, powersave, conservative, userspace.
+governor='performance'
+
+# Limit frequency range
+# Valid suffixes: Hz, kHz (default), MHz, GHz, THz
+#min_freq="2.25GHz"
+#max_freq="3.4GHz"
+
+# Specific frequency to be set.
+# Requires userspace governor to be available.
+# Do not set governor field if you use this one.
+#freq=
+
+# Utilizes cores in one processor package/socket first before processes are
+# scheduled to other processor packages/sockets.
+# See man (1) CPUPOWER-SET for additional details.
+#mc_scheduler=
+
+# Utilizes thread siblings of one processor core first before processes are
+# scheduled to other cores. See man (1) CPUPOWER-SET for additional details.
+#smp_scheduler=
+
+# Sets a register on supported Intel processore which allows software to convey
+# its policy for the relative importance of performance versus energy savings to
+# the processor. See man (1) CPUPOWER-SET for additional details.
+perf_bias=0
+
+# vim:set ts=2 sw=2 ft=sh et:
diff --git a/scripts/cpupower-rt b/scripts/cpupower-rt
new file mode 100755
index 0000000..d775d68
--- /dev/null
+++ b/scripts/cpupower-rt
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+. /etc/default/cpupower-rt
+
+declare -i fail=0
+
+# parse frequency options
+declare -a params=()
+params+=(${governor:+-g $governor})
+params+=(${min_freq:+-d $min_freq})
+params+=(${max_freq:+-u $max_freq})
+params+=(${freq:+-f $freq})
+
+# apply frequency options
+if ((${#params[@]} > 0)); then
+ cpupower frequency-set "${params[@]}" >/dev/null || fail=1
+fi
+
+# parse cpu options
+declare -a params=()
+params+=(${mc_scheduler:+-m $mc_scheduler})
+params+=(${smp_scheduler:+-s $smp_scheduler})
+params+=(${perf_bias:+-b $perf_bias})
+
+# apply cpu options
+if ((${#params[@]} > 0)); then
+ cpupower set "${params[@]}" >/dev/null || fail=1
+fi
+
+exit $fail
+
+# vim:set ts=2 sw=2 ft=sh et:
diff --git a/system/cpupower-rt.service b/system/cpupower-rt.service
new file mode 100644
index 0000000..aa7eda4
--- /dev/null
+++ b/system/cpupower-rt.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Apply cpupower configuration
+ConditionKernelCommandLine=systemd.setenv=REALTIME=true
+After=cpupower.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/lib/systemd/scripts/cpupower-rt
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target