summaryrefslogtreecommitdiffstats
path: root/drivers/tty/n_tty.c
diff options
context:
space:
mode:
authorPeter Hurley2013-07-23 14:47:30 +0200
committerGreg Kroah-Hartman2013-07-24 01:43:03 +0200
commit3afb1b394a49d1237c9c0af8e8b724ddfe5b94ba (patch)
tree958d6da99e73bf1834492b2ab17702087126abc0 /drivers/tty/n_tty.c
parentn_tty: Move n_tty_write_wakeup() to avoid forward declaration (diff)
downloadkernel-qcow2-linux-3afb1b394a49d1237c9c0af8e8b724ddfe5b94ba.tar.gz
kernel-qcow2-linux-3afb1b394a49d1237c9c0af8e8b724ddfe5b94ba.tar.xz
kernel-qcow2-linux-3afb1b394a49d1237c9c0af8e8b724ddfe5b94ba.zip
n_tty: Special case pty flow control
The pty driver forces ldisc flow control on, regardless of available receive buffer space, so the writer can be woken whenever unthrottle is called. However, this 'forced throttle' has performance consequences, as multiple atomic operations are necessary to unthrottle and perform the write wakeup for every input line (in canonical mode). Instead, short-circuit the unthrottle if the tty is a pty and perform the write wakeup directly. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/n_tty.c')
-rw-r--r--drivers/tty/n_tty.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 0e3efc1ed2d5..59eb444fe17c 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -231,6 +231,8 @@ static void n_tty_write_wakeup(struct tty_struct *tty)
static inline void n_tty_check_throttle(struct tty_struct *tty)
{
+ if (tty->driver->type == TTY_DRIVER_TYPE_PTY)
+ return;
/*
* Check the remaining room for the input canonicalization
* mode. We don't want to throttle the driver if we're in
@@ -250,6 +252,18 @@ static inline void n_tty_check_throttle(struct tty_struct *tty)
static inline void n_tty_check_unthrottle(struct tty_struct *tty)
{
+ if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
+ tty->link->ldisc->ops->write_wakeup == n_tty_write_wakeup) {
+ if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE)
+ return;
+ if (!tty->count)
+ return;
+ n_tty_set_room(tty);
+ n_tty_write_wakeup(tty->link);
+ wake_up_interruptible_poll(&tty->link->write_wait, POLLOUT);
+ return;
+ }
+
/* If there is enough space in the read buffer now, let the
* low-level driver know. We use chars_in_buffer() to
* check the buffer, as it now knows about canonical mode.