From f434d0576edb8e79679420b99411e0dfe956a42b Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 18 Feb 2010 16:43:47 +0000 Subject: [PATCH] --- yaml --- r: 185206 b: refs/heads/master c: d9661adfb8e53a7647360140af3b92284cbe52d4 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/char/tty_buffer.c | 6 ++++-- trunk/include/linux/tty.h | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 55c40ce9bf37..e2bcc158f5e4 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 4165fe4ef7305609a96c7f248cefb9c414d0ede5 +refs/heads/master: d9661adfb8e53a7647360140af3b92284cbe52d4 diff --git a/trunk/drivers/char/tty_buffer.c b/trunk/drivers/char/tty_buffer.c index 66fa4e10d76b..f27c4d6d956e 100644 --- a/trunk/drivers/char/tty_buffer.c +++ b/trunk/drivers/char/tty_buffer.c @@ -247,7 +247,8 @@ int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, { int copied = 0; do { - int space = tty_buffer_request_room(tty, size - copied); + int goal = min(size - copied, TTY_BUFFER_PAGE); + int space = tty_buffer_request_room(tty, goal); struct tty_buffer *tb = tty->buf.tail; /* If there is no space then tb may be NULL */ if (unlikely(space == 0)) @@ -283,7 +284,8 @@ int tty_insert_flip_string_flags(struct tty_struct *tty, { int copied = 0; do { - int space = tty_buffer_request_room(tty, size - copied); + int goal = min(size - copied, TTY_BUFFER_PAGE); + int space = tty_buffer_request_room(tty, goal); struct tty_buffer *tb = tty->buf.tail; /* If there is no space then tb may be NULL */ if (unlikely(space == 0)) diff --git a/trunk/include/linux/tty.h b/trunk/include/linux/tty.h index 6abfcf5b5887..d96e5882f129 100644 --- a/trunk/include/linux/tty.h +++ b/trunk/include/linux/tty.h @@ -68,6 +68,16 @@ struct tty_buffer { unsigned long data[0]; }; +/* + * We default to dicing tty buffer allocations to this many characters + * in order to avoid multiple page allocations. We assume tty_buffer itself + * is under 256 bytes. See tty_buffer_find for the allocation logic this + * must match + */ + +#define TTY_BUFFER_PAGE ((PAGE_SIZE - 256) / 2) + + struct tty_bufhead { struct delayed_work work; spinlock_t lock;