General System Tweaks
1. CPU mitigations
A public speculative execution attack exploiting return instructions (retbleed) was revealed in July 2022. This has been mitigated in the kernel, but it results in a significant performance regression (14-39%).
The following CPU’s are affected:
- AMD: Zen 1, Zen 1+, Zen 2
- Intel: 6th to 8th Generation, Skylake, Kaby Lake, Coffee Lake
Check which mitigation affects your CPU by running the following command:
Disabling mitigations
While disabling the CPU mitigation’s is going to increase performance, as a downside it introduces security risks.
Add the following to your kernel command-line: retbleed=off
or to disable all mitigation’s: mitigations=off
Edit the appropriate file to make the changes persistent:
- GRUB:
/etc/default/grub
- systemd boot:
/etc/sdboot-manage.conf
- rEFInd:
/boot/refind_linux.conf
For more information about the impact on performance:
- https://www.phoronix.com/review/retbleed-benchmark
- https://www.phoronix.com/review/xeon-skylake-retbleed
Downfall
Downfall is characterized as a vulnerability due to a memory optimization feature that unintentionally reveals internal hardware registers to software. With Downfall, untrusted software can access data stored by other programs that typically should be off-limits: the AVX GATHER instruction can leak the contents of the internal vector register file during speculative execution. Downfall was discovered by security researcher Daniel Moghimi of Google. Moghimi has written demo code for Downfall to show 128-bit and 256-bit AES keys being stolen from other users on the local system as well as the ability to steal arbitrary data from the Linux kernel.
This affects the following CPU generations:
- Ice Lake
- Skylake
- Kaby Lake
- Coffee Lake
- Comet Lake
- Rocket Lake
- Tiger Lake
Disabling Downfall
Add gather_data_sampling=off
to your kernel cmdline parameters list.
mitigations=off
will also disable downfall.
2. AMD P-State Driver
amd-pstate
is the AMD CPU performance scaling driver that introduces a new CPU frequency control mechanism on modern AMD APU and CPU series in the Linux kernel. The new mechanism is based on Collaborative Processor Performance Control (CPPC) which provides finer grain frequency management than legacy ACPI hardware P-States. Current AMD CPU/APU platforms are using the ACPI P-states driver to manage CPU frequency and clocks with switching only in 3 P-states. CPPC replaces the ACPI P-states controls and allows a flexible, low-latency interface for the Linux kernel to directly communicate the performance hints to hardware.
Below are 3 operation modes of the amd-pstate
driver and kernel cmdline entries to use them on boot:
- AMD P-State (Non-Autonomous Mode):
amd-pstate=passive
- AMD P-State Guided (Guided Autonomous Mode):
amd-pstate=guided
- AMD P-State EPP (Autonomous Mode):
amd-pstate=active
You can also switch between operation modes at runtime to test the options:
-
Autonomous mode: platform considers only the values set for Minimum performance, Maximum performance, and Energy Performance Preference.
-
Guided-autonomous mode: platform sets operating performance level according to the current workload and within limits set by the OS through minimum and maximum performance registers.
-
Non-autonomous mode: platform gets desired performance level from OS directly through Desired Performance Register.
For more information:
- https://www.kernel.org/doc/html/v6.9/admin-guide/pm/amd-pstate.html
- https://lore.kernel.org/lkml/20221110175847.3098728-1-Perry.Yuan@amd.com/
- https://lore.kernel.org/lkml/20230119115017.10188-1-wyes.karny@amd.com/
3. Using AMD P-State EPP
To use the P-State EPP, there are two CPU frequency scaling governors available: powersave and performance. It is recommended to use the powersave governor and set a preference.
- Set powersave governor:
sudo cpupower frequency-set -g powersave
- Set performance governor:
sudo cpupower frequency-set -g performance
To set a preference, run the following command with the desired preference:
Available preferences: performance
, power
, balance_power
, balance_performance
Benchmarks for each preference can be found here: https://lore.kernel.org/lkml/20221219064042.661122-1-perry.yuan@amd.com/
5. AMD 3D V Cache Optimizer
AMD posted a patch to optimize the Cache Scheduling on Dual CCD 3D CPUs, like 7950X3D and 7900X3D. You need to set in the BIOS under the CPPC Option to the “Driver” Option. This will allow to override with the sysfs the used mode.
There are two modes:
- Frequency
- Cache
If cache
is set, the driver will try to put the tasks first on the CCD with the higher Cache, this is mainly profitable on games.
The frequency
option will try to put the tasks on the second CCD, which has a higher frequency then the 3D Cache CCD.
Frequency (Default):
Cache:
After you changed the modes, the amd preffered core stats should provide a different ranking. You can read it out with:
5. AMD P-State Core Performance Boost
AMD Core Performance Boost aka AMD Turbo Core is a dynamic frequency scaling technology by AMD that allows the processor to dynamically adjust and control the processor operating frequency in certain version of its processors which allows for increased performance when needed while maintaining lower power and thermal parameters during normal operation.
Since linux-cachyos
6.9.6, the kernel is patched with CPB support for AMD’s p-state drivers (includes passive
, active
and guided
).
Users can change each CPU’s boost state via the sysfs boost file /sys/devices/system/cpu/cpuX/cpufreq/boost
(X refers to the core number e.g. cpu0 is the first core, cpu1 second, etc).
CachyOS also provides a version of power-profiles-daemon
that backports a commit which enables
support for AMD CPB. AMD CPB will be disabled if the powersave
profile is being used, and will be enabled on balanced
or performance
.
For more information see:
- https://lore.kernel.org/linux-pm/1a78eeaa-fadd-4734-aaeb-2fe11e96e198@amd.com/T/#m4a0c8917ea8fb033504055bd61512c80c85410c8
- https://lore.kernel.org/linux-pm/20240624213400.67773-1-mario.limonciello@amd.com/
6. Disabling Split Lock Mitigate
In some cases, split lock mitigate can slow down performance in some applications and games. A patch is available to disable it via sysctl.
- Disable split lock mitigate:
sudo sysctl kernel.split_lock_mitigate=0
- Enable split lock mitigate:
sudo sysctl kernel.split_lock_mitigate=1
To make the change persistent, add the following line to /etc/sysctl.d/99-splitlock.conf
:
For more information on split lock, see:
- https://www.phoronix.com/news/Linux-Splitlock-Hurts-Gaming
- https://github.com/doitsujin/dxvk/issues/2938
7. Enable RCU Lazy
RCU Lazy helps reducing the power usage at idle or lightly loaded systems. This can be useful for laptops and handheld devices. The improvement is between 5-10% in terms of power savings. However it’s important to note that this power saving feature may come at the cost of slightly reduced performance depending on the scenario. The linux-cachyos-deckify kernel will have this option enabled by default, since power saving is key and necessary for these devices.
To enable RCU Lazy, add the following parameter to your kernel cmdline parameters list:
8. NVIDIA GSP Firmware
The NVIDIA GSP Firmware can “in some cases” lead to decreased performance. While the 555.58.02 NVIDIA Driver has largely addressed this issue, it may persist on certain systems.
If you are facing hiccups in KDE or bad performance in some cases, you can disable the GSP Firmware with the following config file:
/etc/modprobe.d/nvidia-gsp.conf
After creating the file, execute the following command:
It’s generally recommended to test the GSP firmware after each new NVIDIA driver installation, as it often introduces beneficial features. Moreover, NVIDIA primarily started conducting QA testing using the GSP firmware.
9. Disabling SDDM Wayland Backend
While this a nice step forward, it might introduce some annoyances such as breaking support for overclocking using nvidia-settings or cause incompatibility with older GPUs which struggle under Wayland.
In order to revert this change. Remove cachyos-kde-settings: