tty: Only wakeup the line discipline idle queue when queue is active
authorIvo Sieben <meltedpianoman@gmail.com>
Tue, 18 Dec 2012 14:48:50 +0000 (15:48 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jan 2013 07:02:22 +0000 (23:02 -0800)
Before waking up the tty line discipline idle queue first check if the queue is
active (non empty). This prevents unnecessary entering the critical section in
the wake_up() function and therefore avoid needless scheduling overhead on a
PREEMPT_RT system caused by two processes being in the same critical section.

Signed-off-by: Ivo Sieben <meltedpianoman@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/tty_ldisc.c

index c5782294e53261e701f13292b5732c231cfb9d14..e96d1876bd629e9abe6e62be8218c6c3f85385aa 100644 (file)
@@ -64,7 +64,9 @@ static void put_ldisc(struct tty_ldisc *ld)
                return;
        }
        raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-       wake_up(&ld->wq_idle);
+
+       if (waitqueue_active(&ld->wq_idle))
+               wake_up(&ld->wq_idle);
 }
 
 /**