323 Commits

Author SHA1 Message Date
Henrik Holst
91eb57574c fixed double free on exit from non use
if cpu core parking/pinning was disabled by the logic then there would be a double free at exit
2023-12-04 14:18:38 +00:00
Henrik Holst
25a99af4a1 use define instead of value
use a define instead of values for the park_or_pin variable
2023-12-04 14:18:38 +00:00
Henrik Holst
81dc3f95e5 fixed more coding style errors 2023-12-04 14:18:38 +00:00
Henrik Holst
912d4bdc19 fixed more coding style errors 2023-12-04 14:18:38 +00:00
Henrik Holst
2e26331d97 fix to match clang-format 2023-12-04 14:18:38 +00:00
Henrik Holst
51ee251efb Added detection for big.LITTLE
Added detection for big.LITTLE aka cpu:s where not all cores have the same frequency like on Intel Alder Lake and newer. The current logic allows a 5% difference in the max frequency due to some reports that those cpu:s doesn't always give back the exact same value (possible due to boosting capability).
2023-12-04 14:18:38 +00:00
Henrik Holst
4997adef8d build gamemode-cpu
Added build info for gamemade-cpu.c to meson
2023-12-04 14:18:38 +00:00
Henrik Holst
1b10b679cd added the cpu core parking/pinning definitions
added the cpu core parking/pinning definitions to gamemode.h
2023-12-04 14:18:38 +00:00
Henrik Holst
495a659895 Added gamemode-cpu.c
Added gamemode-cpu.c which contains the functions for cpu core parking and pinning
2023-12-04 14:18:38 +00:00
Henrik Holst
2dbd565340 call the cpu core parking/pinning from context
call the cpu core parking/pinning from gamemode-context.c
2023-12-04 14:18:38 +00:00
Henrik Holst
01024927d2 added cpu core parking/pinning settings
added cpu core parking/pinning settings to gamemode-config.h
2023-12-04 14:18:38 +00:00
Henrik Holst
32a0b5b636 added the cpu core parking/pinning settings
added the cpu core parking/pinning settings to gamemode-config.c
2023-12-04 14:18:38 +00:00
Alfred Persson Forsberg
f50e7fffe7 Fix build on musl libc
This simple patch includes signal.h in daemon/gamemode-context.c to fix building gamemode on musl
libc.

This has been tested Gentoo musl and Alpine (also Gentoo glibc to
ensure no multiple defined symbols/other errors for glibc).

