Merge pull request 'Control CPU frequency and idle settings' (#4) from performance_cpupower-settings into main

Reviewed-on: #4
This commit is contained in:
Thomas Gebert 2024-09-19 12:41:23 +00:00
commit 6ac79fb7d0
4 changed files with 74 additions and 0 deletions

2
cpupower/cpupower Normal file
View File

@ -0,0 +1,2 @@
CPU_GOVERNOR="performance"
CPU_CSTATES_DISABLE_BY_LATENCY="3"

View File

@ -0,0 +1,25 @@
ansible -b all -m copy -a "src=cpupower.sh dest=/usr/local/sbin/cpupower.sh"
ansible -b all -m copy -a "src=cpupower.service dest=/etc/systemd/system/cpupower.service"
ansible -b all -m copy -a "src=cpupower.sh dest=/usr/local/sbin/cpupower.sh mode=0755"
ansible -b all -m shell -a "systemctl enable --now cpupower.service"
ansible -b all -m shell -a "cpupower frequency-info | grep governor; cpupower idle-info | grep ^C"
l3support@uxicasfs01:~/cpupower> ansible -b all -m shell -a "cpupower frequency-info | grep governor; cpupower idle-info | grep ^C"
uxicasfs02 | CHANGED | rc=0 >>
available cpufreq governors: performance powersave
The governor "performance" may decide which speed to use
CPUidle driver: intel_idle
CPUidle governor: menu
C1:
C1E (DISABLED) :
C6 (DISABLED) :
uxicasfs01 | CHANGED | rc=0 >>
available cpufreq governors: performance powersave
The governor "performance" may decide which speed to use
CPUidle driver: intel_idle
CPUidle governor: menu
C1:
C1E (DISABLED) :
C6 (DISABLED) :

11
cpupower/cpupower.service Normal file
View File

@ -0,0 +1,11 @@
[Unit]
Description=Configure cpupower related settings
[Service]
EnvironmentFile=-/etc/default/cpupower
Type=oneshot
ExecStart=/usr/local/sbin/cpupower.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

36
cpupower/cpupower.sh Normal file
View File

@ -0,0 +1,36 @@
#!/bin/bash
CPUPOWER_CONFIG="/etc/default/cpupower"
if [ -f "${CPUPOWER_CONFIG}" ]; then
source "${CPUPOWER_CONFIG}"
else
exit 0
fi
print_header() {
cat << HEADER
###############################################################################
# ${@}
###############################################################################
HEADER
}
# Set the CPU governor
if [ ! "${CPU_GOVERNOR}" == "" ]; then
print_header "Setting CPU governor to ${CPU_GOVERNOR}"
cpupower frequency-set --governor "${CPU_GOVERNOR}" &> /dev/null
cpupower frequency-info
else
echo "CPU governor is not set."
fi
# Set the Cstate by latency
if [ ! "${CPU_CSTATES_DISABLE_BY_LATENCY}" == "" ]; then
print_header "Setting CPU CStates by latency to ${CPU_CSTATES_DISABLE_BY_LATENCY}"
cpupower idle-set --disable-by-latency "${CPU_CSTATES_DISABLE_BY_LATENCY}" &> /dev/null
cpupower idle-info
else
echo "No CPU Cstates by latency configured."
fi