gamemode icon indicating copy to clipboard operation
gamemode copied to clipboard

energy_uj is no longer readable

Open Calchan opened this issue 4 years ago • 3 comments

Describe the bug As per this commit read access to /sys/class/powercap/intel-rapl*/*/energy_uj for non-privileged users is no longer allowed.

This appeared in kernel 5.4.77.

Since gamemoded should be started as a user service, it no longer has access to these system interfaces which means the iGPU governor feature is now broken.

To Reproduce Steps used to reproduce the behavior:

  1. Launch gamemod via systemctl --user start gamemoded.service
  2. Run gamemode-simulate-game or gamemoded -t
  3. Monitor the output of journalctl -f -n 0
  4. See error: Failed to open file for read /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:0/energy_uj

Expected behavior Not seeing the error above and being able to use the iGPU governor feature.

System Info (please complete the following information):

  • OS and version: debian sid/experimental with kernel 5.13.9
  • GameMode Version: 1.6.1

Additional context I use the script below started as a system (i.e., not user) systemd service, then add users who need GameMode to the games group.

#! /bin/bash

for NAME_PATH in $(find /sys/class/powercap/intel-rapl/intel-rapl\:0/intel-rapl\:0\:* -name name || true); do
    NAME=$(cat "${NAME_PATH}")
    if [[ "${NAME}" == "core" ]] || [[ "${NAME}" == "uncore" ]]; then
         DIR_NAME=$(dirname "${NAME_PATH}")
         chown root:games "${DIR_NAME}/energy_uj"
         chmod g+r "${DIR_NAME}/energy_uj"
    fi
done

It's a bit crude but it works. It seems this needs to be fixed with GameMode providing a script and systemd service like I do (or any better solution, or at least documentation of the issue and example of possible resolution), or the iGPU governor feature should be removed.

Calchan avatar Aug 12 '21 19:08 Calchan

Still having this issue, after trying this workaround I stopped getting permission denied errors and now get invalid argument errors(using no config file or the example config file). Kernel 5.14.2-1-MANJARO.

ghost avatar Sep 23 '21 19:09 ghost

I use the script below started as a system (i.e., not user) systemd service, then add users who need GameMode to the games group.

Thanks for this, it's a nice albeit slightly hacky trick but it works on my system too (Ubuntu 20.04).

leemm avatar Oct 10 '21 19:10 leemm