diff --git a/ansible/roles/cpu/files/cpu_set_perf_perc b/ansible/roles/cpu/files/cpu_set_perf_perc_freebsd similarity index 100% rename from ansible/roles/cpu/files/cpu_set_perf_perc rename to ansible/roles/cpu/files/cpu_set_perf_perc_freebsd diff --git a/ansible/roles/cpu/files/cpu_set_perf_perc_linux b/ansible/roles/cpu/files/cpu_set_perf_perc_linux new file mode 100644 index 0000000..7d86627 --- /dev/null +++ b/ansible/roles/cpu/files/cpu_set_perf_perc_linux @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# Tell speedshift whether to maximize CPU performance (100) or energy +# efficiency (0). +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +perc=$1 + +if [ $perc -lt 50 ]; then + echo "power" | tee /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference +else + echo "performance" | tee /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference +fi diff --git a/ansible/roles/cpu/tasks/freebsd_intel.yaml b/ansible/roles/cpu/tasks/freebsd_intel.yaml index c818671..6f88399 100644 --- a/ansible/roles/cpu/tasks/freebsd_intel.yaml +++ b/ansible/roles/cpu/tasks/freebsd_intel.yaml @@ -65,7 +65,7 @@ owner: root group: wheel loop: - - src: cpu_set_perf_perc + - src: cpu_set_perf_perc_freebsd dest: /usr/local/bin/cpu_set_perf_perc - name: Install loader.conf diff --git a/ansible/roles/cpu/tasks/linux_intel.yaml b/ansible/roles/cpu/tasks/linux_intel.yaml index 41c49eb..f49196c 100644 --- a/ansible/roles/cpu/tasks/linux_intel.yaml +++ b/ansible/roles/cpu/tasks/linux_intel.yaml @@ -25,3 +25,15 @@ loop: - src: energy_performance_preference.conf dest: /etc/tmpfiles.d/energy_performance_preference.conf + +- name: Install scripts + when: hwpstate is defined and hwpstate + copy: + src: "files/{{ item.src }}" + dest: "{{ item.dest }}" + mode: 0755 + owner: root + group: wheel + loop: + - src: cpu_set_perf_perc_linux + dest: /usr/local/bin/cpu_set_perf_perc