Add defaultgov and desiredgov config settings

Allows users to choose which governor settings they want.

	Should provide some future compatibility for other governor settings.
This commit is contained in:
Marc Di Luzio 2018-05-15 17:04:31 +01:00
parent 20828da140
commit 5ebc77a0f1
4 changed files with 32 additions and 2 deletions

View File

@ -93,3 +93,13 @@ void config_get_gamemode_start_scripts(GameModeConfig *self,
*/
void config_get_gamemode_end_scripts(GameModeConfig *self,
char scripts[CONFIG_LIST_MAX][CONFIG_VALUE_MAX]);
/*
* Get the chosen default governor
*/
void config_get_default_governor(GameModeConfig *self, char governor[CONFIG_VALUE_MAX]);
/*
* Get the chosen desired governor
*/
void config_get_desired_governor(GameModeConfig *self, char governor[CONFIG_VALUE_MAX]);

View File

@ -184,8 +184,13 @@ static void game_mode_context_enter(GameModeContext *self)
self->initial_cpu_mode[sizeof(self->initial_cpu_mode) - 1] = '\0';
LOG_MSG("governor was initially set to [%s]\n", initial_state);
/* Choose the desired governor */
char desired[CONFIG_VALUE_MAX] = { 0 };
config_get_desired_governor(self->config, desired);
const char *desiredGov = desired[0] != '\0' ? desired : "performance";
/* set the governor to performance */
if (!set_governors("performance")) {
if (!set_governors(desiredGov)) {
/* if the set fails, clear the initial mode so we don't try and reset it back and fail
* again, presumably */
memset(self->initial_cpu_mode, 0, sizeof(self->initial_cpu_mode));
@ -206,7 +211,12 @@ static void game_mode_context_leave(GameModeContext *self)
/* Reset the governer state back to initial */
if (self->initial_cpu_mode[0] != '\0') {
set_governors(self->initial_cpu_mode);
/* Choose the governor to reset to, using the config to override */
char defaultgov[CONFIG_VALUE_MAX] = { 0 };
config_get_default_governor(self->config, defaultgov);
const char *gov_mode = defaultgov[0] != '\0' ? defaultgov : self->initial_cpu_mode;
set_governors(gov_mode);
memset(self->initial_cpu_mode, 0, sizeof(self->initial_cpu_mode));
}

View File

@ -97,6 +97,11 @@ Behaviour of the config file can be explained by presenting a commented example:
; The reaper thread will check every 10 seconds for exited clients
reaper_freq=10
; The desired governor is used when entering GameMode instead of "performance"
desiredgov=performance
; The default governer is used when leaving GameMode instead of restoring the original value
defaultgov=powersave
[filter]
; If "whitelist" entry has a value(s)
; gamemode will reject anything not in the whitelist

View File

@ -2,6 +2,11 @@
; The reaper thread will check every 10 seconds for exited clients
reaper_freq=10
; The desired governor is used when entering GameMode instead of "performance"
desiredgov=performance
; The default governer is used when leaving GameMode instead of restoring the original value
defaultgov=powersave
[filter]
; If "whitelist" entry has a value(s)
; gamemode will reject anything not in the whitelist