tuned: discover base profiles dynamically

This commit is contained in:
Josh Lay 2024-08-09 08:25:54 -05:00
parent 983d2339f2
commit 2d314fd691
No known key found for this signature in database
GPG key ID: 47AA304B2243B579
3 changed files with 22 additions and 21 deletions

View file

@ -3,15 +3,8 @@
Hacky solution to integrate AMDGPU power/clock control into `tuned` profiles
with Ansible.
Extends existing profiles, such as:
- `balanced`
- `desktop`
- `latency-performance`
- `network-latency`
- `powersave`, and so on
Creating three variations of each, using the [AMDGPU hwmon interfaces](https://docs.kernel.org/gpu/amdgpu/thermal.html):
Provides three variations of the `tuned` profiles found in `/usr/lib/tuned`
using the [AMDGPU hwmon interfaces](https://docs.kernel.org/gpu/amdgpu/thermal.html):
- `default`: the out-of-the-box configuration
- `overclock`: the optimized card configuration. Includes all of the clock/voltage/power settings
@ -71,6 +64,5 @@ These are the variables you'll want to change/consider.
| gpu_clock_max | Sets the max (dynamic) GPU clock (in `MHz`) for the non-default `amdgpu` profiles |
| gpumem_clock_static | Sets the _static_ memory clock for the GPU (in `MHz`). This is *not* the _effective_ data rate. _That_ would be a multiple of _this_ depending on the type of VRAM.<br/><br/>To avoid flickering this is *not* allowed to change with load, only between `default` and `overclock`/`peak` profiles. |
| gpu_mv_offset | GPU core voltage offset. Takes +/- some integer in millivolts. Can be used to both over _and_ under volt. eg: `-50` _(undervolt `50mV` or `0.05V`)_ |
| base_profiles | List of base tuned profiles to clone in the new AMDGPU profiles. Defaults based on `Fedora` |
| gpu_power_multi_def | Float between `0.0` and `1.0`; controls power limit relative to the board _capability_. For _'default'_-named power profiles. |
| gpu_power_multi_oc | Similar to `gpu_power_multi_def`, for _'overclock'_-named power profiles. |

View file

@ -1,16 +1,7 @@
---
- hosts: localhost
name: "Configure 'tuned' with AMD GPU control"
- name: "Configure 'tuned' with AMD GPU control"
hosts: localhost
roles:
# role prepares/modifies 'tuned' with AMD GPU power/clock parameters
# creates a new tuned profile made for each permutation of (base) 'tuned' profile + AMD powerplay profile
- role: tuned_amdgpu
# list of source tuned profiles available on Fedora (TODO: should dynamically discover)
base_profiles:
- balanced
- desktop
- latency-performance
- network-latency
- network-throughput
- powersave
- virtual-host

View file

@ -27,6 +27,24 @@
state: present
become: true
- name: Find bundled 'tuned' profiles
ansible.builtin.find:
paths:
- /usr/lib/tuned/ # this may change/benefit from var/defaults; packaging should generally prefer this path
patterns:
- 'tuned.conf'
recurse: true
register: tuned_bundled_configs
- name: Set fact with included profile names
ansible.builtin.set_fact:
base_profiles: "{{ base_profiles | default([]) + profile_name }}"
loop: "{{ tuned_bundled_configs.files }}"
loop_control:
label: "{{ profile_name }}"
vars:
profile_name: "{{ [item.path | dirname | basename] }}"
- name: Ensure dynamic tuning is disabled
ansible.builtin.lineinfile:
path: /etc/tuned/tuned-main.conf