diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2013-06-15 09:36:02 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-23 19:47:07 -0400 |
commit | 1cef50e317c3395c6e8451f2b82a155db6ef2b42 (patch) | |
tree | 5721c11c135878e4806b118b5cef5dc407e1b9b7 /drivers/tty/tty_buffer.c | |
parent | 1fc359fc3ea72314cc3ebdfa94c60e020c152cd2 (diff) |
tty: Fix flip buffer free list
Since flip buffers are size-aligned to 256 bytes and all flip
buffers 512-bytes or larger are not added to the free list, the
free list only contains 256-byte flip buffers.
Remove the list search when allocating a new flip buffer.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty_buffer.c')
-rw-r--r-- | drivers/tty/tty_buffer.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 170674cb68fc..a5e396217f76 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c | |||
@@ -18,6 +18,10 @@ | |||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/ratelimit.h> | 19 | #include <linux/ratelimit.h> |
20 | 20 | ||
21 | |||
22 | #define MIN_TTYB_SIZE 256 | ||
23 | #define TTYB_ALIGN_MASK 255 | ||
24 | |||
21 | /** | 25 | /** |
22 | * tty_buffer_free_all - free buffers used by a tty | 26 | * tty_buffer_free_all - free buffers used by a tty |
23 | * @tty: tty to free from | 27 | * @tty: tty to free from |
@@ -94,7 +98,7 @@ static void tty_buffer_free(struct tty_port *port, struct tty_buffer *b) | |||
94 | buf->memory_used -= b->size; | 98 | buf->memory_used -= b->size; |
95 | WARN_ON(buf->memory_used < 0); | 99 | WARN_ON(buf->memory_used < 0); |
96 | 100 | ||
97 | if (b->size >= 512) | 101 | if (b->size > MIN_TTYB_SIZE) |
98 | kfree(b); | 102 | kfree(b); |
99 | else { | 103 | else { |
100 | b->next = buf->free; | 104 | b->next = buf->free; |
@@ -176,9 +180,10 @@ void tty_buffer_flush(struct tty_struct *tty) | |||
176 | static struct tty_buffer *tty_buffer_find(struct tty_port *port, size_t size) | 180 | static struct tty_buffer *tty_buffer_find(struct tty_port *port, size_t size) |
177 | { | 181 | { |
178 | struct tty_buffer **tbh = &port->buf.free; | 182 | struct tty_buffer **tbh = &port->buf.free; |
179 | while ((*tbh) != NULL) { | 183 | if (size <= MIN_TTYB_SIZE) { |
180 | struct tty_buffer *t = *tbh; | 184 | if (*tbh) { |
181 | if (t->size >= size) { | 185 | struct tty_buffer *t = *tbh; |
186 | |||
182 | *tbh = t->next; | 187 | *tbh = t->next; |
183 | t->next = NULL; | 188 | t->next = NULL; |
184 | t->used = 0; | 189 | t->used = 0; |
@@ -187,10 +192,9 @@ static struct tty_buffer *tty_buffer_find(struct tty_port *port, size_t size) | |||
187 | port->buf.memory_used += t->size; | 192 | port->buf.memory_used += t->size; |
188 | return t; | 193 | return t; |
189 | } | 194 | } |
190 | tbh = &((*tbh)->next); | ||
191 | } | 195 | } |
192 | /* Round the buffer size out */ | 196 | /* Round the buffer size out */ |
193 | size = (size + 0xFF) & ~0xFF; | 197 | size = __ALIGN_MASK(size, TTYB_ALIGN_MASK); |
194 | return tty_buffer_alloc(port, size); | 198 | return tty_buffer_alloc(port, size); |
195 | /* Should possibly check if this fails for the largest buffer we | 199 | /* Should possibly check if this fails for the largest buffer we |
196 | have queued and recycle that ? */ | 200 | have queued and recycle that ? */ |