Skip to content

Conversation

samrocketman
Copy link
Contributor

@samrocketman samrocketman commented Jan 2, 2022

While trying out gamemode on Ubuntu 18.04 I had trouble figuring out whether or not my games were running with gamemode enabled. I wrote this utility which prints all processes loaded with the gamemode shared library.

  • Added utility to data/ folder.
  • Update meson installer.
  • Included section 1 manual.
  • Updated README for Ubuntu 18.04 build instructions. Steam supports Ubuntu 18.04.

I'm open to feedback and generally this should work for any distribution since it makes use of the Linux /proc filesystem. Learn more about /proc.

Thanks in advance

image

@samrocketman samrocketman force-pushed the list-processes-using-gamemode branch 2 times, most recently from 752bb95 to b563d36 Compare January 2, 2022 05:14
@samrocketman
Copy link
Contributor Author

Here's an example of my running the command after starting a game.

$ gamemodelist
  PID  PPID USER      NI PSR COMMAND
19614 19573 sam       10   2 python3
19634 19614 sam       10   6 steam
19641 19573 sam       10   5 wineserver
19659 19573 sam       10   6 services.exe
19662 19573 sam       10   6 winedevice.exe
19670 19573 sam       10   5 plugplay.exe
19683 19573 sam       10   4 winedevice.exe
19718 19573 sam       10   2 svchost.exe
19724 19573 sam       10   6 explorer.exe
19740 19573 sam       10   0 rpcss.exe
19750 19573 sam       10   5 tabtip.exe
19775 19573 sam       -1   0 RustClient.exe
19779 19573 sam       10   2 UnityCrashHandl

Started steam game with taskset 77 nice gamemoderun %command% and I reniced my game to be higher priority than other userland processes via following command.

pgrep -f RustClient.exe | xargs -n1 -- sudo -- renice -n -1

@samrocketman samrocketman force-pushed the list-processes-using-gamemode branch from b563d36 to 18989a0 Compare January 2, 2022 05:28
@samrocketman samrocketman force-pushed the list-processes-using-gamemode branch from 18989a0 to 605cd4d Compare January 4, 2022 15:11
@mdiluz
Copy link
Contributor

mdiluz commented Jan 4, 2022

I like it 👍

Unfortunately though libgamemodeauto.so isn't the only way that programs request gamemode, so to be truly correct this would likely need to query the gamemoded daemon itself for the list of PIDs.

@samrocketman
Copy link
Contributor Author

@mdiluz how would one query gamemoded? Reading the manual I don't see a way.

@mdiluz
Copy link
Contributor

mdiluz commented Jan 6, 2022

So getting that set up would be way more involved unfortunately. The current API has a query function here that can get the status for a single PID, but for your use case what you'd possibly need is a new API method to fetch the list of currently registered processes.

@samrocketman
Copy link
Contributor Author

samrocketman commented Jan 8, 2022

While it may not be a complete solution it does its intended purpose. Most games would launch from Steam via gamemoderun. Considering the plethora of references most users would configure steam launch options to use gamemoderun. I understand game developers might integrate differently with gamemode than a user configuring launch options.

I think while no API exists this is a good enough stop-gap measure for users trying to troubleshoot if the game they've opened is running with gamemode successfully. I had trouble verifying this before writing the script.

With the lack of API in gamemoded listing PIDs is it unlikely this PR will be merged?

@mdiluz
Copy link
Contributor

mdiluz commented Jan 8, 2022

You make a good point and you make it well 👍

We'll have to see if the Feral folks decide whether it's fair to merge with the current "bug", but I think it seems sane, and this feels like a little block of work I'd be happy to PR some time in the next few weeks when I get a chance.

While trying out gamemode on Ubuntu 18.04 I had trouble figuring out
whether or not my games were running with gamemode enabled.  I wrote this
utility which prints all processes loaded with the gamemode shared
library.

- [x] Added utility to `data/` folder.
- [x] Update meson installer.
- [x] Included section 1 manual.
- [x] Updated README for Ubuntu 18.04 build instructions.  Steam supports
  Ubuntu 18.04.

I'm open to feedback and generally this should work for any distrobution
since it makes use of the Linux `/proc` filesystem.  [Learn more about
`/proc`][1].

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/filesystems/proc.rst?h=v5.15.12
@samrocketman samrocketman force-pushed the list-processes-using-gamemode branch from 605cd4d to 150ebd6 Compare February 14, 2022 05:55
@samrocketman
Copy link
Contributor Author

Rebased on master.

@afayaz-feral
Copy link
Contributor

This looks very useful - thank you!

My only suggestion would be to briefly mention in the manpage and comments that this is currently limited to games that request gamemode via libgamemodeauto.so.

@samrocketman
Copy link
Contributor Author

My only suggestion would be to briefly mention in the manpage and comments that this is currently limited to games that request gamemode via libgamemodeauto.so.

I'll push a change.

Also, the CI failure appears to be unrelated to my change. Does the CI failure block merging?

@samrocketman
Copy link
Contributor Author

@afayaz-feral I pushed a new commit instead of squashing like I normally do so that you can see what changed.

@samrocketman
Copy link
Contributor Author

I wasn't able to replicate check-format.sh issues reported.

Test image

FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN set -ex; \
apt-get update; \
apt-get install -y build-essential meson appstream clang clang-format clang-tools libdbus-1-dev libinih-dev libsystemd-dev git

RUN set -ex; \
yes | adduser ci-user

USER ci-user

Run docker as user

sudo su -g docker $USER

Build image

docker build -t ci .

Run CI checks

$ id
uid=1000(sam) gid=998(docker) groups=998(docker)

$ docker run --rm ci id
uid=1000(ci-user) gid=1000(ci-user) groups=1000(ci-user)

$ docker run --rm -v "$PWD:$PWD" -w "$PWD" --init ci ./scripts/format-check.sh
Passed clang format check

@samrocketman
Copy link
Contributor Author

I figured it out. I'll open a separate PR.

@samrocketman
Copy link
Contributor Author

#355 opened separate pull request to fix CI checks.

@afayaz-feral
Copy link
Contributor

Thanks, I will merge this now.

I figured it out. I'll open a separate PR.

I couldn't replicate this locally either, and hadn't gotten around to looking into it in more depth. So thank you for solving it!

@afayaz-feral afayaz-feral merged commit c96f737 into FeralInteractive:master Feb 21, 2022
@samrocketman
Copy link
Contributor Author

So thank you for solving it!

You're welcome.

@samrocketman samrocketman deleted the list-processes-using-gamemode branch February 25, 2022 21:12
@FLAGEL
Copy link

FLAGEL commented Jan 3, 2024

Might seem obvious, but for sake of completeness, it is worth mentioning that running gamemodelist on a host where gamemoderun was executed from within a Flatpak will not print all processes loaded with the gamemode shared library.

That said, nice script! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants