summaryrefslogtreecommitdiff
path: root/drivers/tty/tty_buffer.c
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-06-15 13:36:02 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-23 23:47:07 (GMT)
commit1cef50e317c3395c6e8451f2b82a155db6ef2b42 (patch)
tree5721c11c135878e4806b118b5cef5dc407e1b9b7 /drivers/tty/tty_buffer.c
parent1fc359fc3ea72314cc3ebdfa94c60e020c152cd2 (diff)
downloadlinux-1cef50e317c3395c6e8451f2b82a155db6ef2b42.tar.xz
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.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 170674c..a5e3962 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -18,6 +18,10 @@
#include <linux/module.h>
#include <linux/ratelimit.h>
+
+#define MIN_TTYB_SIZE 256
+#define TTYB_ALIGN_MASK 255
+
/**
* tty_buffer_free_all - free buffers used by a tty
* @tty: tty to free from
@@ -94,7 +98,7 @@ static void tty_buffer_free(struct tty_port *port, struct tty_buffer *b)
buf->memory_used -= b->size;
WARN_ON(buf->memory_used < 0);
- if (b->size >= 512)
+ if (b->size > MIN_TTYB_SIZE)
kfree(b);
else {
b->next = buf->free;
@@ -176,9 +180,10 @@ void tty_buffer_flush(struct tty_struct *tty)
static struct tty_buffer *tty_buffer_find(struct tty_port *port, size_t size)
{
struct tty_buffer **tbh = &port->buf.free;
- while ((*tbh) != NULL) {
- struct tty_buffer *t = *tbh;
- if (t->size >= size) {
+ if (size <= MIN_TTYB_SIZE) {
+ if (*tbh) {
+ struct tty_buffer *t = *tbh;
+
*tbh = t->next;
t->next = NULL;
t->used = 0;
@@ -187,10 +192,9 @@ static struct tty_buffer *tty_buffer_find(struct tty_port *port, size_t size)
port->buf.memory_used += t->size;
return t;
}
- tbh = &((*tbh)->next);
}
/* Round the buffer size out */
- size = (size + 0xFF) & ~0xFF;
+ size = __ALIGN_MASK(size, TTYB_ALIGN_MASK);
return tty_buffer_alloc(port, size);
/* Should possibly check if this fails for the largest buffer we
have queued and recycle that ? */