> ../daemon/gamemode-context.c: In function 'game_mode_context_auto_expire':
> ../daemon/gamemode-context.c:421:29: error: implicit declaration of function 'kill' [-Werror=implicit-function-declaration]
>   421 |                         if (kill(client->pid, 0) != 0) {
>       |                             ^~~~
> ../daemon/gamemode-context.c:421:29: warning: nested extern declaration of 'kill' [-Wnested-externs]

Signed-off-by: Alfred Persson Forsberg <cat@catcream.org>
2022-07-15 14:14:16 +01:00
Sam Gleske
23493e5cc3 Fix GitHub Actions Format Check
This change fixes the format check in GitHub actions ran by `clang-format`.

Dockerfile

```dockerfile
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
```

Environment setup

```bash
sudo su -g docker $USER
docker build -t ci .
```

clang-format fix

```bash
docker run -e CI=true --rm -v "$PWD:$PWD" -w "$PWD" --init ci ./scripts/format-check.sh
```
2022-02-21 09:51:59 +00:00
Stephan Lachnit
6c60565f33 Format files according to clang-format
Signed-off-by: Stephan Lachnit <stephanlachnit@debian.org>
2022-02-03 16:40:02 +00:00
Kira Bruneau
5e366bd55d Fix loading shipped config when using a prefix other than /usr
Also remove recommendation to modify `/usr/share/gamemode/gamemode.ini`.
`/usr/share` is intended to contain read-only data files.

See https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s11.html.
2022-02-03 16:02:18 +00:00
Kira Bruneau
126e67fb6b Run executables from PATH instead of /usr/bin
Not all distributions install non-system binaries into /usr/bin. For
example, NixOS installs packages to /nix/store using a unique hash
generated from the inputs used to build it:

/nix/store/jld7jh3ilvbg91zvn1bdyawfc55b9jk8-polkit-0.118-bin/bin/pkexec
2022-02-03 15:42:22 +00:00
Ahsan Fayaz
510a0a6ae2 Fix issues found by Coverity, closes #206. 2020-07-17 18:55:00 +01:00
Stephan Lachnit
d8337aeb05 various variable naming improvements
This makes it more clear that libgamemode and libgamemodeauto are indeed libraries. Also, the misleading name `libgamemode_dep` has been renamed to `gamemode_dep`, which now also includes the dependency on libdl. The misleading `libgamemode_includes` variable name has also been changed.

Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
2020-06-23 09:18:14 +01:00
Stephan Lachnit
ce6485ef97 combine no-daemon, elogind and systemd option
Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
2020-05-19 16:27:51 +01:00
Stephan Lachnit
953792b4a5 Add option to use elogind
Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
2020-05-19 16:27:51 +01:00
Stephan Lachnit
c36019a9aa travis: run gamemoded -v as meson test
Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
2020-05-12 19:25:57 +01:00
qarmin
94444cb76f Check index before using 2020-05-06 11:05:02 +01:00
Ari Breitkreuz
c8492ca28f Fix typo in README and help message 2020-05-06 11:01:37 +01:00
Stephan Lachnit
f0943ff431 prefer system installation of inih
Closes #195.

Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
2020-02-26 18:24:50 +00:00
Jason Ekstrand
688373a260 Add an option for using a different governor for integrated GPUs
This commit adds two new configuration options: igpu_desiredgov and
igpu_power_threshold which allow for a different CPU governor when the
Intel integrated GPU is under load.  This currently only applies to
Intel integrated GPUs and not AMD APUs because it uses the Intel RAPL
infrastructure for getting power information.  If on a platform that
without an Intel integrated GPU or where the kernel does not support
RAPL, the new options will be ignored and it will fall back to the old
behavior.

One of the core principals of gamemoded to date has been that, when
playing a game, we want to use the "performance" CPU governor to
increase CPU performance and prevent CPU-limiting.  However, when the
integrated GPU is under load, this can be counter-productive because the
CPU and GPU share a thermal and power budget.  By throwing the CPU
governor to "performance" game mode currently makes the CPU frequency
management far too aggressive and it burns more power than needed.  With
a discrete GPU, this is fine because the worst that happens is a bit
more fan noise.  With an integrated GPU, however, the additional power
being burned by the CPU is power not available to the GPU and this can
cause the GPU to clock down and lead to significantly worse performance.

By using the "powersave" governor instead of the "performance" governor
while the integrated GPU is under load, we can save power on the CPU
side which lets the GPU clock up higher.  On my Razer Blade Stealth 13
with an i7-1065G7, this improves the performance of "Shadow of the Tomb
Raider" by around 25-30% according to its internal benchmark mode.
2020-01-09 10:49:19 -06:00
Jason Ekstrand
2023a2a1ef Move the get/set governor state machine to a helper 2020-01-09 10:41:10 -06:00
Alex Smith
57efe440c3 clang-format fix 2019-10-22 12:41:37 +01:00
Alex Smith
b2b09fbb83 Run "sleep 5" instead of "sh" for the gamemoderun test
Don't really want to try to run an interactive shell here.
2019-10-22 12:36:59 +01:00
Alex Smith
d25379e001 Increase a test timeout to avoid spurious failures 2019-10-22 12:31:53 +01:00
Christian Kellner
a6552044cd daemon: add new pidfd based D-Bus API
Provide a new set of APIs with identical semantics as the existing
ByPID family of calls but instead of working with process ids, they
take pidfds, file descriptors representing processes, instead. The
fds can be translated back to pids (in the correct namespace) and
also be monitored via select/poll/epoll.
The current implementation translates them directly back to pids,
but in the future the monitoring code that watches processes (if
they are still alive) could be converted be event driven via pidfds.
2019-10-18 13:19:30 +02:00
Christian Kellner
35fb7f5baf meson: include dir in daemon_common dependency
Specify the include directory in the link_daemon_common dependency
and thus everything that includes that as a dependency will get
the proper include directory automatically.
2019-10-18 13:19:30 +02:00
Christian Kellner
b7dc1dc10c daemon: small fix for code comments
Comments were not reflecting the what they were describing.
2019-10-18 13:19:30 +02:00
Kai Krakow
24f054659c gamemode-context: Avoid GameModeClient *cl being NULL
There's no need in defining it at the top of the function. During
rebase, I had one `if` accessing `cl->executable` too early but we were
only storing the path in `executable` at that point.

This change avoids accessing `cl` while it might be NULL.

Signed-off-by: Kai Krakow <kai@kaishome.de>
2019-10-18 09:42:06 +01:00
Christian Kellner
5c1b2d0c74 daemon: export GameModeClient::Requester on D-Bus
Expose the requeter process identifier as 'Requester' property
of the com.feralinteractive.GameMode.Game interface.
2019-07-16 19:00:35 +01:00
Christian Kellner
cfe0fb4f17 daemon: add requester to GameModeClient
Record the requester process id in the GameModeClient struct and
add a getter for it.
2019-07-16 19:00:33 +01:00
Christian Kellner
288b3a005e daemon: export GameModeClient::Timestamp on D-Bus
Expose the timestamp that a client was created as 'Timestamp'
property of the com.feralinteractive.GameMode.Game interface.
2019-07-16 18:59:44 +01:00
Christian Kellner
52367772c8 daemon: add creation timestamp to GameModeClient
Record the time a client was created, i.e. registered, in the
GameModeClient struct and add a getter for it.

(Alex Smith: Fixed up function documentation comments)
2019-07-16 18:59:01 +01:00
Christian Kellner
9075829526 daemon: fix typo in Game.Executable dbus property
Fix spelling for the 'Executable' property in the interface
com.feralinteractive.GameMode.Game.
2019-07-12 17:01:01 +02:00
Christian Kellner
02ad53584d daemon: properly report error in error case
Currently, in method_list_games (`ListGames` on the bus), when
sd_bus_message_append fails, we break the loop but then we were
not reporting the error (contained in r) back to call.
2019-07-12 11:35:55 +02:00
Alex Smith
3881b8b2c8 Fix clang-format error 2019-07-07 11:42:31 +01:00
Alex Smith
60c68feea6 Use the GAME_PATH_PREFIX definition everywhere 2019-07-06 18:12:48 +01:00
Christian Kellner
f9827edfb6 daemon: emit client count change automatically
Every time a game is (un)-registered and we emit the corresponding
signal, also emit the properties change signal for ClientCount.
2019-07-04 16:04:35 +02:00
Christian Kellner
d2bab2962d daemon: export game objects on the bus
For each registered game, export an object on the bus under the
path "/com/feralinteractive/GameMode/Games/<pid>" with an dbus
interface of ""com.feralinteractive.GameMode.Game". The interface
currently provides to properties, ProcessId and Executable.
Additionally add the ListGames method and the GameRegistered,
GameUnregistered signals to the com.feralinteractive.GameMode
interface.
2019-07-04 16:04:35 +02:00
Christian Kellner
5949a988ea daemon: add game_mode_context_lookup_client method
Like game_mode_context_has_client, but will add a reference to
the client, if a match was found.
2019-07-02 17:47:05 +02:00
Christian Kellner
208f37b7d1 daemon: method to list all registered clients
Return an array of pid_t elements containing the process ids of
all registered clients. Memory ownership is transferred to the
client and must be freed.
2019-07-02 17:47:05 +02:00
Christian Kellner
455ea0c72e daemon: getters for properties of GameModeClient
Add getters for all two properties of GameModeCLient: the process
id and the executable path.
2019-07-02 17:46:52 +02:00
Christian Kellner
d99af40795 daemon: add game_mode_client_ref
Now that GameModeClient is reference counted, the counterpart to
game_mode_client_unref is also needed.
2019-07-02 17:46:31 +02:00
Christian Kellner
7e10cc3a0b daemon: make game_mode_client_unref public
So it can be used outside ouf gamemode-context.c.
2019-07-02 17:46:24 +02:00
Christian Kellner
1a863f32a1 daemon: add ref-counting to GameModeClient
This is so it can out-live its membership in the client list, e.g.
when it is passed outside of gamemode-context.c and the reaper
comes along and reaps a client in the background but we still are
using the struct outside.
2019-07-02 17:46:17 +02:00