mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 05:18:00 +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:
parent
8f0e200e66
commit
75fed59ef6
@ -157,6 +157,11 @@ static int dump_sched_info(int pid, ThreadCoreEntry *tc)
|
|||||||
tc->has_sched_policy = true;
|
tc->has_sched_policy = true;
|
||||||
tc->sched_policy = ret;
|
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)) {
|
if ((ret == SCHED_RR) || (ret == SCHED_FIFO)) {
|
||||||
ret = syscall(__NR_sched_getparam, pid, &sp);
|
ret = syscall(__NR_sched_getparam, pid, &sp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -3057,7 +3057,7 @@ static int validate_sched_parm(struct rst_sched_param *sp)
|
|||||||
if ((sp->nice < -20) || (sp->nice > 19))
|
if ((sp->nice < -20) || (sp->nice > 19))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (sp->policy) {
|
switch (sp->policy & ~SCHED_RESET_ON_FORK) {
|
||||||
case SCHED_RR:
|
case SCHED_RR:
|
||||||
case SCHED_FIFO:
|
case SCHED_FIFO:
|
||||||
return ((sp->prio > 0) && (sp->prio < 100));
|
return ((sp->prio > 0) && (sp->prio < 100));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user