From f9ac22c285ee42586375cd46b1072734856c6a0b Mon Sep 17 00:00:00 2001 From: David Runge Date: Fri, 20 Mar 2015 02:50:44 +0100 Subject: cpupower-rt: Adding cpupower-rt script, configuration and service file. Meant to be used with linux-rt and setting the special boot parameter: systemd.setenv=REALTIME=true. --- config/cpupower-rt | 29 +++++++++++++++++++++++++++++ scripts/cpupower-rt | 32 ++++++++++++++++++++++++++++++++ system/cpupower-rt.service | 12 ++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 config/cpupower-rt create mode 100755 scripts/cpupower-rt create mode 100644 system/cpupower-rt.service 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 -- cgit v1.2.3-70-g09d2