aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/tty_buffer.c6
-rw-r--r--include/linux/tty.h10
2 files changed, 14 insertions, 2 deletions
diff --git a/drivers/char/tty_buffer.c b/drivers/char/tty_buffer.c
index 66fa4e10d76b..f27c4d6d956e 100644
--- a/drivers/char/tty_buffer.c
+++ b/drivers/char/tty_buffer.c
@@ -247,7 +247,8 @@ int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars,
247{ 247{
248 int copied = 0; 248 int copied = 0;
249 do { 249 do {
250 int space = tty_buffer_request_room(tty, size - copied); 250 int goal = min(size - copied, TTY_BUFFER_PAGE);
251 int space = tty_buffer_request_room(tty, goal);
251 struct tty_buffer *tb = tty->buf.tail; 252 struct tty_buffer *tb = tty->buf.tail;
252 /* If there is no space then tb may be NULL */ 253 /* If there is no space then tb may be NULL */
253 if (unlikely(space == 0)) 254 if (unlikely(space == 0))
@@ -283,7 +284,8 @@ int tty_insert_flip_string_flags(struct tty_struct *tty,
283{ 284{
284 int copied = 0; 285 int copied = 0;
285 do { 286 do {
286 int space = tty_buffer_request_room(tty, size - copied); 287 int goal = min(size - copied, TTY_BUFFER_PAGE);
288 int space = tty_buffer_request_room(tty, goal);
287 struct tty_buffer *tb = tty->buf.tail; 289 struct tty_buffer *tb = tty->buf.tail;
288 /* If there is no space then tb may be NULL */ 290 /* If there is no space then tb may be NULL */
289 if (unlikely(space == 0)) 291 if (unlikely(space == 0))
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 6abfcf5b5887..d96e5882f129 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -68,6 +68,16 @@ struct tty_buffer {
68 unsigned long data[0]; 68 unsigned long data[0];
69}; 69};
70 70
71/*
72 * We default to dicing tty buffer allocations to this many characters
73 * in order to avoid multiple page allocations. We assume tty_buffer itself
74 * is under 256 bytes. See tty_buffer_find for the allocation logic this
75 * must match
76 */
77
78#define TTY_BUFFER_PAGE ((PAGE_SIZE - 256) / 2)
79
80
71struct tty_bufhead { 81struct tty_bufhead {
72 struct delayed_work work; 82 struct delayed_work work;
73 spinlock_t lock; 83 spinlock_t lock;