This simply tests the current functionality of the gamemode_client tools by calling each function in turn and checking the values return correctly.
Requires the gamemode service to currently be running and installed on the system.
This allows the client to query the daemon about the status of gamemode.
Returns the following:
0 if gamemode is inactive
1 if gamemode is active
2 if gamemode is active and this client is registered
-1 if the query failed
Passing -s to gamemoded will simply query and print the current status.
Allows for more comprehensive testing when using 'gamemoded -r' as well as more reactionary program behaviour
Primarily we convert the service into a thread safe one that isn't reliant
on signaling for control flow, eliminating data race conditions. We also
enable interleaving by separating game mode pivoting from explicit client
registration.
The static pid list is now converted into a dynamic list that is OOM safe
to store all registered clients (with a reasonable upper limit of 256 clients)
to better handle cases where LD_PRELOAD is used for a large process group.
Additionally we begin storing some metadata on the connected clients such
as their executable path, which will enable us to perform some basic
whitelisting in future.
The cpugovctl binary is now moved into the libexecdir as an explicit helper
of the D-BUS service, using the shared library to merge some code back into
the daemon. This saves having to execute a process to query the state of the
governors, as we don't need a privileged client to do this.
In order to sanely set the governors, we require that the binary is running
as euid 0, and execute this using `pkexec`. A PolKit policy definition is
provided which allows active/logged in users to execute this helper through
a path whitelist. As such we can convert the daemon into user-mode only, with
the privileged helper being dispatched exclusively via polkit. This removes
the need for a setuid helper or having a system mode daemon.
Lastly we clean up the codebase a bit to be consistent with modern C code
conventions, using pragmas where available. The library component still uses
the older ifdef approach to support older compilers, but the daemon portion
uses the directive to simplify intent and speed up compilation. Additionally
we move all comments to C style comments for consistency, instead of mixing
in C++ style single line comments, in order to establish a formal coding
style.
The net result is a more robust service which can be D-BUS activated when
clients need it, that can perform scaling automatically without harassing
the user with authentication popups.
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This is a small daemon/libary to enable games to request a
performance "game mode" from the system.
Currently only implemented to upgrade the CPU governor and
automatically downgrade it once done.
A game only needs to load libgamemodeauto to activate the request.
Which means an LD_PRELOAD can be applied to any game to activate
the mode as needed.
However gamemode_client.h can be used to manually activate/deactivate
the mode as needed, and also perform error checking.
The libs are miminal loaders to call into an installed libgamemode
which, if the daemon is installed and running, will send through
the equivelant game mode request, and magic will happen.
See the README.md for more details.
Currently licensed under the BSD 3 clause license.