Linux

Updated 9th of November 2024.

Note: This page is not complete yet, so expect some stuff to be missing and/or not included. If you need to ask me questions, please check the bottom of the page.

When applying something, please don't just copypasta it. Please read and check the docs.

Always read the Arch Linux Wiki

The Arch Linux Wiki provides updated and useful information on how to maintain your Arch Linux installation and how to optimize the installation.

https://wiki.archlinux.org/

Game starts lagging after 25 to 40+ minutes of gameplay when providing mouse and keyboard inputs

Use LD_PRELOAD="" environment variable when launching the game. Alternatively, only add your own libraries there. You may have to add your Vulkan layers using the VK_LOADER_LAYERS_ENABLE environment variable as well. I don't know why this happens (yet).

https://github.com/doitsujin/dxvk/issues/4436

Why is Steam showing a black screen despite trying all the available solutions?

Disable Hardware Acceleration in Steam or use Wayland.

Why does Arch Linux randomly freeze on full load?

Set split_lock_detect=off kernel parameter. Make sure you're NOT using intel_cpufreq driver on a processor with e-cores, use intel_pstate instead.

Why is Steam randomly erasing my games (or saying "Installing") on Arch Linux?

Disable Steam Cloud on Linux before installing the game, then enable it again once the game is fully installed. This is a new Steam problem that happens when Linux tries to parse your Windows's cloud data. No idea what happens exactly, but doing this seems to solve it forever.

Which kernel do I use?

I personally use the xanmod kernel (provided by the linux-xanmod-bin AUR package) for gaming.

I switched to the main Arch Linux kernel which seems to run better for me right now.

Best DXVK settings for performance and latency

Tested with RTX 2070 (dxvk.conf)

# no fake device

# sudo lspci -nn | grep VGA


dxgi.customVendorId = 10de

dxgi.customDeviceId = 1f02

d3d9.customVendorId = 10de

d3d9.customDeviceId = 1f02

dxgi.customDeviceDesc = "NVIDIA GeForce RTX 2070"

d3d9.customDeviceDesc = "NVIDIA GeForce RTX 2070"


dxvk.deviceFilter = "NVIDIA"


dxgi.nvapiHack = false

dxgi.hideNvidiaGpu = False


# latency stuff

dxgi.syncInterval = 0

d3d9.presentInterval = 0

Comments are preceeded by a # character and are either unused settings or simply comments

vendor and device IDs should be set to your graphics card's

