Skip to content

Commit

Permalink
sched: Change pick_next_task_rt from unlikely to likely
Browse files Browse the repository at this point in the history
The if (unlikely(!rt_rq->rt_nr_running)) test in pick_next_task_rt()
tests if there is another rt task ready to run. If so, then pick it.

In most systems, only one RT task runs at a time most of the time.
Running the branch unlikely annotator profiler on a system doing average
work "running firefox, evolution, xchat, distcc builds, etc", it showed the
following:

 correct incorrect  %        Function                  File              Line
 ------- ---------  -        --------                  ----              ----
  324344 135104992  99 _pick_next_task_rt             sched_rt.c           1064

99% of the time the condition is true. When an RT task schedules out,
it is unlikely that another RT task is waiting to run on that same run queue.

Simply remove the unlikely() condition.

Acked-by: Gregory Haskins <ghaskins@novell.com>
Cc:Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Dec 14, 2010
1 parent 33c3d6c commit 8e54a2c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/sched_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ static struct task_struct *_pick_next_task_rt(struct rq *rq)

rt_rq = &rq->rt;

if (unlikely(!rt_rq->rt_nr_running))
if (!rt_rq->rt_nr_running)
return NULL;

if (rt_rq_throttled(rt_rq))
Expand Down

0 comments on commit 8e54a2c

Please sign in to comment.