sched: Clean up check_preempt_wakeup()
Streamline the wakeup preemption code a bit, unifying the preempt path so that they all do the same. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
a65ac745e4
commit
3a7e73a2e2
|
@ -1651,10 +1651,8 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
|
|||
int sync = wake_flags & WF_SYNC;
|
||||
int scale = cfs_rq->nr_running >= sched_nr_latency;
|
||||
|
||||
if (unlikely(rt_prio(p->prio))) {
|
||||
resched_task(curr);
|
||||
return;
|
||||
}
|
||||
if (unlikely(rt_prio(p->prio)))
|
||||
goto preempt;
|
||||
|
||||
if (unlikely(p->sched_class != &fair_sched_class))
|
||||
return;
|
||||
|
@ -1680,37 +1678,32 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
|
|||
return;
|
||||
|
||||
/* Idle tasks are by definition preempted by everybody. */
|
||||
if (unlikely(curr->policy == SCHED_IDLE)) {
|
||||
resched_task(curr);
|
||||
return;
|
||||
}
|
||||
if (unlikely(curr->policy == SCHED_IDLE))
|
||||
goto preempt;
|
||||
|
||||
if ((sched_feat(WAKEUP_SYNC) && sync) ||
|
||||
(sched_feat(WAKEUP_OVERLAP) &&
|
||||
(se->avg_overlap < sysctl_sched_migration_cost &&
|
||||
pse->avg_overlap < sysctl_sched_migration_cost))) {
|
||||
resched_task(curr);
|
||||
return;
|
||||
}
|
||||
if (sched_feat(WAKEUP_SYNC) && sync)
|
||||
goto preempt;
|
||||
|
||||
if (sched_feat(WAKEUP_RUNNING)) {
|
||||
if (pse->avg_running < se->avg_running) {
|
||||
set_next_buddy(pse);
|
||||
resched_task(curr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (sched_feat(WAKEUP_OVERLAP) &&
|
||||
se->avg_overlap < sysctl_sched_migration_cost &&
|
||||
pse->avg_overlap < sysctl_sched_migration_cost)
|
||||
goto preempt;
|
||||
|
||||
if (sched_feat(WAKEUP_RUNNING) && pse->avg_running < se->avg_running)
|
||||
goto preempt;
|
||||
|
||||
if (!sched_feat(WAKEUP_PREEMPT))
|
||||
return;
|
||||
|
||||
find_matching_se(&se, &pse);
|
||||
|
||||
BUG_ON(!pse);
|
||||
|
||||
update_curr(cfs_rq);
|
||||
find_matching_se(&se, &pse);
|
||||
BUG_ON(!pse);
|
||||
if (wakeup_preempt_entity(se, pse) == 1)
|
||||
goto preempt;
|
||||
|
||||
if (wakeup_preempt_entity(se, pse) == 1) {
|
||||
return;
|
||||
|
||||
preempt:
|
||||
resched_task(curr);
|
||||
/*
|
||||
* Only set the backward buddy when the current task is still
|
||||
|
@ -1723,9 +1716,9 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
|
|||
*/
|
||||
if (unlikely(!se->on_rq || curr == rq->idle))
|
||||
return;
|
||||
|
||||
if (sched_feat(LAST_BUDDY) && scale && entity_is_task(se))
|
||||
set_last_buddy(se);
|
||||
}
|
||||
}
|
||||
|
||||
static struct task_struct *pick_next_task_fair(struct rq *rq)
|
||||
|
|
Loading…
Reference in New Issue