Commit 25de0902 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] sched: micro-optimisation for wake_up

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.
parent 85841fc0
......@@ -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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment