linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: prevent unnecessary work queue lock checking on flip buffer copy
@ 2012-09-20 14:02 Ivo Sieben
  2012-09-20 16:33 ` Alan Cox
  0 siblings, 1 reply; 16+ messages in thread
From: Ivo Sieben @ 2012-09-20 14:02 UTC (permalink / raw)
  To: Alan Cox, Greg KH, linux-serial, RT; +Cc: Ivo Sieben

In case of PREEMPT_RT or when low_latency flag is set by the serial driver
the TTY receive flip buffer is copied to the line discipline directly
instead of using a work queue in the background. Therefor only in case a
workqueue is actually used for copying data to the line discipline
we'll have to check & wait for the workqueue to finish.

This prevents unnecessary spin lock/unlock on the workqueue spin lock that can
cause additional scheduling overhead on a PREEMPT_RT system. On a 240 MHz
AT91SAM9261 processor setup this fixes about 100us of scheduling overhead on the
TTY read call.

Signed-off-by: Ivo Sieben <meltedpianoman@gmail.com>
---
 drivers/tty/tty_buffer.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 5cfa548..b8e90b8 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -492,7 +492,16 @@ static void flush_to_ldisc(struct work_struct *work)
  */
 void tty_flush_to_ldisc(struct tty_struct *tty)
 {
-	flush_work(&tty->buf.work);
+	/*
+	 * Only in case a workqueue is actually used for copying data to the
+	 * line discipline, we'll have to wait for the workqueue to finish. In
+	 * other cases this prevents us from unnecessary blocking by the
+	 * workqueue spin lock.
+	 */
+#ifndef CONFIG_PREEMPT_RT_FULL
+	if (!tty->low_latency)
+		flush_work(&tty->buf.work);
+#endif
 }
 
 /**
-- 
1.7.9.5



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

end of thread, other threads:[~2012-10-24 18:22 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-20 14:02 [PATCH] tty: prevent unnecessary work queue lock checking on flip buffer copy Ivo Sieben
2012-09-20 16:33 ` Alan Cox
2012-09-24  9:33   ` Ivo Sieben
2012-09-25 12:01     ` [PATCH-v2] " Ivo Sieben
2012-09-25 13:06       ` Alan Cox
2012-09-25 14:39         ` Ivo Sieben
2012-09-25 14:47           ` Alan Cox
2012-09-27 11:58             ` [PATCH-v3] " Ivo Sieben
2012-09-27 12:02               ` Ivo Sieben
2012-10-22 23:47                 ` Greg KH
2012-10-23 10:16                   ` Alan Cox
2012-10-24 12:35                     ` [PATCH] [tty]: Report warning when low_latency flag is wrongly used Ivo Sieben
2012-10-24 14:32                       ` Paul Gortmaker
2012-10-24 18:22                     ` [PATCH-v3] tty: prevent unnecessary work queue lock checking on flip buffer copy Greg KH
2012-09-27 13:15               ` Alan Cox
2012-09-27 16:53                 ` Greg KH

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