re-nice is not very effective with autogrouping/cgroup_sched enabled
gamemode makes use of setpriority to renice game processes when possible, but when autogrouping or cgroups are used it does not have the intended effect, and both are commonly enabled in distro kernels.
sched(7) has some details, but basically CFS divides cpu resources by task groups, which means the cgroup cpu controller if enabled and otherwise by autogrouping, and only finally by process priority. Renicing it only changes its priority relative to other tasks in the group.
I think when systemd/cgroups are used, gamemode should probably change the cpu controller weight by moving the game process to a unique cgroup and writing to the cpu.weight property.
The cpu weight is accessible to an unprivileged user, which makes it much more desirable for gamemode's use-case. We can use existing user configs by leveraging the cpu.weight.nice property as well, which gives an equivalent "nice" like interface to the cpu controller.
[1] https://docs.kernel.org/scheduler/sched-bwc.html [2] https://docs.kernel.org/admin-guide/cgroup-v2.html#cpu-interface-files [3] https://man.archlinux.org/man/sched.7#The_autogroup_feature
EDIT: clarity
This is spot on! re-nice is only a placebo, at least on Ubuntu-derived systems and also apparently on Arch and Fedora. See this excellent thread: https://www.reddit.com/r/linux/comments/d7hx2c/why_nice_levels_are_a_placebo_and_have_been_for_a/
If the cpu controller is enabled, autogroups are not used for processes outside of the root cgroup, even if enabled. So autogrouping is only possibly relevant for non-systemd systems (not sure what they do with cgroups), since systemd will put everything into the system or user slice.
What actually matters is the process niceness, the cpu.weight property of the local cgroup, and the cpu.weight of all the cgroups above it in the hierarchy.