-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
re-nice is not very effective with autogrouping/cgroup_sched enabled #437
Comments
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: |
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. |
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
The text was updated successfully, but these errors were encountered: