]> git.hungrycats.org Git - linux/commitdiff
[PATCH] sched: micro-optimisation for wake_up
authorAndrew Morton <akpm@osdl.org>
Mon, 10 May 2004 06:29:40 +0000 (23:29 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 10 May 2004 06:29:40 +0000 (23:29 -0700)
From: Nick Piggin <nickpiggin@yahoo.com.au>

This actually does produce better code, especially under the locked
section.

Turns a conditional + unconditional jump under the lock in the unlikely
case into a cmov outside the lock.

kernel/sched.c

index cf210a3f8c8e81a3fe153e4e773221af2d71a47a..3ba86bfbbbb9c1be32f9dbb6ac35ef6ad53bdaf0 100644 (file)
@@ -2400,15 +2400,16 @@ void fastcall __wake_up_locked(wait_queue_head_t *q, unsigned int mode)
 void fastcall __wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr_exclusive)
 {
        unsigned long flags;
+       int sync = 1;
 
        if (unlikely(!q))
                return;
 
+       if (unlikely(!nr_exclusive))
+               sync = 0;
+
        spin_lock_irqsave(&q->lock, flags);
-       if (likely(nr_exclusive))
-               __wake_up_common(q, mode, nr_exclusive, 1);
-       else
-               __wake_up_common(q, mode, nr_exclusive, 0);
+       __wake_up_common(q, mode, nr_exclusive, sync);
        spin_unlock_irqrestore(&q->lock, flags);
 }
 EXPORT_SYMBOL_GPL(__wake_up_sync);     /* For internal use only */