public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: Check nr_running before calling pick_next_task in schedule().
@ 2011-07-01 18:41 Rakib Mullick
  2011-07-02  2:18 ` Paul Turner
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Rakib Mullick @ 2011-07-01 18:41 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Peter Zijlstra, linux-kernel

Currently at schedule(), when we call pick_next_task we don't check whether current rq is empty or not. Since idle_balance can fail,
its nice to check whether we really have any task on rq or not. If not, we can call idle_sched_class.pick_next_task straight.

Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
---

diff --git a/kernel/sched.c b/kernel/sched.c
index 5925275..a4f4f58 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4273,7 +4273,14 @@ need_resched:
 		idle_balance(cpu, rq);
 
 	put_prev_task(rq, prev);
-	next = pick_next_task(rq);
+	/*  Since idle_balance can fail, its better to check rq->nr_running.
+	 *  Otherwise we can call idle_sched_class.pick_next_task straight,
+	 *  cause we need to do some accounting.
+	 */
+	if (likely(rq->nr_running))
+		next = pick_next_task(rq);
+	else
+		next = idle_sched_class.pick_next_task(rq);
 	clear_tsk_need_resched(prev);
 	rq->skip_clock_update = 0;
 



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

end of thread, other threads:[~2011-07-09  4:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-01 18:41 [PATCH] sched: Check nr_running before calling pick_next_task in schedule() Rakib Mullick
2011-07-02  2:18 ` Paul Turner
2011-07-02  2:23 ` Paul Turner
2011-07-02  4:37   ` Rakib Mullick
2011-07-02  9:51 ` Peter Zijlstra
2011-07-02 14:26   ` Rakib Mullick
2011-07-02 15:35     ` Peter Zijlstra
2011-07-03  8:07       ` Rakib Mullick
2011-07-04  9:00         ` Rakib Mullick
2011-07-09  4:43     ` Rakib Mullick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox