2021-10-13 02:02:22 +00:00
|
|
|
---
|
|
|
|
- hosts: localhost
|
|
|
|
become: yes
|
|
|
|
vars:
|
2022-05-06 02:48:35 +00:00
|
|
|
power_max_multi: 0.90 # should not exceed 1.0, must be a float. note: driver seems to do its own rounding
|
|
|
|
power_max: "{{ power_max_b64['content'] | b64decode }}"
|
|
|
|
power_cap_float: "{{ power_max |float * power_max_multi }}"
|
|
|
|
power_cap: "{{ power_cap_float |int }}"
|
2021-10-13 02:02:22 +00:00
|
|
|
card: card0 # default to card0
|
2022-01-30 05:02:26 +00:00
|
|
|
base_profiles: # standard tuned profiles available on Fedora, should dynamically discover?
|
|
|
|
- balanced
|
2021-10-13 02:02:22 +00:00
|
|
|
- desktop
|
2022-01-30 05:02:26 +00:00
|
|
|
- latency-performance
|
2021-10-13 02:02:22 +00:00
|
|
|
- network-latency
|
2022-01-30 05:02:26 +00:00
|
|
|
- network-throughput
|
2021-10-13 02:02:22 +00:00
|
|
|
- powersave
|
2022-01-30 05:02:26 +00:00
|
|
|
- virtual-host
|
2021-10-13 02:09:15 +00:00
|
|
|
amdgpu_profiles: # statically defined mapping of the contents in /sys/class/drm/{{ card }}/device/pp_power_profile_mode
|
2022-01-30 05:02:26 +00:00
|
|
|
# - { name: 'bootup_default', value: 0 }
|
|
|
|
# - { name: '3D_fullscreen', value: 1 }
|
2021-10-13 02:02:22 +00:00
|
|
|
- { name: 'powersaving', value: 2 }
|
|
|
|
- { name: 'video', value: 3 }
|
|
|
|
- { name: 'VR', value: 4 }
|
2022-01-30 05:02:26 +00:00
|
|
|
# - { name: 'compute', value: 5 }
|
|
|
|
# - { name: 'custom', value: 6 }
|
|
|
|
handlers:
|
|
|
|
- name: restart tuned
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: tuned
|
|
|
|
state: restarted
|
2021-10-13 02:02:22 +00:00
|
|
|
tasks:
|
2022-02-01 01:18:10 +00:00
|
|
|
- name: find hwmon/max power capability file for {{ card }}
|
|
|
|
find:
|
|
|
|
paths: /sys/class/drm/{{ card }}/device/hwmon
|
|
|
|
file_type: file
|
|
|
|
recurse: yes
|
|
|
|
use_regex: yes
|
|
|
|
patterns:
|
|
|
|
- '^power1_cap_max$'
|
|
|
|
register: hwmon
|
|
|
|
- name: get max power capability for {{ card }}
|
|
|
|
slurp:
|
|
|
|
src: "{{ hwmon.files.0.path }}"
|
2022-05-06 02:48:35 +00:00
|
|
|
register: power_max_b64
|
2021-10-13 02:02:22 +00:00
|
|
|
- name: ensure tuned is installed
|
|
|
|
package:
|
|
|
|
name: tuned
|
|
|
|
state: present
|
|
|
|
- name: create custom profile directories
|
|
|
|
file:
|
|
|
|
state: directory
|
2022-01-30 05:02:26 +00:00
|
|
|
path: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0.name }}
|
2021-10-13 02:02:22 +00:00
|
|
|
mode: "0755"
|
|
|
|
with_nested:
|
|
|
|
- "{{ amdgpu_profiles }}"
|
|
|
|
- "{{ base_profiles }}"
|
|
|
|
- name: template custom tuned profiles
|
|
|
|
template:
|
|
|
|
src: templates/tuned.conf.j2
|
2022-01-30 05:02:26 +00:00
|
|
|
dest: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0.name }}/tuned.conf
|
2021-10-13 02:02:22 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
|
|
|
with_nested:
|
|
|
|
- "{{ amdgpu_profiles }}"
|
2022-01-30 05:02:26 +00:00
|
|
|
- "{{ base_profiles }}"
|
|
|
|
notify: restart tuned
|