2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00

Add support for reset-on-fork scheduling flag

This patch extends CRIU with support for SCHED_RESET_ON_FORK.
When the SCHED_RESET_ON_FORK flag is set, the following rules
apply for subsequently created children:

- If the calling thread has a scheduling policy of SCHED_FIFO or
SCHED_RR, the policy is reset to SCHED_OTHER in child processes.

- If the calling process has a negative nice value, the nice value
is reset to zero in child processes.

(See 'man 7 sched')

Fixes: #2359

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
Radostin Stoyanov 2024-03-04 15:10:31 +00:00 committed by Andrei Vagin
parent 8f0e200e66
commit 75fed59ef6
2 changed files with 6 additions and 1 deletions

View File

@ -157,6 +157,11 @@ static int dump_sched_info(int pid, ThreadCoreEntry *tc)
tc->has_sched_policy = true;
tc->sched_policy = ret;
/* The reset-on-fork flag might be used in combination
* with SCHED_FIFO or SCHED_RR to reset the scheduling
* policy/priority in child processes.
*/
ret &= ~SCHED_RESET_ON_FORK;
if ((ret == SCHED_RR) || (ret == SCHED_FIFO)) {
ret = syscall(__NR_sched_getparam, pid, &sp);
if (ret < 0) {

View File

@ -3057,7 +3057,7 @@ static int validate_sched_parm(struct rst_sched_param *sp)
if ((sp->nice < -20) || (sp->nice > 19))
return 0;
switch (sp->policy) {
switch (sp->policy & ~SCHED_RESET_ON_FORK) {
case SCHED_RR:
case SCHED_FIFO:
return ((sp->prio > 0) && (sp->prio < 100));