* Remove duplicate code from sched_fair.c
@ 2008-02-22 7:55 Balbir Singh
2008-02-22 9:40 ` Ingo Molnar
0 siblings, 1 reply; 2+ messages in thread
From: Balbir Singh @ 2008-02-22 7:55 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: Srivatsa Vaddagiri, Dhaval Giani, linux-kernel
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 <balbir@linux.vnet.ibm.com>
---
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Remove duplicate code from sched_fair.c
2008-02-22 7:55 Remove duplicate code from sched_fair.c Balbir Singh
@ 2008-02-22 9:40 ` Ingo Molnar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2008-02-22 9:40 UTC (permalink / raw)
To: Peter Zijlstra, Srivatsa Vaddagiri, Dhaval Giani, linux-kernel
* Balbir Singh <balbir@linux.vnet.ibm.com> wrote:
> 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.
thanks, applied.
Ingo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-22 9:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-22 7:55 Remove duplicate code from sched_fair.c Balbir Singh
2008-02-22 9:40 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®