FeralInteractive / gamemode

Optimise Linux system performance on demand
BSD 3-Clause "New" or "Revised" License
4.67k stars 184 forks source link

Gamemode 1.8.1 can't set CPU governor and GPU Optimisation #452

Open bg2908 opened 8 months ago

bg2908 commented 8 months ago

Describe the bug Update gamemode to 1.8.1 and get this when install

warning: directory permissions differ on /usr/share/polkit-1/rules.d/
filesystem: 750  package: 755

Run gamemoded -t and it would fail with this message

:: Feature tests
::: Verifying CPU governor setting
ERROR: Governor was not set to performance (was actually schedutil)!
::: Failed!
::: Verifying Scripts
::: Passed (no scripts configured to run)
::: Verifying GPU Optimisations
ERROR: Current AMD GPU performance level during gamemode does not match requested value!
    expected:high was:auto
::: Failed!

To Reproduce Steps used to reproduce the behavior:

  1. Update gamemod to 1.8.1
  2. Run gamemoded -t
  3. Tests Failed!

Expected behavior : All Tests Passed! after running gamemoded -t

System Info (please complete the following information):

Additional context Downgrade to GameMode version 1.7 and it work again.

dtheil commented 8 months ago

Same issue as above: updated to 1.8.1 and got the message:

warning: directory permissions differ on /usr/share/polkit-1/rules.d/
filesystem: 750  package: 755

ran the command gamemoded -t and it returns the following message:

: Loading config
: Running tests

:: Basic client tests
:: Passed

:: Dual client tests
gamemode request succeeded and is active
Quitting by request...
:: Passed

:: Gamemoderun and reaper thread tests
...Waiting for child to quit...
...Waiting for reaper thread (reaper_frequency set to 5 seconds)...
:: Passed

:: Supervisor tests
:: Passed

:: Feature tests
::: Verifying CPU governor setting
ERROR: Governor was not set to performance (was actually powersave)!
::: Failed!
::: Verifying Scripts
::: Passed (no scripts configured to run)
::: Verifying GPU Optimisations
::: Passed (gpu optimisations not configured to run)
::: Verifying renice
::: Passed (no renice configured)
::: Verifying ioprio
::: Passed
ERROR: :: Failed!
: Tests Failed!

System info

Additional context Downgrading back to 1.7 fixed GameMode for me as well

Saroumane commented 8 months ago

I reproduce the problem, also using Archlinux - 6-6-7-arch1-1 and gamemode 1.8.1 In case someone is interested, it is possible to downgrade to previous working version with : $ sudo pacman -U file:///var/cache/pacman/pkg/gamemode-1.7-1-x86_64.pkg.tar.zst

bg2908 commented 8 months ago

From the new gamemode.ini file

; GameMode can renice game processes. You can put any value between 0 and 20 here, the value ; will be negated and applied as a nice value (0 means no change). Defaults to 0. ; To use this feature, the user must be added to the gamemode group (and then rebooted): ; sudo usermod -aG gamemode $(whoami) renice=0

So I ran the command and added my username to the group gamemode, and now gamemode 1.8.1 work normally. I did not intend to use the renice function though.

Kagukara commented 8 months ago

Just ran into this "issue" and adding myself to the gamemode group and restarted PC fixed the "problem". Is adding the user to the gamemode group now indented for gamemode to work?

SaschaVasarrhelyi commented 8 months ago

In my case that worked not for me. Gamemode can´t change the Governor. I added me to the group gamemode but no success.

bg2908 commented 8 months ago

I added me to the group gamemode but no success.

Did you rebooted the machine? From the gamemod.ini

To use this feature, the user must be added to the gamemode group (and then rebooted):

SaschaVasarrhelyi commented 8 months ago

Yes. I added me user to the gamemode group with "sudo usermod -aG gamemode sascha" in the terminal , reboot and do install again gamemode-1.8.1 because there was no effect by test gamemode with gamemoded -t in the console. The CPU Governor can't change from gamemode-1.8.1 but the rest of the test are successfully as it was before.

