From 57c6bbb4443a50c6ed0a94218bf593a8c9a2af2b Mon Sep 17 00:00:00 2001 From: Kai Krakow Date: Sun, 10 Jun 2018 09:33:02 +0200 Subject: [PATCH] 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 --- README.md | 2 +- daemon/daemon_config.c | 11 +++++++++++ daemon/daemon_config.h | 5 +++++ data/gamemoded.1 | 4 ++++ example/gamemode.ini | 4 ++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d19b702..be97adb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ GameMode was designed primarily as a stop-gap solution to problems with the Inte GameMode can leverage support for soft real time mode if the running kernel supports `SCHED_ISO`. This adjusts the scheduling of the game to real time without sacrificing system stability by starving other processes. -GameMode adjusts the nice priority of games to -4 to give it a slight IO and CPU priority over other background processes. This only works if your user is permitted to adjust priorities within the limits configured by PAM. +GameMode adjusts the nice priority of games to -4 by default to give it a slight IO and CPU priority over other background processes. This only works if your user is permitted to adjust priorities within the limits configured by PAM. See `/etc/security/limits.conf`. Issues with GameMode should be reported here in the issues section, and not reported to Feral directly. diff --git a/daemon/daemon_config.c b/daemon/daemon_config.c index 1afa2b7..53b4434 100644 --- a/daemon/daemon_config.c +++ b/daemon/daemon_config.c @@ -68,6 +68,7 @@ struct GameModeConfig { char desiredgov[CONFIG_VALUE_MAX]; char softrealtime[CONFIG_VALUE_MAX]; + long renice; long reaper_frequency; }; @@ -161,6 +162,8 @@ static int inih_handler(void *user, const char *section, const char *name, const valid = get_string_value(value, self->desiredgov); } else if (strcmp(name, "softrealtime") == 0) { valid = get_string_value(value, self->softrealtime); + } else if (strcmp(name, "renice") == 0) { + valid = get_long_value(name, value, &self->renice); } } else if (strcmp(section, "custom") == 0) { /* Custom subsection */ @@ -413,3 +416,11 @@ void config_get_soft_realtime(GameModeConfig *self, char softrealtime[CONFIG_VAL { memcpy_locked_config(self, softrealtime, self->softrealtime, sizeof(self->softrealtime)); } + +/* + * Get the renice value + */ +void config_get_renice_value(GameModeConfig *self, long *value) +{ + memcpy_locked_config(self, value, &self->renice, sizeof(long)); +} diff --git a/daemon/daemon_config.h b/daemon/daemon_config.h index 59e90c9..f6f9975 100644 --- a/daemon/daemon_config.h +++ b/daemon/daemon_config.h @@ -108,3 +108,8 @@ void config_get_desired_governor(GameModeConfig *self, char governor[CONFIG_VALU * Get the chosen soft realtime behavior */ void config_get_soft_realtime(GameModeConfig *self, char softrealtime[CONFIG_VALUE_MAX]); + +/* + * Get the renice value + */ +void config_get_renice_value(GameModeConfig *self, long *value); diff --git a/data/gamemoded.1 b/data/gamemoded.1 index 518a24e..6bc91e3 100644 --- a/data/gamemoded.1 +++ b/data/gamemoded.1 @@ -106,6 +106,10 @@ defaultgov=powersave ; force enable or disable with "on" or "off" softrealtime=auto +; By default, GameMode renices the client to -4, you can put any value between 1 and 20 here, +; the value will be negated and applied as a nice value +renice = 4 + [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 e4a95e1..36697f6 100644 --- a/example/gamemode.ini +++ b/example/gamemode.ini @@ -11,6 +11,10 @@ defaultgov=powersave ; force enable or disable with "on" or "off" softrealtime=auto +; By default, GameMode renices the client to -4, you can put any value between 1 and 20 here, +; the value will be negated and applied as a nice value +renice = 4 + [filter] ; If "whitelist" entry has a value(s) ; gamemode will reject anything not in the whitelist