yield_task_fair has some duplicate code, that can be replaced with rb_last(). This code reuses rb_next and removes the duplicate code. As a side effect, we don't do an rb_entry for each node as we walk along the path.
Comments, flames? Description ----------- pick_task_entity() duplicates existing code. This functionality can be easily obtained using rb_last(). Avoid code duplication by using rb_last() Signed-off-by: Balbir Singh <[EMAIL PROTECTED]> --- kernel/sched_fair.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff -puN kernel/sched_fair.c~use-existing-code-in-sched-yield kernel/sched_fair.c --- linux-2.6.25-rc2/kernel/sched_fair.c~use-existing-code-in-sched-yield 2008-02-22 11:35:35.000000000 +0530 +++ linux-2.6.25-rc2-balbir/kernel/sched_fair.c 2008-02-22 11:50:03.000000000 +0530 @@ -301,16 +301,13 @@ static struct sched_entity *__pick_next_ static inline struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq) { - struct rb_node **link = &cfs_rq->tasks_timeline.rb_node; - struct sched_entity *se = NULL; - struct rb_node *parent; - - while (*link) { - parent = *link; - se = rb_entry(parent, struct sched_entity, run_node); - link = &parent->rb_right; - } + struct rb_node *last; + struct sched_entity *se; + last = rb_last(&cfs_rq->tasks_timeline); + if (!last) + return NULL; + se = rb_entry(last, struct sched_entity, run_node); return se; } _ -- Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/