lxmint commented 8 months ago

It worked for me without reboot after killing gamemoded process and adding my user to the gamemode group with vi.

devz3r0 commented 8 months ago

I had the same issue, adding the user to the group fixed it, I even did not need to do a reboot. So it is now not only for the renice process, now it counts for the governor too. Why is this behavior change happening out of sudden?

Tuskiurhil commented 8 months ago

From the new gamemode.ini file

; GameMode can renice game processes. You can put any value between 0 and 20 here, the value ; will be negated and applied as a nice value (0 means no change). Defaults to 0. ; To use this feature, the user must be added to the gamemode group (and then rebooted): ; sudo usermod -aG gamemode $(whoami) renice=0

So I ran the command and added my username to the group gamemode, and now gamemode 1.8.1 work normally. I did not intend to use the renice function though.

stumbled upon the same issue today and adding myself to the gamemode group fixed it for me.

frugaltech commented 8 months ago

I have been looking into this issue as well. I see a change in data/com.feralinteractive.GameMode.policy.in from version 1.7.0 to version 1.8.1. If I use the file from version 1.7.0, everything works. I am no Policykit expert, but to me, it looks like the new version of the policy does not actually allow anything. In any case, tweaking this file seems to work.

CargaisonTuba commented 8 months ago

Hello, I have the same line "ERROR: Governor was not set to performance (was actually powersave)!" However I'm new to linux and I don't know how to add a user to a group (I don't even know how it's related to the problem) Also despite following the instructions for Ubuntu (I run Kubuntu) I don't why gamemode is installed in /home, and now the commands provided to uninstall it doesn't work ninja: Entering directorybuilddir' ninja: fatal: chdir to 'builddir' - No such file or directory ` If someone has the time to answer me, thanks

SaschaVasarrhelyi commented 8 months ago

Hi, try to open a Terminal (Strg + Alt + t) and type into it

cd /home/$USER/gamemode

then make the uninstall steps again, also

systemctl --user stop gamemoded.service ninja uninstall -C builddir

It shuld now find the Builddir to uninstall it. Greetings

jhpgcj commented 8 months ago

Can confirm this very issue also happens to me. I'm using gamemode 1.8.1 (happened on 1.8 too, not on 1.7), Pop OS! 22.04 (kernel 6.6.6), already tried adding my user to gamemode group and restarting. Issue still remains.

marcj303 commented 8 months ago

I don't get any directory permissions issue, but I do get the ERROR: Governor was not set to performance (was actually schedutil)! I ran built and installed with bootstrap.sh, added myself to the gamemode group, and rebooted. No errors were reported until I ran gamemoded -t.

$ gamemoded -t
: Loading config
Loading config file [/usr/share/gamemode/gamemode.ini]
: Running tests

:: Basic client tests
:: Passed

:: Dual client tests
gamemode request succeeded and is active
Quitting by request...
:: Passed

:: Gamemoderun and reaper thread tests
...Waiting for child to quit...
...Waiting for reaper thread (reaper_frequency set to 5 seconds)...
:: Passed

:: Supervisor tests
:: Passed

:: Feature tests
::: Verifying CPU governor setting
ERROR: Governor was not set to performance (was actually powersave)!
::: Failed!
::: Verifying Scripts
::: Passed (no scripts configured to run)
::: Verifying GPU Optimisations
::: Passed (gpu optimisations not configured to run)
::: Verifying renice
::: Passed (no renice configured)
::: Verifying ioprio
::: Passed
ERROR: :: Failed!
: Tests Failed!

I built:

8cea4c2 (HEAD -> master, origin/master, origin/HEAD) Fix hybrid CPU core pinning
4a82094 Fix build with musl
5180d89 (tag: 1.8.1) Update version to 1.8.1
$ id
uid=1000(marc) gid=1000(marc) groups=1000(marc),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),133(lxd),134(sambashare),998(gamemode)
$ uname -a
Linux samus2 6.5.0-14-generic #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
tim-rex commented 7 months ago

Added myself to gamemode group

sudo gpasswd -a $USER gamemode

