mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-26 17:31:45 +02:00
Disable softrealtime (SCHED_ISO) and renice by default
SCHED_ISO is not supported by upstream kernels, so don't try to use this by default since for most users it will result in an error log that trying to set the scheduling policy fails. Without extra system configuration, we will also not have permission to renice processes by default, so out of the box doing this will fail as well. Users that wish to use these features can enable them from the config once they have configured their system appropriately.
This commit is contained in:
@ -67,7 +67,9 @@ void game_mode_apply_renice(const GameModeContext *self, const pid_t client)
|
||||
* read configuration "renice" (1..20)
|
||||
*/
|
||||
long int renice = config_get_renice_value(config);
|
||||
if ((renice < 1) || (renice > 20)) {
|
||||
if (renice == 0) {
|
||||
return;
|
||||
} else if ((renice < 1) || (renice > 20)) {
|
||||
LOG_ONCE(ERROR, "Configured renice value '%ld' is invalid, will not renice.\n", renice);
|
||||
return;
|
||||
} else {
|
||||
@ -105,12 +107,13 @@ void game_mode_apply_scheduling(const GameModeContext *self, const pid_t client)
|
||||
* priority inversion problems with the graphics driver thus running
|
||||
* slower as a result, so enable only with more than 3 cores.
|
||||
*/
|
||||
bool enable_softrealtime = (strcmp(softrealtime, "on") == 0) || (get_nprocs() > 3);
|
||||
bool enable_softrealtime = (strcmp(softrealtime, "on") == 0) ||
|
||||
((strcmp(softrealtime, "auto") == 0) && (get_nprocs() > 3));
|
||||
|
||||
/*
|
||||
* Actually apply the scheduler policy if not explicitly turned off
|
||||
*/
|
||||
if (!(strcmp(softrealtime, "off") == 0) && (enable_softrealtime)) {
|
||||
if (enable_softrealtime) {
|
||||
const struct sched_param p = { .sched_priority = 0 };
|
||||
if (sched_setscheduler(client, SCHED_ISO | SCHED_RESET_ON_FORK, &p)) {
|
||||
const char *hint = "";
|
||||
@ -139,9 +142,5 @@ void game_mode_apply_scheduling(const GameModeContext *self, const pid_t client)
|
||||
strerror(errno),
|
||||
hint);
|
||||
}
|
||||
} else {
|
||||
LOG_ERROR("Skipped setting client [%d] into SCHED_ISO mode: softrealtime setting is '%s'\n",
|
||||
client,
|
||||
softrealtime);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user