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@xxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html