From 057c245fa154be37b92c8ac63ac04b20e84dbe0f Mon Sep 17 00:00:00 2001 From: Kai Krakow Date: Thu, 24 May 2018 22:28:18 +0200 Subject: [PATCH] scheduler: Don't renice if already reniced This is a heuristic to not apply a nice level if the user already did that (or the process itself). Signed-off-by: Kai Krakow --- daemon/gamemode.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/daemon/gamemode.c b/daemon/gamemode.c index 1775312..db1c048 100644 --- a/daemon/gamemode.c +++ b/daemon/gamemode.c @@ -179,7 +179,12 @@ static void game_mode_apply_scheduler(pid_t client) { LOG_MSG("Setting scheduling policies...\n"); - if (setpriority(PRIO_PROCESS, (id_t)client, NICE_PRIORITY)) { + /* + * don't adjust priority if it was already adjusted + */ + if (getpriority(PRIO_PROCESS, (id_t)client) != 0) { + LOG_ERROR("Client [%d] already reniced, ignoring.\n", client); + } else if (setpriority(PRIO_PROCESS, (id_t)client, NICE_PRIORITY)) { LOG_ERROR("Renicing client [%d] failed with error %d, ignoring.\n", client, errno); }