Skip to content

Commit

Permalink
sched: optimize schedule() a bit on SMP
Browse files Browse the repository at this point in the history
optimize schedule() a bit on SMP, by moving the rq-clock update
outside the rq lock.

code size is the same:

      text    data     bss     dec     hex filename
     25725    2666      96   28487    6f47 sched.o.before
     25725    2666      96   28487    6f47 sched.o.after

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Ingo Molnar committed Oct 15, 2007
1 parent 08ec3df commit 1e81995
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -3481,9 +3481,13 @@ asmlinkage void __sched schedule(void)

schedule_debug(prev);

spin_lock_irq(&rq->lock);
clear_tsk_need_resched(prev);
/*
* Do the rq-clock update outside the rq lock:
*/
local_irq_disable();
__update_rq_clock(rq);
spin_lock(&rq->lock);
clear_tsk_need_resched(prev);

if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
if (unlikely((prev->state & TASK_INTERRUPTIBLE) &&
Expand Down

0 comments on commit 1e81995

Please sign in to comment.