diff --git a/ansible/environments/laptop/host_vars/odolinux b/ansible/environments/laptop/host_vars/odolinux index d4cb545..90062eb 100644 --- a/ansible/environments/laptop/host_vars/odolinux +++ b/ansible/environments/laptop/host_vars/odolinux @@ -26,3 +26,5 @@ build_user: wireguard_directory: odo enabled_wireguard: - wgh +hwpstate: true +cores: 8 diff --git a/ansible/roles/power/defaults/main.yaml b/ansible/roles/power/defaults/main.yaml deleted file mode 100644 index bdc48d1..0000000 --- a/ansible/roles/power/defaults/main.yaml +++ /dev/null @@ -1,15 +0,0 @@ -tlp_config: - PCIE_ASPM_ON_BAT: powersupersave - USB_ALLOWLIST: "1050:0406" - CPU_BOOST_ON_AC: "0" - CPU_BOOST_ON_BAT: "0" - CPU_ENERGY_PERF_POLICY_ON_BAT: "power" - DISK_IDLE_SECS_ON_BAT: "5" - CPU_MIN_PERF_ON_AC: "0" - CPU_MAX_PERF_ON_AC: "100" - CPU_MIN_PERF_ON_BAT: "0" - CPU_MAX_PERF_ON_BAT: "100" - # WIFI_PWR_ON_AC: "on" - # WIFI_PWR_ON_BAT: "on" - # CPU_HWP_DYN_BOOST_ON_AC: "0" - # CPU_HWP_DYN_BOOST_ON_BAT: "0" diff --git a/ansible/roles/power/files/disable_turboboost_tmpfiles.conf b/ansible/roles/power/files/disable_turboboost_tmpfiles.conf new file mode 100644 index 0000000..e70a469 --- /dev/null +++ b/ansible/roles/power/files/disable_turboboost_tmpfiles.conf @@ -0,0 +1,2 @@ +# Disable turboboost. This makes the laptop significantly quieter and probably helps battery life. +w- /sys/devices/system/cpu/intel_pstate/no_turbo - - - - 1 diff --git a/ansible/roles/power/tasks/linux.yaml b/ansible/roles/power/tasks/linux.yaml index bc15c06..41c49eb 100644 --- a/ansible/roles/power/tasks/linux.yaml +++ b/ansible/roles/power/tasks/linux.yaml @@ -2,47 +2,26 @@ package: name: - powertop - - tlp state: present -# - name: Configure TLP -# lineinfile: -# path: /etc/tlp.conf -# regexp: "^{{ item.key }}=" -# line: '{{ item.key }}="{{ item.value }}"' -# loop: "{{ tlp_config | dict2items }}" -# when: '" " in item.value' - -# - name: Configure TLP -# lineinfile: -# path: /etc/tlp.conf -# regexp: "^{{ item.key }}=" -# line: "{{ item.key }}={{ item.value }}" -# loop: "{{ tlp_config | dict2items }}" -# when: '" " not in item.value' - -- name: Configure sysctls - sysctl: - name: "{{ item.name }}" - value: "{{ item.value }}" - state: present - sysctl_file: /etc/sysctl.d/dirty.conf +- name: Install tmpfiles.d configuration + copy: + src: "files/{{ item }}_tmpfiles.conf" + dest: "/etc/tmpfiles.d/{{ item }}.conf" + mode: 0644 + owner: root + group: wheel loop: - - name: vm.dirty_writeback_centisecs - value: 2000 # Default is 500 (5 seconds) + - disable_turboboost -- name: Configure sysctls - sysctl: - name: "{{ item.name }}" - value: "{{ item.value }}" - state: present - sysctl_file: /etc/sysctl.d/laptop.conf +- name: Favor energy efficiency for Speed Shift + when: hwpstate is defined and hwpstate and cores is defined + template: + src: "templates/{{ item.src }}.j2" + dest: "{{ item.dest }}" + mode: 0755 + owner: root + group: wheel loop: - - name: vm.laptop_mode - value: 5 - -- name: Enable services - systemd: - name: tlp.service - daemon_reload: yes - enabled: true + - src: energy_performance_preference.conf + dest: /etc/tmpfiles.d/energy_performance_preference.conf diff --git a/ansible/roles/power/templates/energy_performance_preference.conf.j2 b/ansible/roles/power/templates/energy_performance_preference.conf.j2 new file mode 100644 index 0000000..b5a4239 --- /dev/null +++ b/ansible/roles/power/templates/energy_performance_preference.conf.j2 @@ -0,0 +1,4 @@ +# Favor energy efficiency for Speed Shift +{% for core in range(0, cores, 1) %} +w- /sys/devices/system/cpu/cpufreq/policy{{core}}/energy_performance_preference - - - - power +{% endfor %}