34 Commits

Author SHA1 Message Date
Marc Di Luzio
9ade4481c3 Change AMD overclocking to simply be setting the power_dpm_force_performance_level file for now
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
2019-03-10 10:32:08 +00:00
Marc Di Luzio
c215626ccd Add "script_timeout" config value to control if a user wants to extend the script timeout before kill value 2019-03-07 17:51:57 +00:00
Alex Smith
3c28e84700 Merge pull request #105 from mdiluz/auto-detect-vendor
Detect the GPU vendor automatically
2019-03-04 08:43:58 +00:00
Marc Di Luzio
1430c0b831 Implement supervisor features using new config variables
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)
2019-02-21 17:34:20 +00:00
Marc Di Luzio
d60ac23daa Add a helper function for getting if a config list contains a string 2019-02-21 17:34:20 +00:00
Marc Di Luzio
de390be93d Add unused to now unused hex function 2019-02-21 17:33:58 +00:00
Marc Di Luzio
0847d3b452 Remove the vendor config value in prep for it to be auto-detected 2019-02-21 17:26:14 +00:00
Marc Di Luzio
938794a69c Protect the [gpu] config section
Don't allow these settings to be set from $HOME or $CWD, as discussed in PR #101
2019-02-20 17:48:23 +00:00
Marc Di Luzio
c0ef843290 Refactor the config values into a sub-struct
This makes it much simpler to default all but some to zero
2019-02-19 17:40:50 +00:00
Marc Di Luzio
903fda6dcb Use a macro to declare some the repeated "get long config value" pattern 2019-02-19 17:40:50 +00:00
Marc Di Luzio
d5ffdcffdb Fix reaper_frequency naming 2019-02-19 17:40:50 +00:00
Marc Di Luzio
b7dff4265c Refactor config functions that can return their full value to do so
This pattern got a little out of hand, and was only meant for variable length values like strings
2019-02-19 17:40:50 +00:00
Marc Di Luzio
0170a72634 Fix formatting of renice value comment 2019-02-12 08:55:23 +00:00
Marc Di Luzio
ff1a838ab7 Apply format corrections 2019-02-12 08:55:23 +00:00
Marc Di Luzio
142b2fb32d Also add nv_perf_level for nvidia (needed as a parameter to nvidia-xsettings) 2019-02-12 08:55:23 +00:00
Marc Di Luzio
6b268e8349 Convert "apply_gpu_optimisations" to a string with a special key 2019-02-12 08:55:23 +00:00
Marc Di Luzio
ad2c218ab3 Allow setting the device value with a hex string
Also stops erroring on 0 value longs
2019-02-12 08:55:23 +00:00
Marc Di Luzio
fe9b5c8744 Error with invalid device or vendor values 2019-02-12 08:55:23 +00:00
Marc Di Luzio
cee2351c55 Add config for vendor and device 2019-02-12 08:55:23 +00:00
Marc Di Luzio
b1bf33d386 Add config parameters for GPU clocking 2019-02-12 08:55:23 +00:00
Marc Di Luzio
ba49055519 Set up inhibit_screensaver config option to disable the feature 2019-02-03 15:45:11 +00:00
Marc Di Luzio
b54a406b97 Don't log an error about a default initial renice value 2019-01-31 19:06:02 +00:00
Alex Smith
53f3d4b346 Merge pull request #81 from kakra/io-priorities
Adjust IO priorities of clients
2018-10-05 14:21:46 +01:00
Kai Krakow
ebf177bebe daemon-config: Add ioprio configuration option
Signed-off-by: Kai Krakow <kai@kaishome.de>
2018-10-01 19:34:46 +02:00
Kai Krakow
61a9ee9033 Fix access to uninitialized values (valgrind)
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>
2018-09-30 00:01:38 +02:00
Kai Krakow
57c6bbb444 config: Allow renice configuration
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>
2018-06-10 09:33:02 +02:00
Kai Krakow
9dfd718807 config: Introduce new setting "softrealtime"
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>
2018-05-24 22:41:04 +02:00
Marc Di Luzio
20828da140 Refactor getting config values to stop duplicating the rwlock 2018-05-15 17:04:20 +01:00
Marc Di Luzio
808f5c9159 Provide a cascaded merge-overwrite config approach for #6
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
2018-05-01 15:42:54 +01:00
Marc Di Luzio
db8a70b7ba Add support for user defined local script plugins
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.
2018-04-24 16:59:17 +01:00
Marc Di Luzio
c45b9f90a4 Refactor the config gathering code to be reusable
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
2018-04-24 15:21:59 +01:00
Marc Di Luzio
51e1e7203f Add "reaper_freq" config setting in the "general" section
This simply allows control over the reaper thread frequency.

	Defaults to 5 as before.
2018-04-24 14:37:39 +01:00
Ikey Doherty
69db9c2a61 Conformance: Update copyright range to include 2018
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-04-10 13:23:38 +01:00
Marc Di Luzio
759cbc3c40 Add config file parsing
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)
2018-03-23 16:59:15 +00:00