This appears to have resolved the immediate issue for me. gamemoded -t now succeeds and no further instances of privilege errorsin the system journal when activating/deactivating gamemode from code.

Arch Linux with gamemode v1.8.1

I do still see the following, not sure what that's about at present

ERROR: Could not inspect tasks for client [19204]! Skipping ioprio optimisation.
hir0xygen commented 7 months ago

Can reproduce, adding oneself to the gamemode group (creating it beforehand if it does not exist) fixes the issue at hand.

Edit: Tested on latest Debian stable 12.4 with GNOME

jhpgcj commented 7 months ago

Can reproduce, adding oneself to the gamemode group (creating it beforehand if it does not exist) fixes the issue at hand.

Added my user to the group (it already existed) and the issue remains.

SaschaVasarrhelyi commented 7 months ago

It dosen't fix for me too. The Group:gamemode exists and i am in the group gamemode. That dosn't fix the problem on Ubuntu Mate 22.04 LTS with Kernel: Kernel Linux 6.5.0-14-generic x86_64 and Mate: MATE 1.26.0 It must be an other reason why gamemode-1.8.1 have no rights to change the CPU- Governor on Ubuntu x.xy

Iron-Squid commented 7 months ago

This occurs for me as well, on Arch Linux. Adding myself to the gamemode group using usermod clears the issue of not being able to pass a test. https://wiki.archlinux.org/title/Gamemode#Installation

Though, the polkit issue still remains regardless of this quick fix to get gamemode working.

Iron-Squid commented 7 months ago

The polkit issue seems to be resolved by changing the permission of /usr/share/polkit-1/rules.d from 750 to 755. https://bbs.archlinux.org/viewtopic.php?pid=2144554#p2144554

This fix is specific to Arch Linux. I'm unsure if it'll work for any other distros.

SaschaVasarrhelyi commented 7 months ago

What Polkit Rules Files and rights are in Your Directory? Can You Put the Terminaloutput from "ls -l /usr/share/polkit-1/rules.d/" ? In my case it is: -rw-r--r-- 1 root root 515 Feb 10 2022 blueman.rules -rw-r--r-- 1 root root 263 Mär 17 2021 geoclue-2.0.rules -rw-r--r-- 1 root root 368 Feb 7 2022 org.freedesktop.bolt.rules -rw-r--r-- 1 root root 768 Mär 16 2023 org.freedesktop.Flatpak.rules -rw-r--r-- 1 root root 251 Mai 17 2023 org.freedesktop.fwupd.rules -rw-r--r-- 1 root root 261 Jun 9 2022 org.freedesktop.NetworkManager.rules -rw-r--r-- 1 root root 334 Mär 14 2022 org.freedesktop.packagekit.rules -rw-r--r-- 1 root root 594 Jun 3 2022 org.gtk.vfs.file-operations.rules -rw-r--r-- 1 root root 527 Mär 11 2022 systemd-networkd.rules

SaschaVasarrhelyi commented 7 months ago

I am reinstall the 1.8.1 Version of Gamemode again and take the Terminaloutput here:

:~/gamemode$ ./bootstrap.sh

Build targets in project: 10

gamemode 1.8.1

User defined options buildtype : debugoptimized prefix : /usr with-systemd-user-unit-dir: /etc/systemd/user

Found ninja-1.10.1 at /usr/bin/ninja

mikeyjoel commented 7 months ago

Confirming that adding to group works on opensuse tumbleweed as well.

sudo zypper install -y gamemode gamemode gamemode libgamemodeauto0;
sudo usermod -a -G gamemode $(whoami)
systemctl --user enable --now gamemoded.service;

Then proceed with testing and using on your launcher/games. gamemoded -t;

SaschaVasarrhelyi commented 7 months ago

On Ubuntu-Mate 22.04LTS that dosn't work. I'am in the group gamemode but it's not work. It is not able to change the governor and the test with gamemode -t failed.

marcj303 commented 7 months ago

For those that are still having issues even after adding yourself to the gamemode group (and rebooting)...