use sudo lspci -nn | grep VGA to find your vendor and ID; NVIDIA has always 10de as a vendor; this step prevents DXVK from hiding your NVIDIA GPU (used together with dxgi.nvapiHack and dxgi.hideNvidiaGpu

when setting syncinterval and presentinterval at 0, it will prevent vsync from being used at all

Do not enforce Anisotropic filtering through dxvk.conf. It can cause glitches and artifacts, especially in Unity Engine games.

dxvk.conf reference

My environment variables for best performance on NVIDIA and Arch Linux

EDITOR=nano


NVD_BACKEND=direct

MOZ_DISABLE_RDD_SANDBOX=1

MOZ_X11_EGL=1

LIBVA_DRIVER_NAME=nvidia


__EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/10_nvidia.json


VK_LOADER_DRIVERS_SELECT=nvidia*

VK_LOADER_DEVICE_SELECT=0x10de:0x2783

VK_DRIVER_FILES=/usr/share/vulkan/icd.d/nvidia_icd.json

VK_LOADER_LAYERS_DISABLE=*MESA*


PROTON_HIDE_NVIDIA_GPU=0

PROTON_DISABLE_NVAPI=0


DXVK_CONFIG_FILE=/home/melody/dxvk.conf


MANGOHUD_CONFIGFILE=/home/melody/mangohud.conf


STEAM_COMPAT_CLIENT_INSTALL_PATH=/home/melody/.local/share/Steam

DXVK_STATE_CACHE_PATH=/home/melody/.cache/dxvk-cache-pool

PROTON_BATTLEYE_RUNTIME=/home/melody/battleye/

PROTON_EAC_RUNTIME=/home/melody/easyanticheat/


__GL_SYNC_TO_VBLANK=0

__GL_ALLOW_UNOFFICIAL_PROTOCOL=1

# __GL_MaxFramesAllowed=16

__GL_SHADER_DISK_CACHE=1


LFX2=0

WINEHAGS=1


WINEDLLOVERRIDES="winmm=n,b"


VKD3D_CONFIG=force_static_cbv


PROTON_FORCE_NVAPI=1

# PROTON_HEAP_DELAY_FREE=1

# PROTON_FORCE_LARGE_ADDRESS_AWARE=1


DXVK_NVAPI_DRIVER_VERSION=56603

DXVK_NVAPI_GPU_ARCH=AD100


# VKD3D_SWAPCHAIN_LATENCY_FRAMES=16


DXVK_ENABLE_NVAPI=1

DXVK_FORCE_WINDOWED=1

DXVK_FILTER_DEVICE_NAME=NVIDIA


GBM_BACKEND=nvidia-drm

__GLX_VENDOR_LIBRARY_NAME=nvidia


SteamDeck=0


WINEFSYNC=1

WINEESYNC=1

Each environment variable can be looked up on Google

Commented environment variables can cause instability and issues, these can also be changed per-game via launch options.

Some environment variables need to be changed accordingly! Please do not just copy-paste all of this! -> Please read <-

Keep in mind that this is on a NVIDIA configuration, not on an AMD/Intel GPU configuration! If you want to contribute with your own AMD/Intel GPU variables, scroll to the bottom of this page.

default environment variables go in /etc/environment

Simplest way to install AUR packages on Arch Linux

sudo pacman -S base-devel

sudo pacman -S git

git clone https://aur.archlinux.org/yay.git

cd yay

makepkg -si

See: https://github.com/Jguer/yay

You may also want to try chaotic-aur.

Some useful Arch Linux Wiki links

https://wiki.archlinux.org/title/NVIDIA

https://wiki.archlinux.org/title/steam

https://wiki.archlinux.org/title/gaming

Power plans and power management

Install power-profiles-daemon.

Run:

sudo systemctl unmask power-profiles-daemon.service

sudo systemctl enable power-profiles-daemon.service

Restart your system. The powerprofilesctl CLI utility provides power plans functionality. KDE Plasma and GNOME support managing these through the system UI.

See: https://wiki.archlinux.org/title/CPU_frequency_scaling#power-profiles-daemon, https://gitlab.freedesktop.org/upower/power-profiles-daemon#how-to-use

More on power management: https://wiki.archlinux.org/title/Power_management, https://wiki.archlinux.org/title/CPU_frequency_scaling

Disabling a PCI device in Arch Linux

Create a new rule in /etc/udev/rules.d/, for example: /etc/udev/rules.d/00-disable-unused.rules

Important note: udev rules MUST have a ".rules" extension, ".conf" is not acceptable anymore and will be ignored!


ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="vendor_id", ATTR{device}=="device_id", ATTR{power/control}="auto", ATTR{remove}="1"


replace vendor_id and device_id with the respective values. sudo lspci -nn is an useful command to get these values.


The following udev rules disable NVIDIA USB policy controller and USB controller:

ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{device}=="0x1ada", ATTR{power/control}="auto", ATTR{remove}="1"

ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{device}=="0x1adb", ATTR{power/control}="auto", ATTR{remove}="1"

Useful obs plugin to efficiently capture OpenGL and Vulkan games

https://aur.archlinux.org/packages/obs-vkcapture

Run your game with obs-gamecapture <name>

Example (for Steam): obs-gamecapture %COMMAND%

Then use "Game Capture" in OBS to capture your game

Dangerous: If a game cannot be captured, you may need to manually LD_PRELOAD obs-gamecapture's GL library for OpenGL games, or the Vulkan layer for Vulkan games.

My kernel parameters

loglevel=4 mitigations=off split_lock_detect=off kernel.split_lock_mitigate=0 intel_pstate=support_acpi_ppc vm.vfs_cache_pressure = 1

These give me the best performance

Also add nvidia_drm.modeset=1 to enable modesetting (required for Wayland). I have it in a modprobe.d rule instead of a kernel parameter. The nvidia-tweaks AUR package does that automatically. nvidia-tweaks is no longer maintained and the latest NVIDIA drivers from the Arch repos already provide modesetting and a fbdev for NVIDIA devices. You can add the following to a modprobe rule to further improve performance on a NVIDIA device:

options nvidia NVreg_UsePageAttributeTable=1 NVreg_InitializeSystemMemoryAllocations=0 NVreg_EnableStreamMemOPs=1 NVreg_DynamicPowerManagement=0x02

options nvidia_modeset opportunistic_display_sync=0 vblank_sem_control=0

You can have kernel.split_lock_mitigate=0 and vm.vfs_cache_pressure=1 in a sysctl rule as well.

Bad memory overclocks / faulty processors and vm.vfs_cache_pressure: Beware when setting this value too low on unstable hardware as this may cause massive data loss. If your system tends to crash a lot, set this to 100, which will severely reduce the risk of data loss at cost of severely less disk performance.

Disabling dumb motherboard's power management proved to reduce stutters. This does not affect the way your components idle. Generally fixed in the new kernel/s.

What's split locking? Split locking spawns multiple smaller locks that each protect different parts of the data structure, which means multiple threads can access different parts of the structure simultaneously without contention. This is considered bad practice in Linux and is disabled and mitigated by default. Allowing split locking will provide MASSIVE performance improvements in a lot of games.

Old parameters for obsolete kernels:

hpet=force forces usage of HPET for devices as the main timer which can improve device events accuracy and has reduced microstuttering in my tests. Some devices use PIT by default, this parameter makes them use HPET instead. Keep in mind that this does NOT use HPET as system clocksource, it's not the same concept. Needs to be tested on more systems.

iomem=relaxed - In some contexts, disabling strict checking of access to MMIO memory strict regions from userspace WILL lead to marginal performance improvements, as the overhead of validation is removed. Reduces microstuttering and slightly improves framerate.

pcie_aspm=off pcie_port_pm=off apm=off clk_ignore_unused - Some motherboards, notably some MSI, Gigabyte and ASRock boards, seem to have issues with their dumb power management + Linux and they cause microstuttering.

How to create modprobe rules to specify module parameters in Arch Linux

Modprobe rules are stored in /etc/modprobe.d/ for user rules and /usr/lib/modprobe.d/ for rules that are added by packages or other sources. You should always put your own rules in /etc/modprobe.d/.


Create a new file (for example: custom-rules.conf) in /etc/modprobe.d/ and use the following syntax:

options module parameter=value


For example, I want to enable modesetting on nvidia_drm, so I use the following syntax:

options nvidia_drm modeset=1


You can add as many rules as you want in a single file on new lines.

You may have to run mkinitcpio -P afterwards, as the Arch Linux wiki suggests.

How to get possible module parameters in Arch Linux

To get the parameters you can use on a module, we can use the modinfo command. Parameters are preceeded by parm:. Let's see which parameters we can use for the drm module after running sudo modinfo drm:

parm:           edid_firmware:Do not probe monitor, use specified EDID blob from built-in data or /lib/firmware instead.  (string)

parm:           vblankoffdelay:Delay until vblank irq auto-disable [msecs] (0: never disable, <0: disable immediately) (int)

parm:           timestamp_precision_usec:Max. error on timestamps [usecs] (int)

parm:           debug:Enable debug output, where each bit enables a debug category.


Now we want to set vlankoffdelay to -1, we can now set this parameter by using the drm.vblankoffdelay=-1 kernel parameter or by specifying options drm vblankoffdelay=-1 in a modprobe rule.

Module parameters list for all your running modules

We can use the following bash command to output a list of modules and their parameters to a file named modules_parameters.txt under the current directory:

for i in $(sudo lsmod | cut -d " " -f 1 | tail -n +2); do echo $i && sudo modinfo $i | grep "parm:"; done > modules_parameters.txt

Force flat mouse acceleration everywhere on X11

In /etc/X11/xorg.conf.d/, create a new conf file (example: 00-mouse.conf) with the following content:

Section "InputClass"

        Identifier "libinput pointer catchall"

        MatchIsPointer "on"

        MatchDevicePath "/dev/input/event*"

        Driver "libinput"

        Option "AccelProfile" "flat"

EndSection

https://wiki.archlinux.org/title/Mouse_acceleration

Some settings I suggest using

BIOS:

Additional settings for Ryzen:

Additional settings for Intel:

Disable mitigations

Simply use the mitigations=off kernel parameters and all mitigations will be disabled. This can lead to up to 30-40% CPU performance increase DEPENDING on scenario. This won't disable split lock detection/mitigations. Use split_lock_detect=off kernel.split_lock_mitigate=0 to disable those.

Microstuttering

On obsolete kernels, stuttering is mainly caused by your motherboard's dumb power management that doesn't get along with Linux. Use pcie_aspm=off pcie_port_pm=off apm=off clk_ignore_unused to disable all of that, and make sure that ASPM, clock gating and native power management are also disabled in your BIOS (if possible).

FPS drops at high polling rates

It is known that some games don't like high polling rates and this is mainly an issue with Windows games rather than Linux native ports. To prevent this, you may want to reduce your mouse's polling rate down to 1000 or 500 for such dumb games. Keyboards running at more than 125 Hz polling can also cause problems with such games when sending keystrokes, you can use options usbhid kbpoll 8 to force your keyboard to poll at 125 Hz.

Enable Hardware Video Decoding for Firefox on NVIDIA GPUs

It is highly recommended that you use this method with X11 and not with Wayland.

This is extremely useful for 8K videos in AV1 and 4K in VP9 as they're extremely demanding for the CPU.

Install the libva-nvidia-driver package from the AUR.

Edit your environment variables (/etc/environment) and add the following:

NVD_BACKEND=direct

MOZ_DISABLE_RDD_SANDBOX=1

LIBVA_DRIVER_NAME=nvidia

Set the following in about:config on Firefox:

widget.dmabuf.force-enabled true

gfx.x11-egl.force-enabled true

media.av1.enabled - DEPENDS on whether your GPU supports AV1 or not, set to false if it doesn't. GeForce RTX 2000 and below DON'T support AV1! 

media.mediasource.vp9.enabled - DEPENDS on whether your GPU supports VP9 or not. GTX 800 / 700 and below DON'T support VP9!

media.rdd-ffmpeg.enabled true

media.ffmpeg.vaapi.enabled true

This section is mostly a TL;DR. For more info, please check https://github.com/elFarto/nvidia-vaapi-driver

Error: wine: setpriority (some number) for pid -1 failed: 3

It seems like setpriority returns 3 (operation not permitted) albeit the user is in the games group / gamemode group, or the user is under a group that allows setting niceness to the shown value (/etc/security/limits.d/...), or caps are set properly. Other software (such as Gamemode) may also fail setting the niceness. Most likely a regression, you don't have to worry about it until somebody cares about it. This problem has been fixed.

Questions / want to contribute to this info?

If you have question or wish to contribute to this page, such as correcting something or providing better information, feel free to join our Discord server by using the link below:

http://discord.gg/6TMHU63