sched: Preserve the nice level over sched_setscheduler() and sched_setparam() calls
authorPeter Zijlstra <[email protected]>
Wed, 15 Jan 2014 11:30:15 +0000 (12:30 +0100)
committerIngo Molnar <[email protected]>
Thu, 16 Jan 2014 08:27:14 +0000 (09:27 +0100)
Previously sched_setscheduler() and sched_setparam() would not affect
the nice value of a task, restore this behaviour.

Signed-off-by: Peter Zijlstra <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Michael wang <[email protected]>
Cc: Daniel Lezcano <[email protected]>
Fixes: d50dde5a10f3 ("sched: Add new scheduler syscalls to support an extended scheduling parameters ABI")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
kernel/sched/core.c

index 26af3702ebf1769335926efaf2cdd230287eb8ec..c1b3d7e04f0faeeab27d76ff04b64170d9e7a5c0 100644 (file)
@@ -3451,7 +3451,8 @@ int sched_setscheduler(struct task_struct *p, int policy,
 {
        struct sched_attr attr = {
                .sched_policy   = policy,
-               .sched_priority = param->sched_priority
+               .sched_priority = param->sched_priority,
+               .sched_nice     = PRIO_TO_NICE(p->static_prio),
        };
        return __sched_setscheduler(p, &attr, true);
 }
@@ -3481,7 +3482,8 @@ int sched_setscheduler_nocheck(struct task_struct *p, int policy,
 {
        struct sched_attr attr = {
                .sched_policy   = policy,
-               .sched_priority = param->sched_priority
+               .sched_priority = param->sched_priority,
+               .sched_nice     = PRIO_TO_NICE(p->static_prio),
        };
        return __sched_setscheduler(p, &attr, false);
 }