Commit d5f9f942 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

revert 'sched: redundant reschedule when set_user_nice() boosts a prio of a...

revert 'sched: redundant reschedule when set_user_nice() boosts a prio of a task from the "expired" array'

Revert commit bd53f96c.

Con says:

This is no good, sorry. The one I saw originally was with the staircase
deadline cpu scheduler in situ and was different.

  #define TASK_PREEMPTS_CURR(p, rq) \
     ((p)->prio < (rq)->curr->prio)
     (((p)->prio < (rq)->curr->prio) && ((p)->array == (rq)->active))

This will fail to wake up a runqueue for a task that has been migrated to the
expired array of a runqueue which is otherwise idle which can happen with smp
balancing,

Cc: Dmitry Adamushko <dmitry.adamushko@gmail.com>
Cc: Con Kolivas <kernel@kolivas.org>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent da4e8ca3
...@@ -169,7 +169,7 @@ unsigned long long __attribute__((weak)) sched_clock(void) ...@@ -169,7 +169,7 @@ unsigned long long __attribute__((weak)) sched_clock(void)
(MAX_BONUS / 2 + DELTA((p)) + 1) / MAX_BONUS - 1)) (MAX_BONUS / 2 + DELTA((p)) + 1) / MAX_BONUS - 1))
#define TASK_PREEMPTS_CURR(p, rq) \ #define TASK_PREEMPTS_CURR(p, rq) \
(((p)->prio < (rq)->curr->prio) && ((p)->array == (rq)->active)) ((p)->prio < (rq)->curr->prio)
#define SCALE_PRIO(x, prio) \ #define SCALE_PRIO(x, prio) \
max(x * (MAX_PRIO - prio) / (MAX_USER_PRIO / 2), MIN_TIMESLICE) max(x * (MAX_PRIO - prio) / (MAX_USER_PRIO / 2), MIN_TIMESLICE)
...@@ -4076,13 +4076,13 @@ void rt_mutex_setprio(struct task_struct *p, int prio) ...@@ -4076,13 +4076,13 @@ void rt_mutex_setprio(struct task_struct *p, int prio)
struct prio_array *array; struct prio_array *array;
unsigned long flags; unsigned long flags;
struct rq *rq; struct rq *rq;
int delta; int oldprio;
BUG_ON(prio < 0 || prio > MAX_PRIO); BUG_ON(prio < 0 || prio > MAX_PRIO);
rq = task_rq_lock(p, &flags); rq = task_rq_lock(p, &flags);
delta = prio - p->prio; oldprio = p->prio;
array = p->array; array = p->array;
if (array) if (array)
dequeue_task(p, array); dequeue_task(p, array);
...@@ -4098,11 +4098,13 @@ void rt_mutex_setprio(struct task_struct *p, int prio) ...@@ -4098,11 +4098,13 @@ void rt_mutex_setprio(struct task_struct *p, int prio)
enqueue_task(p, array); enqueue_task(p, array);
/* /*
* Reschedule if we are currently running on this runqueue and * Reschedule if we are currently running on this runqueue and
* our priority decreased, or if our priority became higher * our priority decreased, or if we are not currently running on
* than the current's. * this runqueue and our priority is higher than the current's
*/ */
if (TASK_PREEMPTS_CURR(p, rq) || if (task_running(rq, p)) {
(delta > 0 && task_running(rq, p))) if (p->prio > oldprio)
resched_task(rq->curr);
} else if (TASK_PREEMPTS_CURR(p, rq))
resched_task(rq->curr); resched_task(rq->curr);
} }
task_rq_unlock(rq, &flags); task_rq_unlock(rq, &flags);
...@@ -4150,12 +4152,10 @@ void set_user_nice(struct task_struct *p, long nice) ...@@ -4150,12 +4152,10 @@ void set_user_nice(struct task_struct *p, long nice)
enqueue_task(p, array); enqueue_task(p, array);
inc_raw_weighted_load(rq, p); inc_raw_weighted_load(rq, p);
/* /*
* Reschedule if we are currently running on this runqueue and * If the task increased its priority or is running and
* our priority decreased, or if our priority became higher * lowered its priority, then reschedule its CPU:
* than the current's.
*/ */
if (TASK_PREEMPTS_CURR(p, rq) || if (delta < 0 || (delta > 0 && task_running(rq, p)))
(delta > 0 && task_running(rq, p)))
resched_task(rq->curr); resched_task(rq->curr);
} }
out_unlock: out_unlock:
...@@ -4382,11 +4382,13 @@ int sched_setscheduler(struct task_struct *p, int policy, ...@@ -4382,11 +4382,13 @@ int sched_setscheduler(struct task_struct *p, int policy,
__activate_task(p, rq); __activate_task(p, rq);
/* /*
* Reschedule if we are currently running on this runqueue and * Reschedule if we are currently running on this runqueue and
* our priority decreased, or our priority became higher * our priority decreased, or if we are not currently running on
* than the current's. * this runqueue and our priority is higher than the current's
*/ */
if (TASK_PREEMPTS_CURR(p, rq) || if (task_running(rq, p)) {
(task_running(rq, p) && p->prio > oldprio)) if (p->prio > oldprio)
resched_task(rq->curr);
} else if (TASK_PREEMPTS_CURR(p, rq))
resched_task(rq->curr); resched_task(rq->curr);
} }
__task_rq_unlock(rq); __task_rq_unlock(rq);
......
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