linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched: Accelerate "pick_next_entity" under special condition
@ 2012-01-16  9:37 Michael Wang
  2012-01-16  9:50 ` Michael Wang
  2012-01-16  9:51 ` Peter Zijlstra
  0 siblings, 2 replies; 29+ messages in thread
From: Michael Wang @ 2012-01-16  9:37 UTC (permalink / raw)
  To: Peter Zijlstra, ingo Molnar; +Cc: LKML

From: Michael Wang <wangyun@linux.vnet.ibm.com>

We can avoid some useless operation in some special condition.

For example:
If we have "cfs_rq->next" and it can be use, we just return it directly.

Signed-off-by: Michael Wang <wangyun@linux.vnet.ibm.com>
---
 kernel/sched/fair.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 84adb2d..9fc2c3c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1295,6 +1295,8 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
 static int
 wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se);
 
+#define ENTITY_PREEMPT_ALLOWED(prev,next)	(wakeup_preempt_entity(prev, next) < 1)
+
 /*
  * Pick the next process, keeping these things in mind, in this order:
  * 1) keep things fair between processes/task groups
@@ -1308,29 +1310,33 @@ static struct sched_entity *pick_next_entity(struct cfs_rq *cfs_rq)
 	struct sched_entity *left = se;
 
 	/*
-	 * Avoid running the skip buddy, if running something else can
-	 * be done without getting too unfair.
+	 * Someone really wants this to run. If it's not unfair, run it.
 	 */
-	if (cfs_rq->skip == se) {
-		struct sched_entity *second = __pick_next_entity(se);
-		if (second && wakeup_preempt_entity(second, left) < 1)
-			se = second;
+	if (cfs_rq->next && ENTITY_PREEMPT_ALLOWED(cfs_rq->next, left)) {
+		se = cfs_rq->next;
+		goto out;
 	}
 
 	/*
 	 * Prefer last buddy, try to return the CPU to a preempted task.
 	 */
-	if (cfs_rq->last && wakeup_preempt_entity(cfs_rq->last, left) < 1)
+	if (cfs_rq->last && ENTITY_PREEMPT_ALLOWED(cfs_rq->last, left)) {
 		se = cfs_rq->last;
+		goto out;
+	}
 
 	/*
-	 * Someone really wants this to run. If it's not unfair, run it.
+	 * Avoid running the skip buddy, if running something else can
+	 * be done without getting too unfair.
 	 */
-	if (cfs_rq->next && wakeup_preempt_entity(cfs_rq->next, left) < 1)
-		se = cfs_rq->next;
+	if (cfs_rq->skip == se) {
+		struct sched_entity *second = __pick_next_entity(se);
+		if (second && ENTITY_PREEMPT_ALLOWED(second, left))
+			se = second;
+	}
 
+out:
 	clear_buddies(cfs_rq, se);
-
 	return se;
 }
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2012-09-04 18:50 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-16  9:37 [PATCH] sched: Accelerate "pick_next_entity" under special condition Michael Wang
2012-01-16  9:50 ` Michael Wang
2012-01-16  9:51 ` Peter Zijlstra
2012-01-16 10:34   ` Michael Wang
2012-01-17  2:36   ` [PATCH v2] " Michael Wang
2012-01-17  2:41     ` Michael Wang
2012-01-17  2:58     ` Xiaotian Feng
2012-01-17  3:04       ` Michael Wang
2012-01-25 15:55         ` Peter Zijlstra
2012-01-26 10:04           ` Ingo Molnar
2012-01-27  1:22             ` Michael Wang
2012-01-27  4:42               ` Cong Wang
2012-01-29  6:32                 ` Michael Wang
2012-01-29 16:33                   ` Ingo Molnar
2012-01-30  3:18                     ` Michael Wang
2012-01-30  3:25                       ` Cong Wang
2012-01-30  5:47                         ` Michael Wang
2012-07-03  6:34                           ` [PATCH] sched: remove useless code in yield_to Michael Wang
2012-07-12  5:45                             ` Michael Wang
2012-07-12 14:07                             ` Peter Zijlstra
2012-07-12 18:44                               ` Mike Galbraith
2012-07-16  2:39                               ` Michael Wang
2012-08-17  6:56                               ` Michael Wang
2012-08-17  9:43                                 ` Peter Zijlstra
2012-08-10  3:05                             ` Michael Wang
2012-08-10  3:10                               ` Michael Wang
2012-08-10  5:52                                 ` Mike Galbraith
2012-09-04 18:50                             ` [tip:sched/core] sched: Remove useless code in yield_to() tip-bot for Michael Wang
2012-01-27  0:56           ` [PATCH v2] sched: Accelerate "pick_next_entity" under special condition Michael Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).