Commit 383afd09 authored by Steven Rostedt's avatar Steven Rostedt Committed by Ingo Molnar

sched: Fix broken setscheduler()

I decided to run my tests on linux-next, and my wakeup_rt tracer was
broken. After running a bisect, I found that the problem commit was:

   linux-next commit c365c292
   "sched: Consider pi boosting in setscheduler()"

And the reason the wake_rt tracer test was failing, was because it had
no RT task to trace. I first noticed this when running with
sched_switch event and saw that my RT task still had normal SCHED_OTHER
priority. Looking at the problem commit, I found:

 -       p->normal_prio = normal_prio(p);
 -       p->prio = rt_mutex_getprio(p);

With no

 +       p->normal_prio = normal_prio(p);
 +       p->prio = rt_mutex_getprio(p);

Reading what the commit is suppose to do, I realize that the p->prio
can't be set if the task is boosted with a higher prio, but the
p->normal_prio still needs to be set regardless, otherwise, when the
task is deboosted, it wont get the new priority.

The p->prio has to be set before "check_class_changed()" is called,
otherwise the class wont be changed.

Also added fix to newprio to include a check for deadline policy that
was missing. This change was suggested by Juri Lelli.
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Cc: SebastianAndrzej Siewior <bigeasy@linutronix.de>
Cc: Juri Lelli <juri.lelli@gmail.com>
Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140306120438.638bfe94@gandalf.local.homeSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 07082682
...@@ -3195,6 +3195,7 @@ static void __setscheduler_params(struct task_struct *p, ...@@ -3195,6 +3195,7 @@ static void __setscheduler_params(struct task_struct *p,
* getparam()/getattr() don't report silly values for !rt tasks. * getparam()/getattr() don't report silly values for !rt tasks.
*/ */
p->rt_priority = attr->sched_priority; p->rt_priority = attr->sched_priority;
p->normal_prio = normal_prio(p);
set_load_weight(p); set_load_weight(p);
} }
...@@ -3204,6 +3205,12 @@ static void __setscheduler(struct rq *rq, struct task_struct *p, ...@@ -3204,6 +3205,12 @@ static void __setscheduler(struct rq *rq, struct task_struct *p,
{ {
__setscheduler_params(p, attr); __setscheduler_params(p, attr);
/*
* If we get here, there was no pi waiters boosting the
* task. It is safe to use the normal prio.
*/
p->prio = normal_prio(p);
if (dl_prio(p->prio)) if (dl_prio(p->prio))
p->sched_class = &dl_sched_class; p->sched_class = &dl_sched_class;
else if (rt_prio(p->prio)) else if (rt_prio(p->prio))
...@@ -3262,7 +3269,8 @@ static int __sched_setscheduler(struct task_struct *p, ...@@ -3262,7 +3269,8 @@ static int __sched_setscheduler(struct task_struct *p,
const struct sched_attr *attr, const struct sched_attr *attr,
bool user) bool user)
{ {
int newprio = MAX_RT_PRIO - 1 - attr->sched_priority; int newprio = dl_policy(attr->sched_policy) ? MAX_DL_PRIO - 1 :
MAX_RT_PRIO - 1 - attr->sched_priority;
int retval, oldprio, oldpolicy = -1, on_rq, running; int retval, oldprio, oldpolicy = -1, on_rq, running;
int policy = attr->sched_policy; int policy = attr->sched_policy;
unsigned long flags; unsigned long flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment