lkml.org 
[lkml]   [2011]   [Jul]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] sched: Check nr_running before calling pick_next_task in schedule().
From
Date
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;




\
 
 \ /
  Last update: 2011-07-01 20:45    [W:0.101 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site