Add tests to check this feature
Apply config validation in config for simplicity
Note: if anything messes with the niceness (ie. it starts non-zero, or it's not the expected value during setup, we'll bail out)
SCHED_ISO is not supported by upstream kernels, so don't try to use this by
default since for most users it will result in an error log that trying to
set the scheduling policy fails.
Without extra system configuration, we will also not have permission to renice
processes by default, so out of the box doing this will fail as well.
Users that wish to use these features can enable them from the config once
they have configured their system appropriately.
This also fixes the instances in testing where we don't have the nv overclock in use, but we do have the mode set
Solves issues explaining the what the perf_level actually meant, and future proofs for any PR that wants to set individual perf levels
This covers the MVP for now, and simply allows pinning the power level to "high"
Full overclocking set up is somewhat more complicated, and it'll be better to implement that at the same time as the same for Nvidia, where we're currently only really setting the top end power level
This allows direct control over who can make requests on behalf of other processes
require_supervisor can also be used to allow a supervisor to take direct control of gamemode on the system (perhaps a GUI, or game launcher)
Fix what was reported by valgrind:
```
==8458==
==8458== HEAP SUMMARY:
==8458== in use at exit: 11,677 bytes in 27 blocks
==8458== total heap usage: 768 allocs, 741 frees, 397,008 bytes
allocated
==8458==
==8458== Searching for pointers to 27 not-freed blocks
==8458== Checked 206,624 bytes
==8458==
==8458== LEAK SUMMARY:
==8458== definitely lost: 0 bytes in 0 blocks
==8458== indirectly lost: 0 bytes in 0 blocks
==8458== possibly lost: 0 bytes in 0 blocks
==8458== still reachable: 11,677 bytes in 27 blocks
==8458== suppressed: 0 bytes in 0 blocks
==8458== Reachable blocks (those to which a pointer was found) are not
shown.
==8458== To see them, rerun with: --leak-check=full
--show-leak-kinds=all
==8458==
==8458== Use --track-origins=yes to see where uninitialised values come
from
==8458== ERROR SUMMARY: 200 errors from 10 contexts (suppressed: 0 from
0)
==8458==
==8458== 20 errors in context 1 of 10:
==8458== Conditional jump or move depends on uninitialised value(s)
==8458== at 0x10BD18: game_mode_apply_scheduler (gamemode.c:237)
==8458== by 0x10C7D7: game_mode_context_register (gamemode.c:445)
==8458== by 0x10D4E6: method_register_game (dbus_messaging.c:79)
==8458== by 0x4CB795B: method_callbacks_run (bus-objects.c:404)
==8458== by 0x4CB795B: object_find_and_run (bus-objects.c:1262)
==8458== by 0x4CB8D38: bus_process_object (bus-objects.c:1378)
==8458== by 0x4CC9251: process_message (sd-bus.c:2663)
==8458== by 0x4CC9251: process_running (sd-bus.c:2705)
==8458== by 0x4CC9251: bus_process_internal (sd-bus.c:2924)
==8458== by 0x10D8B9: game_mode_context_loop (dbus_messaging.c:173)
==8458== by 0x10B7C4: main (main.c:186)
==8458==
==8458==
==8458== 20 errors in context 2 of 10:
==8458== Conditional jump or move depends on uninitialised value(s)
==8458== at 0x4A0C4DC: strcmp (vg_replace_strmem.c:846)
==8458== by 0x10BD15: game_mode_apply_scheduler (gamemode.c:237)
==8458== by 0x10C7D7: game_mode_context_register (gamemode.c:445)
==8458== by 0x10D4E6: method_register_game (dbus_messaging.c:79)
==8458== by 0x4CB795B: method_callbacks_run (bus-objects.c:404)
==8458== by 0x4CB795B: object_find_and_run (bus-objects.c:1262)
==8458== by 0x4CB8D38: bus_process_object (bus-objects.c:1378)
==8458== by 0x4CC9251: process_message (sd-bus.c:2663)
==8458== by 0x4CC9251: process_running (sd-bus.c:2705)
==8458== by 0x4CC9251: bus_process_internal (sd-bus.c:2924)
==8458== by 0x10D8B9: game_mode_context_loop (dbus_messaging.c:173)
==8458== by 0x10B7C4: main (main.c:186)
==8458==
==8458==
==8458== 20 errors in context 3 of 10:
==8458== Conditional jump or move depends on uninitialised value(s)
==8458== at 0x10BCDB: game_mode_apply_scheduler (gamemode.c:232)
==8458== by 0x10C7D7: game_mode_context_register (gamemode.c:445)
==8458== by 0x10D4E6: method_register_game (dbus_messaging.c:79)
==8458== by 0x4CB795B: method_callbacks_run (bus-objects.c:404)
==8458== by 0x4CB795B: object_find_and_run (bus-objects.c:1262)
==8458== by 0x4CB8D38: bus_process_object (bus-objects.c:1378)
==8458== by 0x4CC9251: process_message (sd-bus.c:2663)
==8458== by 0x4CC9251: process_running (sd-bus.c:2705)
==8458== by 0x4CC9251: bus_process_internal (sd-bus.c:2924)
==8458== by 0x10D8B9: game_mode_context_loop (dbus_messaging.c:173)
==8458== by 0x10B7C4: main (main.c:186)
==8458==
==8458==
==8458== 20 errors in context 4 of 10:
==8458== Conditional jump or move depends on uninitialised value(s)
==8458== at 0x4A0C4DC: strcmp (vg_replace_strmem.c:846)
==8458== by 0x10BCD8: game_mode_apply_scheduler (gamemode.c:232)
==8458== by 0x10C7D7: game_mode_context_register (gamemode.c:445)
==8458== by 0x10D4E6: method_register_game (dbus_messaging.c:79)
==8458== by 0x4CB795B: method_callbacks_run (bus-objects.c:404)
==8458== by 0x4CB795B: object_find_and_run (bus-objects.c:1262)
==8458== by 0x4CB8D38: bus_process_object (bus-objects.c:1378)
==8458== by 0x4CC9251: process_message (sd-bus.c:2663)
==8458== by 0x4CC9251: process_running (sd-bus.c:2705)
==8458== by 0x4CC9251: bus_process_internal (sd-bus.c:2924)
==8458== by 0x10D8B9: game_mode_context_loop (dbus_messaging.c:173)
==8458== by 0x10B7C4: main (main.c:186)
==8458==
==8458==
==8458== 20 errors in context 5 of 10:
==8458== Conditional jump or move depends on uninitialised value(s)
==8458== at 0x53AB44C: vfprintf (vfprintf.c:1642)
==8458== by 0x53B2C5D: printf (printf.c:33)
==8458== by 0x10BBA2: game_mode_apply_scheduler (gamemode.c:201)
==8458== by 0x10C7D7: game_mode_context_register (gamemode.c:445)
==8458== by 0x10D4E6: method_register_game (dbus_messaging.c:79)
==8458== by 0x4CB795B: method_callbacks_run (bus-objects.c:404)
==8458== by 0x4CB795B: object_find_and_run (bus-objects.c:1262)
==8458== by 0x4CB8D38: bus_process_object (bus-objects.c:1378)
==8458== by 0x4CC9251: process_message (sd-bus.c:2663)
==8458== by 0x4CC9251: process_running (sd-bus.c:2705)
==8458== by 0x4CC9251: bus_process_internal (sd-bus.c:2924)
==8458== by 0x10D8B9: game_mode_context_loop (dbus_messaging.c:173)
==8458== by 0x10B7C4: main (main.c:186)
==8458==
==8458==
==8458== 20 errors in context 6 of 10:
==8458== Conditional jump or move depends on uninitialised value(s)
==8458== at 0x53AA9DA: vfprintf (vfprintf.c:1642)
==8458== by 0x53B2C5D: printf (printf.c:33)
==8458== by 0x10BBA2: game_mode_apply_scheduler (gamemode.c:201)
==8458== by 0x10C7D7: game_mode_context_register (gamemode.c:445)
==8458== by 0x10D4E6: method_register_game (dbus_messaging.c:79)
==8458== by 0x4CB795B: method_callbacks_run (bus-objects.c:404)
==8458== by 0x4CB795B: object_find_and_run (bus-objects.c:1262)
==8458== by 0x4CB8D38: bus_process_object (bus-objects.c:1378)
==8458== by 0x4CC9251: process_message (sd-bus.c:2663)
==8458== by 0x4CC9251: process_running (sd-bus.c:2705)
==8458== by 0x4CC9251: bus_process_internal (sd-bus.c:2924)
==8458== by 0x10D8B9: game_mode_context_loop (dbus_messaging.c:173)
==8458== by 0x10B7C4: main (main.c:186)
==8458==
==8458==
==8458== 20 errors in context 7 of 10:
==8458== Conditional jump or move depends on uninitialised value(s)
==8458== at 0x53A6FF5: _itoa_word (_itoa.c:179)
==8458== by 0x53AA922: vfprintf (vfprintf.c:1642)
==8458== by 0x53B2C5D: printf (printf.c:33)
==8458== by 0x10BBA2: game_mode_apply_scheduler (gamemode.c:201)
==8458== by 0x10C7D7: game_mode_context_register (gamemode.c:445)
==8458== by 0x10D4E6: method_register_game (dbus_messaging.c:79)
==8458== by 0x4CB795B: method_callbacks_run (bus-objects.c:404)
==8458== by 0x4CB795B: object_find_and_run (bus-objects.c:1262)
==8458== by 0x4CB8D38: bus_process_object (bus-objects.c:1378)
==8458== by 0x4CC9251: process_message (sd-bus.c:2663)
==8458== by 0x4CC9251: process_running (sd-bus.c:2705)
==8458== by 0x4CC9251: bus_process_internal (sd-bus.c:2924)
==8458== by 0x10D8B9: game_mode_context_loop (dbus_messaging.c:173)
==8458== by 0x10B7C4: main (main.c:186)
==8458==
==8458==
==8458== 20 errors in context 8 of 10:
==8458== Use of uninitialised value of size 8
==8458== at 0x53A6FE8: _itoa_word (_itoa.c:179)
==8458== by 0x53AA922: vfprintf (vfprintf.c:1642)
==8458== by 0x53B2C5D: printf (printf.c:33)
==8458== by 0x10BBA2: game_mode_apply_scheduler (gamemode.c:201)
==8458== by 0x10C7D7: game_mode_context_register (gamemode.c:445)
==8458== by 0x10D4E6: method_register_game (dbus_messaging.c:79)
==8458== by 0x4CB795B: method_callbacks_run (bus-objects.c:404)
==8458== by 0x4CB795B: object_find_and_run (bus-objects.c:1262)
==8458== by 0x4CB8D38: bus_process_object (bus-objects.c:1378)
==8458== by 0x4CC9251: process_message (sd-bus.c:2663)
==8458== by 0x4CC9251: process_running (sd-bus.c:2705)
==8458== by 0x4CC9251: bus_process_internal (sd-bus.c:2924)
==8458== by 0x10D8B9: game_mode_context_loop (dbus_messaging.c:173)
==8458== by 0x10B7C4: main (main.c:186)
==8458==
==8458==
==8458== 20 errors in context 9 of 10:
==8458== Conditional jump or move depends on uninitialised value(s)
==8458== at 0x53AB20A: vfprintf (vfprintf.c:1642)
==8458== by 0x53B2C5D: printf (printf.c:33)
==8458== by 0x10BBA2: game_mode_apply_scheduler (gamemode.c:201)
==8458== by 0x10C7D7: game_mode_context_register (gamemode.c:445)
==8458== by 0x10D4E6: method_register_game (dbus_messaging.c:79)
==8458== by 0x4CB795B: method_callbacks_run (bus-objects.c:404)
==8458== by 0x4CB795B: object_find_and_run (bus-objects.c:1262)
==8458== by 0x4CB8D38: bus_process_object (bus-objects.c:1378)
==8458== by 0x4CC9251: process_message (sd-bus.c:2663)
==8458== by 0x4CC9251: process_running (sd-bus.c:2705)
==8458== by 0x4CC9251: bus_process_internal (sd-bus.c:2924)
==8458== by 0x10D8B9: game_mode_context_loop (dbus_messaging.c:173)
==8458== by 0x10B7C4: main (main.c:186)
==8458==
==8458==
==8458== 20 errors in context 10 of 10:
==8458== Conditional jump or move depends on uninitialised value(s)
==8458== at 0x10BB44: game_mode_apply_scheduler (gamemode.c:200)
==8458== by 0x10C7D7: game_mode_context_register (gamemode.c:445)
==8458== by 0x10D4E6: method_register_game (dbus_messaging.c:79)
==8458== by 0x4CB795B: method_callbacks_run (bus-objects.c:404)
==8458== by 0x4CB795B: object_find_and_run (bus-objects.c:1262)
==8458== by 0x4CB8D38: bus_process_object (bus-objects.c:1378)
==8458== by 0x4CC9251: process_message (sd-bus.c:2663)
==8458== by 0x4CC9251: process_running (sd-bus.c:2705)
==8458== by 0x4CC9251: bus_process_internal (sd-bus.c:2924)
==8458== by 0x10D8B9: game_mode_context_loop (dbus_messaging.c:173)
==8458== by 0x10B7C4: main (main.c:186)
==8458==
==8458== ERROR SUMMARY: 200 errors from 10 contexts (suppressed: 0 from
0)
```
Signed-off-by: Kai Krakow <kai@kaishome.de>
This commit adds configuration support for the renice value and amends
documentation and examples. This commit by itself does nothing, the
following commit is needed to actually apply the new settings.
Signed-off-by: Kai Krakow <kai@kaishome.de>
This adds support for a new configuration option "softrealtime" to be
read from the general section. This commit alone does nothing, the
following commit adds actually making use of the value.
Signed-off-by: Kai Krakow <kai@kaishome.de>
gamemoded will now load and merge settings from the following locations - arrays will merge and single settings will overwrite.
1. /usr/share/gamemode/
2. /etc/
3. $XDG_CONFIG_HOME or $HOME/.config/
4. $PWD
A much requested feature, this allows for providing custom scripts in the config file. An example in the man page is below and would trigger both a system notification, and allow control over a background crypto mining script automatically in gamemode.
[custom]
; Custom scripts (executed using the shell) when gamemode starts and ends
start=notify-send "GameMode started"
/home/me/bin/stop_ethmining.sh
end=notify-send "GameMode ended"
/home/me/bin/start_ethmining.sh
Scripts are run with system() and do not have any special privilages, as with the rest of the daemon, custom scripts that require root will need their own permissions set up externally.
This commit also renames two defines as they needed to be moved to the public interface.
This moves adding to lists and getting long values into resuable functions.
It also fixes a couple other issues in the process:
1. Logging now goes to the error channel and is labelled
2. >Max length lines are properly handled, although this should never happen since inih has a 200 limit
Checks for a gamemode.ini in /usr/share/gamemode/ (or in the cwd for debugging)
Currently allows for blacklisting and whitelisting clients based on rudimentary needle-haystack executable name checks
See the example/gamemode.ini file for expected syntax
Using the BSD licensed inih library (with additional meson.build file)