linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: Only wakeup the line discipline idle queue when queue is active
@ 2012-12-18 14:48 Ivo Sieben
  2013-01-02  9:29 ` Jiri Slaby
  0 siblings, 1 reply; 17+ messages in thread
From: Ivo Sieben @ 2012-12-18 14:48 UTC (permalink / raw)
  To: linux-serial, Alan Cox, Greg KH
  Cc: Oleg Nesterov, linux-kernel, Andi Kleen, Peter Zijlstra,
	Ingo Molnar, Ivo Sieben

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>
---

 Remark:
 This patch has kind of a long history... I first tried to prevent the critical
 section in the wakeup() function itself by a change in the scheduler. But after
 review remarks from Oleg Nesterov it turned out that using the
 waitqueue_active() was a much nicer way to prevent it. See also
 https://lkml.org/lkml/2012/10/25/159

 drivers/tty/tty_ldisc.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index c578229..e96d187 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -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);
 }
 
 /**
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2013-01-21  7:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-18 14:48 [PATCH] tty: Only wakeup the line discipline idle queue when queue is active Ivo Sieben
2013-01-02  9:29 ` Jiri Slaby
2013-01-02 11:43   ` Alan Cox
2013-01-02 15:21     ` Ivo Sieben
2013-01-02 19:06       ` Jiri Slaby
2013-01-03  9:49         ` Ivo Sieben
2013-01-03 18:36           ` Oleg Nesterov
2013-01-15  9:16             ` Ivo Sieben
2013-01-15 18:03               ` Oleg Nesterov
2013-01-16  8:13           ` Preeti U Murthy
2013-01-16  9:16             ` Ivo Sieben
2013-01-16 10:41               ` Preeti U Murthy
2013-01-16 12:02                 ` Ivo Sieben
2013-01-17 10:56                   ` Preeti U Murthy
2013-01-18 15:45                     ` Oleg Nesterov
2013-01-21  2:56                       ` Preeti U Murthy
2013-01-21  7:20                       ` Ivo Sieben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).