diff --git a/daemon/daemon_config.c b/daemon/daemon_config.c index 53b4434..89d426a 100644 --- a/daemon/daemon_config.c +++ b/daemon/daemon_config.c @@ -70,6 +70,8 @@ struct GameModeConfig { char softrealtime[CONFIG_VALUE_MAX]; long renice; + char ioprio[CONFIG_VALUE_MAX]; + long reaper_frequency; }; @@ -164,6 +166,8 @@ static int inih_handler(void *user, const char *section, const char *name, const valid = get_string_value(value, self->softrealtime); } else if (strcmp(name, "renice") == 0) { valid = get_long_value(name, value, &self->renice); + } else if (strcmp(name, "ioprio") == 0) { + valid = get_string_value(value, self->ioprio); } } else if (strcmp(section, "custom") == 0) { /* Custom subsection */ @@ -215,6 +219,7 @@ static void load_config_files(GameModeConfig *self) pthread_rwlock_wrlock(&self->rwlock); /* Clear our config values */ + memset(self->ioprio, 0, sizeof(self->ioprio)); memset(self->whitelist, 0, sizeof(self->whitelist)); memset(self->blacklist, 0, sizeof(self->blacklist)); memset(self->startscripts, 0, sizeof(self->startscripts)); @@ -424,3 +429,18 @@ void config_get_renice_value(GameModeConfig *self, long *value) { memcpy_locked_config(self, value, &self->renice, sizeof(long)); } + +/* + * Get the ioprio value + */ +void config_get_ioprio_value(GameModeConfig *self, int *value) +{ + char ioprio_value[CONFIG_VALUE_MAX] = { 0 }; + memcpy_locked_config(self, ioprio_value, &self->ioprio, sizeof(self->ioprio)); + if (0 == strncmp(ioprio_value, "off", sizeof(self->ioprio))) + *value = IOPRIO_DONT_SET; + else if (0 == strncmp(ioprio_value, "default", sizeof(self->ioprio))) + *value = IOPRIO_RESET_DEFAULT; + else + *value = atoi(ioprio_value); +} diff --git a/daemon/daemon_config.h b/daemon/daemon_config.h index f6f9975..561db5f 100644 --- a/daemon/daemon_config.h +++ b/daemon/daemon_config.h @@ -39,6 +39,12 @@ POSSIBILITY OF SUCH DAMAGE. #define CONFIG_LIST_MAX 32 #define CONFIG_VALUE_MAX 256 +/* + * Special ioprio values + */ +#define IOPRIO_RESET_DEFAULT -1 +#define IOPRIO_DONT_SET -2 + /* * Opaque config context type */ @@ -113,3 +119,8 @@ void config_get_soft_realtime(GameModeConfig *self, char softrealtime[CONFIG_VAL * Get the renice value */ void config_get_renice_value(GameModeConfig *self, long *value); + +/* + * Get the ioprio value + */ +void config_get_ioprio_value(GameModeConfig *self, int *value); diff --git a/data/gamemoded.8 b/data/gamemoded.8 index cc48ec1..a088638 100644 --- a/data/gamemoded.8 +++ b/data/gamemoded.8 @@ -110,6 +110,12 @@ softrealtime=auto ; the value will be negated and applied as a nice value renice = 4 +; By default, GameMode adjusts the iopriority of clients to BE/0, you can put any value +; between 0 and 7 here (with 0 being highest priority), or one of the special values +; "off" (to disable) or "reset" (to restore Linux default behavior based on CPU priority), +; currently, only the best-effort class is supported thus you cannot set it here +ioprio = 0 + [filter] ; If "whitelist" entry has a value(s) ; gamemode will reject anything not in the whitelist diff --git a/example/gamemode.ini b/example/gamemode.ini index c182073..7df64aa 100644 --- a/example/gamemode.ini +++ b/example/gamemode.ini @@ -15,6 +15,12 @@ softrealtime=auto ; the value will be negated and applied as a nice value renice = 4 +; By default, GameMode adjusts the iopriority of clients to BE/0, you can put any value +; between 0 and 7 here (with 0 being highest priority), or one of the special values +; "off" (to disable) or "reset" (to restore Linux default behavior based on CPU priority), +; currently, only the best-effort class is supported thus you cannot set it here +ioprio = 0 + [filter] ; If "whitelist" entry has a value(s) ; gamemode will reject anything not in the whitelist