My setup: Ubuntu 22.04 with the 6.5 kernel (HWE). AMD 5600G CPU.

TLDR:sudo apt install linux-tools-6.5.0-15-generic

I decided to check alternative utilities that would let me set the governor and what my issue might be with gamemode. I had updated to the newer 6.5 kernel for the new performance features for AMD recently. In looking at governor documentation I learned that the 6.5 kernel supports the new AMD p-state driver: https://docs.kernel.org/admin-guide/pm/amd-pstate.html

I tried running the cpupower utility, but hit a warning:

WARNING: cpupower not found for kernel 6.5.0-15-generic

You may need to install the following packages for this specific kernel: linux-tools-6.5.0-15-generic linux-cloud-tools-6.5.0-15-generic

You may also want to install one of the following packages to keep up to date: linux-tools-generic linux-cloud-tools-generic

I checked and linux-tools-generic points to the 5.15 kernel version, so we need to install the 6.5 version.

linux-tools-generic is already the newest version (5.15.0.92.89)

sudo apt install linux-tools-6.5.0-15-generic
sudo apt install cpupower

Then I'm able to set the governor with cpupower.

sudo cpupower frequency-info
sudo cpupower frequency-set
sudo cpupower frequency-set -g performance
sudo cpupower frequency-set -g powersave

After linux-tools-6.5.0-15-generic was installed, I was able to run gamemoded -t successfully.

Maybe someone else knows what is in the linux-tools that is required for gamemoderun. And maybe gamemoded could give a warning if it isn't installed.

https://ubuntu.pkgs.org/22.04/ubuntu-updates-main-amd64/linux-tools-6.5.0-15-generic_6.5.0-15.15~22.04.1_amd64.deb.html

This package provides the architecture dependant parts for kernel version locked tools (such as perf and x86_energy_perf_policy) for version 6.5.0-15 on 64 bit x86.

SaschaVasarrhelyi commented 7 months ago

I test it, but it's failed again. I install linux-tools everytime i get an new kernel because of using cpupower to set my cpu to powersave on startup but i have give it another try and uninstall gamemode 1.7 and install gamemode 1.8.1 again. Have you removed gamemode 1.7 as root? Otherwise ninja can not delete the files from the old version. If you try "gamemoded -v" the version of the gamemode in use you can see in the terminal. I'am interrested what version you have test.

CargaisonTuba commented 7 months ago

Hi as a linux noob I just didn't see it was available as a package for Ubuntu. So I installed it using apt install gamemode and it works well now. Sorry for disturbing you and thanks for your work.

SaschaVasarrhelyi commented 7 months ago

Hi, the Ubuntu Packages are very outdated if you use the LTS. The Git- Release are the newest versions of this Application and have to compile by yourself if you want to use the newest App- Version of Gamemode. If you don't want the newest Version with new Feature youre right to use the Ubuntu Package to install with Synaptic ore an other Package- manager. The Problem is the version 1.8.1 (Newest Release at the Moment) that not run at Ubuntu as it should.

thican commented 6 months ago

@SaschaVasarrhelyi

It dosen't fix for me too. The Group:gamemode exists and i am in the group gamemode. That dosn't fix the problem on Ubuntu Mate 22.04 LTS with Kernel: Kernel Linux 6.5.0-14-generic x86_64 and Mate: MATE 1.26.0 It must be an other reason why gamemode-1.8.1 have no rights to change the CPU- Governor on Ubuntu x.xy

It also happened to me, until I noticed the directory /sys/devices/system/cpu/cpufreq on my system was empty, and therefore no cpufreq symlinks under each /sys/devices/system/cpu/cpuX repertories; those messages when running gamemoded --test were the tell:

ERROR: glob failed for cpu governors: (No such file or directory)
ERROR: glob failed for cpu governors: (No such file or directory)
ERROR: Governor was not set to performance (was actually )!

Notice how in the last message, the content after "was actually" is empty string.

In fact the former directory was empty because my kernel (configured by myself) was lacking the correct P-State option for my CPU. So enable CONFIG_X86_INTEL_PSTATE or CONFIG_X86_AMD_PSTATE (or both) according to your CPU vendor (or try using the expected kernel binary from your distribution).

