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:
Peter Zijlstra 2009-11-28 18:51:02 +01:00 committed by Ingo Molnar
parent a65ac745e4
commit 3a7e73a2e2

View file

@ -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 sync = wake_flags & WF_SYNC;
int scale = cfs_rq->nr_running >= sched_nr_latency; int scale = cfs_rq->nr_running >= sched_nr_latency;
if (unlikely(rt_prio(p->prio))) { if (unlikely(rt_prio(p->prio)))
resched_task(curr); goto preempt;
return;
}
if (unlikely(p->sched_class != &fair_sched_class)) if (unlikely(p->sched_class != &fair_sched_class))
return; return;
@ -1680,52 +1678,47 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
return; return;
/* Idle tasks are by definition preempted by everybody. */ /* Idle tasks are by definition preempted by everybody. */
if (unlikely(curr->policy == SCHED_IDLE)) { if (unlikely(curr->policy == SCHED_IDLE))
resched_task(curr); goto preempt;
return;
}
if ((sched_feat(WAKEUP_SYNC) && sync) || if (sched_feat(WAKEUP_SYNC) && sync)
(sched_feat(WAKEUP_OVERLAP) && goto preempt;
(se->avg_overlap < sysctl_sched_migration_cost &&
pse->avg_overlap < sysctl_sched_migration_cost))) {
resched_task(curr);
return;
}
if (sched_feat(WAKEUP_RUNNING)) { if (sched_feat(WAKEUP_OVERLAP) &&
if (pse->avg_running < se->avg_running) { se->avg_overlap < sysctl_sched_migration_cost &&
set_next_buddy(pse); pse->avg_overlap < sysctl_sched_migration_cost)
resched_task(curr); goto preempt;
return;
} if (sched_feat(WAKEUP_RUNNING) && pse->avg_running < se->avg_running)
} goto preempt;
if (!sched_feat(WAKEUP_PREEMPT)) if (!sched_feat(WAKEUP_PREEMPT))
return; return;
find_matching_se(&se, &pse);
BUG_ON(!pse);
update_curr(cfs_rq); 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;
resched_task(curr);
/* preempt:
* Only set the backward buddy when the current task is still resched_task(curr);
* on the rq. This can happen when a wakeup gets interleaved /*
* with schedule on the ->pre_schedule() or idle_balance() * Only set the backward buddy when the current task is still
* point, either of which can * drop the rq lock. * on the rq. This can happen when a wakeup gets interleaved
* * with schedule on the ->pre_schedule() or idle_balance()
* Also, during early boot the idle thread is in the fair class, * point, either of which can * drop the rq lock.
* for obvious reasons its a bad idea to schedule back to it. *
*/ * Also, during early boot the idle thread is in the fair class,
if (unlikely(!se->on_rq || curr == rq->idle)) * for obvious reasons its a bad idea to schedule back to it.
return; */
if (sched_feat(LAST_BUDDY) && scale && entity_is_task(se)) if (unlikely(!se->on_rq || curr == rq->idle))
set_last_buddy(se); 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) static struct task_struct *pick_next_task_fair(struct rq *rq)