[RFC/PATCH 17/17] sched: fair: optimize the elegebility test

From: Peter Zijlstra
Date: Sun Mar 09 2008 - 13:12:23 EST


Suggested by Dmitry Adamushko; trade a div for a mult.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
---
kernel/sched_fair.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

Index: linux-2.6-2/kernel/sched_fair.c
===================================================================
--- linux-2.6-2.orig/kernel/sched_fair.c
+++ linux-2.6-2/kernel/sched_fair.c
@@ -339,6 +339,12 @@ s64 avg_vruntime(struct cfs_root_rq *cfs
}

static inline
+int avg_vruntime_cmp(struct cfs_root_rq *cfs_r_rq, s64 vruntime)
+{
+ return (vruntime * cfs_r_rq->nr_queued) <= cfs_r_rq->avg_vruntime;
+}
+
+static inline
s64 entity_deadline_key(struct cfs_root_rq *cfs_r_rq, struct sched_entity *se)
{
return se->vruntime + se->vperiod - cfs_r_rq->min_vruntime;
@@ -430,11 +436,10 @@ static struct sched_entity *__pick_next_
*/
static struct sched_entity *__pick_next_entity(struct cfs_root_rq *cfs_r_rq)
{
- struct sched_entity *next_deadline;
- s64 avg = avg_vruntime(cfs_r_rq);
+ struct sched_entity *next_deadline = __pick_next_deadline(cfs_r_rq);
+ s64 vruntime = entity_timeline_key(cfs_r_rq, next_deadline);

- next_deadline = __pick_next_deadline(cfs_r_rq);
- if (entity_timeline_key(cfs_r_rq, next_deadline) <= avg)
+ if (avg_vruntime_cmp(cfs_r_rq, vruntime))
return next_deadline;

return __pick_next_timeline(cfs_r_rq);

--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/