From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <peter@programming.kicks-ass.net>
Cc: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>,
Dhaval Giani <dhaval@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Remove duplicate code from sched_fair.c
Date: Fri, 22 Feb 2008 13:25:53 +0530 [thread overview]
Message-ID: <20080222075553.GA3691@balbir.in.ibm.com> (raw)
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
next reply other threads:[~2008-02-22 8:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-22 7:55 Balbir Singh [this message]
2008-02-22 9:40 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080222075553.GA3691@balbir.in.ibm.com \
--to=balbir@linux.vnet.ibm.com \
--cc=dhaval@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peter@programming.kicks-ass.net \
--cc=vatsa@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®