mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-04 22:57:21 +02:00
properly support config reloading
This commit is contained in:
parent
9cb119be62
commit
88a15aba86
@ -186,6 +186,13 @@ static int walk_string(char *cpulist, char *config_cpulist, GameModeCPUInfo *inf
|
||||
return 1;
|
||||
}
|
||||
|
||||
void game_mode_reconfig_cpu(GameModeConfig *config, GameModeCPUInfo **info)
|
||||
{
|
||||
game_mode_unpark_cpu(*info);
|
||||
game_mode_free_cpu(info);
|
||||
game_mode_initialise_cpu(config, info);
|
||||
}
|
||||
|
||||
int game_mode_initialise_cpu(GameModeConfig *config, GameModeCPUInfo **info)
|
||||
{
|
||||
/* Verify input, this is programmer error */
|
||||
@ -281,6 +288,12 @@ int game_mode_initialise_cpu(GameModeConfig *config, GameModeCPUInfo **info)
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
if (CPU_COUNT_S(CPU_ALLOC_SIZE(new_info->num_cpu), new_info->to_keep) == 0) {
|
||||
game_mode_free_cpu(&new_info);
|
||||
LOG_MSG("I can find no reason to perform core pinning on this system!\n");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
if (CPU_COUNT_S(CPU_ALLOC_SIZE(new_info->num_cpu), new_info->to_keep) < 4) {
|
||||
game_mode_free_cpu(&new_info);
|
||||
LOG_MSG(
|
||||
@ -431,6 +444,17 @@ void game_mode_apply_core_pinning(const GameModeCPUInfo *info, const pid_t clien
|
||||
LOG_ERROR("Failed to pin process: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
void game_mode_undo_core_pinning(const GameModeCPUInfo *info, const pid_t client)
|
||||
{
|
||||
if (!info || info->park_or_pin == IS_CPU_PARK)
|
||||
return;
|
||||
|
||||
LOG_MSG("Pinning process back to all online cores...\n");
|
||||
|
||||
if (sched_setaffinity(client, CPU_ALLOC_SIZE(info->num_cpu), info->online) != 0)
|
||||
LOG_ERROR("Failed to pin process: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
void game_mode_free_cpu(GameModeCPUInfo **info)
|
||||
{
|
||||
if ((*info)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user