ralmachado commented 6 months ago

Same problem on Pop_OS! 22.04, with the 6.6.10-76060610-generic kernel.

The gamemode group did not exist, so I created it as a regular user group and added myself to the group - did not work. I then tried creating the group as a system group (gid < 1000) - did not work.

Also tried @marcj303's answer by installing the kernel appropriate linux-tools package - also did not work.

Ultimately, polkit seems to be denying the execution of any gamemode tools, as @SaschaVasarrhelyi commented in https://github.com/FeralInteractive/gamemode/issues/411#issuecomment-1863503664. The gamemode.rules file is in /usr/share/polkit-1/rules.d/, with file permissions matching other files in the directory (644).

journalctl output:

Mar 08 12:49:15 sieger pkexec[6902]: rodrigo: Error executing command as another user: Not authorized [USER=root] [TTY=unknown] [CWD=/home/rodrigo] [COMMAND=/usr/libexec/cpugovctl set performance]
Mar 08 12:49:15 sieger gamemoded[2610]: Requesting update of governor policy to perfo
Mar 08 12:49:15 sieger gamemoded[6902]: Error executing command as another user: Not authorized
Mar 08 12:49:15 sieger gamemoded[6902]: This incident has been reported.
Mar 08 12:49:15 sieger gamemoded[2610]: ERROR: External process failed with exit code 127
Mar 08 12:49:15 sieger gamemoded[2610]: ERROR: Output was:
Mar 08 12:49:15 sieger gamemoded[2610]: ERROR: Failed to update cpu governor policy
Mar 08 12:49:15 sieger pkexec[6905]: rodrigo: Error executing command as another user: Not authorized [USER=root] [TTY=unknown] [CWD=/home/rodrigo] [COMMAND=/usr/libexec/procsysctl split_lock_mitigate 0]
Mar 08 12:49:15 sieger gamemoded[6905]: Error executing command as another user: Not authorized
Mar 08 12:49:15 sieger gamemoded[6905]: This incident has been reported.
Mar 08 12:49:15 sieger gamemoded[2610]: ERROR: External process failed with exit code 127
Mar 08 12:49:15 sieger gamemoded[2610]: ERROR: Output was:
Mar 08 12:49:15 sieger gamemoded[2610]: ERROR: Failed to update split_lock_mitigate
Mar 08 12:49:15 sieger gamemoded[2610]: ERROR: Skipping ioprio on client [6858,6858]: ioprio was (0) but we expected (4)
Mar 08 12:49:15 sieger pkexec[6908]: rodrigo: Error executing command as another user: Not authorized [USER=root] [TTY=unknown] [CWD=/home/rodrigo] [COMMAND=/usr/libexec/procsysctl split_lock_mitigate 1]
Mar 08 12:49:15 sieger gamemoded[6908]: Error executing command as another user: Not authorized
Mar 08 12:49:15 sieger gamemoded[6908]: This incident has been reported.
Mar 08 12:49:15 sieger gamemoded[2610]: ERROR: External process failed with exit code 127
Mar 08 12:49:15 sieger gamemoded[2610]: ERROR: Output was:
Mar 08 12:49:15 sieger gamemoded[2610]: ERROR: Failed to update split_lock_mitigate

id output:

uid=1000(rodrigo) gid=1000(rodrigo) groups=1000(rodrigo),4(adm),27(sudo),46(plugdev),124(lpadmin),137(sambashare),138(gamemode),999(docker)

Sleuthing on StackExchange, it was said that JavaScript style .rules do not work on polkit < 0.106 (pkaction --version reports 0.105), which is odd because there are multiple other rules files in /usr/share/polkit-1/rules.d/, including ones from flatpak and systemd. So I then tried to create a pkla file mimicking gamemode.rules, /etc/polkit-1/localauthority/50-local.d/99-gamemode.pkla shown below, but that also did not work.

