diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2008-11-04 15:25:07 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-05 04:30:13 -0500 |
commit | f4b6755fb37595da3630d1d6fc130ea6888cd48f (patch) | |
tree | 04501dab4a1573b5b6bc6932db08262806c2c0e2 | |
parent | 75fa67706cce5272bcfc51ed646f2da21f3bdb6e (diff) |
sched: cleanup fair task selection
Impact: cleanup
Clean up task selection
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/sched_fair.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index ce514afd78ff..6167336a2372 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c | |||
@@ -347,17 +347,17 @@ static void __dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) | |||
347 | rb_erase(&se->run_node, &cfs_rq->tasks_timeline); | 347 | rb_erase(&se->run_node, &cfs_rq->tasks_timeline); |
348 | } | 348 | } |
349 | 349 | ||
350 | static inline struct rb_node *first_fair(struct cfs_rq *cfs_rq) | ||
351 | { | ||
352 | return cfs_rq->rb_leftmost; | ||
353 | } | ||
354 | |||
355 | static struct sched_entity *__pick_next_entity(struct cfs_rq *cfs_rq) | 350 | static struct sched_entity *__pick_next_entity(struct cfs_rq *cfs_rq) |
356 | { | 351 | { |
357 | return rb_entry(first_fair(cfs_rq), struct sched_entity, run_node); | 352 | struct rb_node *left = cfs_rq->rb_leftmost; |
353 | |||
354 | if (!left) | ||
355 | return NULL; | ||
356 | |||
357 | return rb_entry(left, struct sched_entity, run_node); | ||
358 | } | 358 | } |
359 | 359 | ||
360 | static inline struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq) | 360 | static struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq) |
361 | { | 361 | { |
362 | struct rb_node *last = rb_last(&cfs_rq->tasks_timeline); | 362 | struct rb_node *last = rb_last(&cfs_rq->tasks_timeline); |
363 | 363 | ||
@@ -794,28 +794,16 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) | |||
794 | static int | 794 | static int |
795 | wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se); | 795 | wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se); |
796 | 796 | ||
797 | static struct sched_entity * | 797 | static struct sched_entity *pick_next_entity(struct cfs_rq *cfs_rq) |
798 | pick_next(struct cfs_rq *cfs_rq, struct sched_entity *se) | ||
799 | { | 798 | { |
799 | struct sched_entity *se = __pick_next_entity(cfs_rq); | ||
800 | |||
800 | if (!cfs_rq->next || wakeup_preempt_entity(cfs_rq->next, se) == 1) | 801 | if (!cfs_rq->next || wakeup_preempt_entity(cfs_rq->next, se) == 1) |
801 | return se; | 802 | return se; |
802 | 803 | ||
803 | return cfs_rq->next; | 804 | return cfs_rq->next; |
804 | } | 805 | } |
805 | 806 | ||
806 | static struct sched_entity *pick_next_entity(struct cfs_rq *cfs_rq) | ||
807 | { | ||
808 | struct sched_entity *se = NULL; | ||
809 | |||
810 | if (first_fair(cfs_rq)) { | ||
811 | se = __pick_next_entity(cfs_rq); | ||
812 | se = pick_next(cfs_rq, se); | ||
813 | set_next_entity(cfs_rq, se); | ||
814 | } | ||
815 | |||
816 | return se; | ||
817 | } | ||
818 | |||
819 | static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev) | 807 | static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev) |
820 | { | 808 | { |
821 | /* | 809 | /* |
@@ -1396,6 +1384,7 @@ static struct task_struct *pick_next_task_fair(struct rq *rq) | |||
1396 | 1384 | ||
1397 | do { | 1385 | do { |
1398 | se = pick_next_entity(cfs_rq); | 1386 | se = pick_next_entity(cfs_rq); |
1387 | set_next_entity(cfs_rq, se); | ||
1399 | cfs_rq = group_cfs_rq(se); | 1388 | cfs_rq = group_cfs_rq(se); |
1400 | } while (cfs_rq); | 1389 | } while (cfs_rq); |
1401 | 1390 | ||