On Wed, Jan 15, 2014 at 05:25:55PM +0800, Michael wang wrote: > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 0326c06..bf4a6ed 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -3464,6 +3464,10 @@ int sched_setscheduler(struct task_struct *p, int > policy, > .sched_policy = policy, > .sched_priority = param->sched_priority > }; > + > + if (fair_policy(policy)) > + attr.sched_nice = PRIO_TO_NICE(attr.sched_priority); > + > return __sched_setscheduler(p, &attr, true); > } > EXPORT_SYMBOL_GPL(sched_setscheduler); > @@ -3494,6 +3498,10 @@ int sched_setscheduler_nocheck(struct task_struct > *p, int policy, > .sched_policy = policy, > .sched_priority = param->sched_priority > }; > + > + if (fair_policy(policy)) > + attr.sched_nice = PRIO_TO_NICE(attr.sched_priority); > + > return __sched_setscheduler(p, &attr, false); > }
That seems wrong; the manpage confirms, from sched_setscheduler(2): For processes scheduled under one of the normal scheduling policies (SCHED_OTHER, SCHED_IDLE, SCHED_BATCH), sched_priority is not used in scheduling decisions (it must be speciā fied as 0). That said; we should probably preserve the nice value, which with the current code we reset to 0. --- kernel/sched/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 0326c06953eb..f3abbb7dae62 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3462,7 +3462,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); } @@ -3492,7 +3493,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); } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/