[Enable gamemode requests]
Identity=unix-user:gamemode
Action=com.feralinteractive.GameMode.governor-helper;com.feralinteractive.GameMode.gpu-helper;com.feralinteractive.GameMode.cpu-helper;com.feralinteractive.GameMode.procsys-helper
ResultAny=yes
ResultInactive=yes
ResultActive=yes

Could it really be that polkit < 0.106 won't allow gamemode versions above 1.7 to work at all?

JustCauseWhyNot commented 6 months ago

I'm using gentoo, and gamemode renice isn't working even if after adding my user to the gamemode group.

ralmachado commented 6 months ago

Tested on EndeavourOS (polkit 124) and Ubuntu 23.10 (polkit 123) - both worked and passed all tests, which makes me think polkit might be the culprit here.

To really ensure that issue lies with polkit, it would have to be upgraded from source on Ubuntu 22.04, keeping as many other packages intact, but I'm not too keen on doing that on the only machine I have and possibly breaking something :/

Screenshot_20240309_125753 Screenshot from 2024-03-09 13-30-24

ralmachado commented 6 months ago

I got it to work, the solution is to create the following .pkla in /etc/polkit-1/localauthority/50-local.d:

[Enable gamemode requests]
Identity=unix-group:gamemode
Action=com.feralinteractive.GameMode.governor-helper;com.feralinteractive.GameMode.gpu-helper;com.feralinteractive.GameMode.cpu-helper;com.feralinteractive.GameMode.procsys-helper
ResultAny=yes
ResultInactive=yes
ResultActive=yes

Basically, it's the same as the gamemode.rules file but in the older format accepted by the outdated polkit in Ubuntu 22.04.

image

JustCauseWhyNot commented 6 months ago

I've tried what you pasted, and it still doesn't work for me.

id ``` uid=1000(justcausewhynot) gid=1000(justcausewhynot) groups=1000(justcausewhynot),10(wheel),18(audio),27(video),85(usb),97(input),100(users),250(portage),272(plugdev),385(gamemode) ```

gamemode version: v1.8.1 pkaction version 124

ralmachado commented 6 months ago

I've tried what you pasted, and it still doesn't work for me. id

uid=1000(justcausewhynot) gid=1000(justcausewhynot) groups=1000(justcausewhynot),10(wheel),18(audio),27(video),85(usb),97(input),100(users),250(portage),272(plugdev),385(gamemode)

gamemode version: v1.8.1 pkaction version 124

My solution was intended only for outdated polkit versions (used in Ubuntu LTS), which doesn't support the shipped polkit rules file.

I tried a clean build in an arch based distro with polkit 124 and it worked. Check journalctl output after a gamemoded -t to see if the issue is in fact polkit :)

JustCauseWhyNot commented 6 months ago

Here's my ~/everthing/current log

``` Mar 09 11:59:29 [polkitd] Started polkitd version 124 Mar 09 11:59:29 [polkitd] Loading rules from directory /etc/polkit-1/rules.d Mar 09 11:59:29 [polkitd] Loading rules from directory /usr/share/polkit-1/rules.d Mar 09 11:59:29 [polkitd] Finished loading, compiling and executing 2 rules Mar 09 11:59:29 [dbus-daemon] [system] Successfully activated service 'org.freedesktop.PolicyKit1' Mar 09 11:59:29 [polkitd] Acquired the name org.freedesktop.PolicyKit1 on the system bus Mar 09 11:59:29 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:29 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/cpugovctl set performance] Mar 09 11:59:29 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:29 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/gpuclockctl 0 set -1 -1 1] Mar 09 11:59:29 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:29 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/gpuclockctl 0 set 0 0 1] Mar 09 11:59:29 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:29 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/cpugovctl set ] Mar 09 11:59:29 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:29 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/cpugovctl set performance] Mar 09 11:59:29 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:29 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/gpuclockctl 0 set -1 -1 1] Mar 09 11:59:29 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:29 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/gpuclockctl 0 set 0 0 1] Mar 09 11:59:29 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:29 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/cpugovctl set ] Mar 09 11:59:29 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:29 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/cpugovctl set performance] Mar 09 11:59:30 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:30 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/gpuclockctl 0 set -1 -1 1] Mar 09 11:59:34 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:34 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/gpuclockctl 0 set 0 0 1] Mar 09 11:59:34 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:34 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/cpugovctl set ] Mar 09 11:59:35 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:35 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/cpugovctl set performance] Mar 09 11:59:35 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:35 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/gpuclockctl 0 set -1 -1 1] Mar 09 11:59:35 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:35 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/gpuclockctl 0 set 0 0 1] Mar 09 11:59:35 [pkexec] pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000) Mar 09 11:59:35 [pkexec] justcausewhynot: Executing command [USER=root] [TTY=unknown] [CWD=/] [COMMAND=/usr/libexec/cpugovctl set ] ```
JustCauseWhyNot commented 6 months ago

