diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2013-06-15 09:36:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-23 19:47:08 -0400 |
commit | 7bfe0b7116be207cf2204ae06335cc89d8f8ee02 (patch) | |
tree | 03175cd2ce9dd8013c4aaa8e2dd426767aa1a4c7 /drivers/tty/pty.c | |
parent | 7391ee16950e772076d321792d9fbf030f921345 (diff) |
tty: Track flip buffer memory limit atomically
Lockless flip buffers require atomically updating the bytes-in-use
watermark.
The pty driver also peeks at the watermark value to limit
memory consumption to a much lower value than the default; query
the watermark with new fn, tty_buffer_space_avail().
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r-- | drivers/tty/pty.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 1b39dd639ee9..b38a28bd9511 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -89,17 +89,13 @@ static void pty_unthrottle(struct tty_struct *tty) | |||
89 | * pty_space - report space left for writing | 89 | * pty_space - report space left for writing |
90 | * @to: tty we are writing into | 90 | * @to: tty we are writing into |
91 | * | 91 | * |
92 | * The tty buffers allow 64K but we sneak a peak and clip at 8K this | 92 | * Limit the buffer space used by ptys to 8k. |
93 | * allows a lot of overspill room for echo and other fun messes to | ||
94 | * be handled properly | ||
95 | */ | 93 | */ |
96 | 94 | ||
97 | static int pty_space(struct tty_struct *to) | 95 | static int pty_space(struct tty_struct *to) |
98 | { | 96 | { |
99 | int n = 8192 - to->port->buf.memory_used; | 97 | int n = tty_buffer_space_avail(to->port); |
100 | if (n < 0) | 98 | return min(n, 8192); |
101 | return 0; | ||
102 | return n; | ||
103 | } | 99 | } |
104 | 100 | ||
105 | /** | 101 | /** |