From: Ivo Sieben <meltedpianoman@gmail.com>
To: Alan Cox <alan@linux.intel.com>,
Greg KH <gregkh@linuxfoundation.org>,
<linux-serial@vger.kernel.org>,
RT <linux-rt-users@vger.kernel.org>
Cc: Ivo Sieben <meltedpianoman@gmail.com>
Subject: [PATCH-v3] tty: prevent unnecessary work queue lock checking on flip buffer copy
Date: Thu, 27 Sep 2012 14:02:05 +0200 [thread overview]
Message-ID: <1348747325-13539-1-git-send-email-meltedpianoman@gmail.com> (raw)
In-Reply-To: <1348747101-13462-1-git-send-email-meltedpianoman@gmail.com>
When low_latency flag is set 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 flush the workqueue.
This prevents unnecessary spin lock/unlock on the workqueue spin lock that
can cause additional scheduling overhead on a PREEMPT_RT system. On a 200
MHz AT91SAM9261 processor setup this fixes about 100us of scheduling
overhead on the TTY read call.
Signed-off-by: Ivo Sieben <meltedpianoman@gmail.com>
---
v3:
Prevented the flush the easy way: workque is not flused when low latency
flag is set. This means that drivers that use the tty_schedule_flip()
functions instead of the tty_flip_buffer_push() should never have the
low_latency flag set, otherwise the workqueue won't be flushed. Added a
WARN_ON() to detect those drivers.
For PREEMPT_RT systems: this optimization will only work when the user has
actually enabled the ASYNC_LOW_LATENCY option for the serial driver, otherwise
the workqueue will still be flushed although it is not used since the PREMPT_RT
patch makes the tty_flip_buffer_push() function to always bypass the workqueue.
drivers/tty/tty_buffer.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 6146e8b..b952de1 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -342,6 +342,8 @@ EXPORT_SYMBOL(tty_insert_flip_string_flags);
* Takes any pending buffers and transfers their ownership to the
* ldisc side of the queue. It then schedules those characters for
* processing by the line discipline.
+ * Note that this function can only be used when the low_latency flag
+ * is unset. Otherwise the workqueue won't be flushed.
*
* Locking: Takes tty->buf.lock
*/
@@ -349,6 +351,7 @@ EXPORT_SYMBOL(tty_insert_flip_string_flags);
void tty_schedule_flip(struct tty_struct *tty)
{
unsigned long flags;
+ WARN_ON(tty->low_latency);
spin_lock_irqsave(&tty->buf.lock, flags);
if (tty->buf.tail != NULL)
tty->buf.tail->commit = tty->buf.tail->used;
@@ -514,7 +517,8 @@ static void flush_to_ldisc(struct work_struct *work)
*/
void tty_flush_to_ldisc(struct tty_struct *tty)
{
- flush_work(&tty->buf.work);
+ if (!tty->low_latency)
+ flush_work(&tty->buf.work);
}
/**
--
1.7.9.5
next prev parent reply other threads:[~2012-09-27 12:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1348747325-13539-1-git-send-email-meltedpianoman@gmail.com \
--to=meltedpianoman@gmail.com \
--cc=alan@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).