diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2015-01-16 15:05:38 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-02-02 10:11:26 -0800 |
commit | 06c49f9fa31f026e00a15cc6487b4d8d99b0e333 (patch) | |
tree | 1d8031d62ef5ab2c86a68f99c4583452ce10866e /drivers/tty/n_tty.c | |
parent | 70aca71f92ca2c111978bf676287fab5580d2598 (diff) | |
download | op-kernel-dev-06c49f9fa31f026e00a15cc6487b4d8d99b0e333.zip op-kernel-dev-06c49f9fa31f026e00a15cc6487b4d8d99b0e333.tar.gz |
n_tty: Fix PARMRK over-throttling
If PARMRK is enabled, the available read buffer space computation is
overly-pessimistic, which results in severely throttled i/o, even
in the absence of parity errors. For example, if the 4k read buffer
contains 1k processed data, the input worker will compute available
space of 333 bytes, despite 3k being available. At 1365 chars of
processed data, 0 space available is computed.
*Divide remaining space* by 3, truncating down (if left == 2, left = 0).
Reported-by: Christian Riesch <christian.riesch@omicron.at>
Conflicts:
drivers/tty/n_tty.c
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.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index f63b25b..7aeabb7 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -1669,9 +1669,8 @@ n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp, while (1) { /* - * When PARMRK is set, multiply read_cnt by 3, since each byte - * might take up to three times as many spaces (depending on - * its flags, e.g. parity error). [This calculation is wrong.] + * When PARMRK is set, each input char may take up to 3 chars + * in the read buf; reduce the buffer space avail by 3x * * If we are doing input canonicalization, and there are no * pending newlines, let characters through without limit, so @@ -1683,13 +1682,10 @@ n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp, * read_tail (so this producer will not overwrite unread data) */ size_t tail = smp_load_acquire(&ldata->read_tail); - size_t head = ldata->read_head; + room = N_TTY_BUF_SIZE - (ldata->read_head - tail) - 1; if (I_PARMRK(tty)) - room = N_TTY_BUF_SIZE - (head - tail) * 3 - 1; - else - room = N_TTY_BUF_SIZE - (head - tail) - 1; - + room /= 3; if (room <= 0) room = ldata->icanon && ldata->canon_head == tail; |