I found out the issue. It's the fact that in /etc/security/limits.d/10-gamemode.conf it's set to -10 not -20. The odd thing is that despite me now changing it to -20 gamemoded renice is still failing with anything past 10. Do I need to do something to update polkit configs?

After more testing the max I can set is -19. -20 doesn't work for somereason despite setting -20 in gamemode.conf

ralmachado commented 6 months ago

I found out the issue. It's the fact that in /etc/security/limits.d/10-gamemode.conf it's set to -10 not -20. The odd thing is that despite me now changing it to -20 gamemoded renice is still failing with anything past 10. Do I need to do something to update polkit configs?

After more testing the max I can set is -19. -20 doesn't work for somereason despite setting -20 in gamemode.conf

This is a niceness problem, not really related to this issue, but yes, you should only let usermode processes renice to -19 for safety reasons. Root should be able to renice to -20 to kill any hung processes.

In any case, setting the limit to -19 should be enough, otherwise disable renice in gamemode config.

SaschaVasarrhelyi commented 6 months ago

Hi @ralmachado, you are right, i try to make this .pkla file at the right position as you say and it's work for me with the gamemode 1.8.1. Thank you very much

SaschaVasarrhelyi commented 6 months ago

:~$ gamemoded -v gamemode version: v1.8.1

:~$ gamemoded -t : Loading config Loading config file [/usr/share/gamemode/gamemode.ini] : Running tests

:: Basic client tests :: Passed

:: Dual client tests gamemode request succeeded and is active Quitting by request... :: Passed

:: Gamemoderun and reaper thread tests ...Waiting for child to quit... ...Waiting for reaper thread (reaper_frequency set to 5 seconds)... :: Passed

:: Supervisor tests :: Passed

:: Feature tests ::: Verifying CPU governor setting ::: Passed ::: Verifying Scripts ::: Passed (no scripts configured to run) ::: Verifying GPU Optimisations ::: Passed (gpu optimisations not configured to run) ::: Verifying renice ::: Passed (no renice configured) ::: Verifying ioprio ::: Passed :: Passed

: All Tests Passed!

Good work

stvoidit commented 5 months ago

I faced the same problem, but in slightly different conditions, as it seemed to me, however, the solution https://github.com/FeralInteractive/gamemode/issues/452#issuecomment-1986861524 It helped me.

OS: Linux Mint 21.3 x86_64
Host: 82UH Legion 7 16ARHA7
Kernel: 6.8.4-stvoid
Shell: bash 5.1.16
DE: Cinnamon 6.0.4
CPU: AMD Ryzen 9 6900HX with Radeon Graphics (16) @ 4.935GHz
GPU: AMD ATI Radeon RX 6700/6700 XT / 6800M
GPU: AMD ATI 37:00.0 Rembrandt

By default, the version from the standard Ubuntu "1.6.1-1 build2" repository was installed.

I wanted to put together a more recent version. Fortunately, everything worked out the first time, although I often have errors with the assembly of some modules and other things, because I am building an up-to-date stable kernel with clang-18, so the variables CC=clang-18 CXX=clang-18 LLVM=-18 were set in my environment (I don't know if it could does this affect a successful build, but suddenly someone will encounter).

Immediately after successful completion ./bootstrap.sh I ran the "gamemoded -t" test and got this error.

At first I tried to add myself to the gamemode group, but it didn't work because there was no such group. However, this was not a problem for version 1.6.1.

After the reboot, I added myself to the group again and this time the group already existed. However, this did not eliminate the problem with passing the tests. Therefore, I created the file /etc/polkit-1/localauthority/50-local.d/gamemode.pkla by logging in as root (pkaction version 0.105). After that, I rebooted, ran the tests and they worked.


At the moment, I am observing errors in the log, more specifically, I am interested in what is said about IGPU, can I ignore it and everything is fine or does it need to be solved?

апр 05 23:47:59 space pkexec[10216]: pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000)
апр 05 23:47:59 space gamemoded[10185]: ERROR: Configured iGPU power threshold value '-1.000000' is invalid, ignoring iGPU default governor.
апр 05 23:47:59 space gamemoded[10185]: ERROR: Failed to open file for read /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:0/energy_uj
апр 05 23:47:59 space pkexec[10219]: pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000)
апр 05 23:47:59 space gamemoded[10185]: ERROR: Skipping ioprio on client [10215,10215]: ioprio was (0) but we expected (4)
апр 05 23:47:59 space gamemoded[10185]: ERROR: Skipping ioprio on client [10223,10223]: ioprio was (0) but we expected (4)
апр 05 23:47:59 space gamemoded[10185]: ERROR: Addition requested for already known client 10223 [/home/stvoid/.local/share/Steam/ubuntu12_32/steam-launch-wrapper].
апр 05 23:47:59 space gamemoded[10185]:     -- This may happen due to using exec or shell wrappers. You may want to
апр 05 23:47:59 space gamemoded[10185]:     -- blacklist this client so GameMode can see its final name here.
апр 05 23:47:59 space gamemoded[10185]: ERROR: Skipping ioprio on client [10226,10226]: ioprio was (0) but we expected (4)
gamemoded -s
> gamemode is active
stvoidit commented 5 months ago

little update: grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

When using the game, I see that the value of scaling_governor changes correctly to performance, and this leads to powersave

I don't know if it's related, but I was interested in checking it out.

nipnipj commented 5 months ago

Linux mint 21.3 here.

::: Verifying CPU governor setting
ERROR: Governor was not set to performance (was actually schedutil)!

This Comment worked!

brooksvb commented 4 months ago

This is the policy that helped me:

// /etc/polkit-1/rules.d/10-gamemode.rules
polkit.addRule(function(action, subject) {
    if (action.id.match("com.feralinteractive.GameMode.governor-helper") ||
        action.id.match("com.feralinteractive.GameMode.gpu-helper") ||
        action.id.match("com.feralinteractive.GameMode.cpu-helper") ||
        action.id.match("com.feralinteractive.GameMode.procsys-helper")) {
        if (subject.isInGroup("gamemode") || subject.user === "<YOUR USERNAME>") {
            return polkit.Result.YES;
        }
    }
});
TickDracy commented 4 months ago

I got it to work, the solution is to create the following .pkla in /etc/polkit-1/localauthority/50-local.d:

Thanks a lot. That indeed solved it for me on Pop!_OS 22.04.

Noob question: Creating that file is harmless, or it can create hypothetical issues with other apps?

ralmachado commented 4 months ago

Noob question: Creating that file is harmless, or it can create hypothetical issues with other apps?

In theory, no. The pkla is simply an older format for polkit rules, and the one I posted is simply the translation of gamemode polkit rules to it. (I am in no way an expert into how polkit works, but unless the rules can be exploited by other applications this should not cause issues, security or compatibility wise)

Samueru-sama commented 3 months ago

I get usermod: group 'gamemode' does not exist when trying to run usermod -aG gamemode $(whoami)

This is on artix linux.

EDIT: I was able to fix the issue by manually creating the group with groupadd -f 'gamemode' now it passes all tests.

hbacelar8 commented 1 month ago

Worked for me after simply changing my linux power settings from Balanced to Performance (UI settings on Pop OS)