]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.52/tty-improve-tty_insert_flip_char-slow-path.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.52 / tty-improve-tty_insert_flip_char-slow-path.patch
1 From 065ea0a7afd64d6cf3464bdd1d8cd227527e2045 Mon Sep 17 00:00:00 2001
2 From: Arnd Bergmann <arnd@arndb.de>
3 Date: Tue, 20 Jun 2017 23:10:42 +0200
4 Subject: tty: improve tty_insert_flip_char() slow path
5
6 From: Arnd Bergmann <arnd@arndb.de>
7
8 commit 065ea0a7afd64d6cf3464bdd1d8cd227527e2045 upstream.
9
10 While working on improving the fast path of tty_insert_flip_char(),
11 I noticed that by calling tty_buffer_request_room(), we needlessly
12 move to the separate flag buffer mode for the tty, even when all
13 characters use TTY_NORMAL as the flag.
14
15 This changes the code to call __tty_buffer_request_room() with the
16 correct flag, which will then allocate a regular buffer when it rounds
17 out of space but no special flags have been used. I'm guessing that
18 this is the behavior that Peter Hurley intended when he introduced
19 the compacted flip buffers.
20
21 Fixes: acc0f67f307f ("tty: Halve flip buffer GFP_ATOMIC memory consumption")
22 Cc: Peter Hurley <peter@hurleysoftware.com>
23 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26 ---
27 drivers/tty/tty_buffer.c | 5 +++--
28 1 file changed, 3 insertions(+), 2 deletions(-)
29
30 --- a/drivers/tty/tty_buffer.c
31 +++ b/drivers/tty/tty_buffer.c
32 @@ -375,10 +375,11 @@ int __tty_insert_flip_char(struct tty_po
33 struct tty_buffer *tb = port->buf.tail;
34 int flags = (flag == TTY_NORMAL) ? TTYB_NORMAL : 0;
35
36 - if (!tty_buffer_request_room(port, 1))
37 + if (!__tty_buffer_request_room(port, 1, flags))
38 return 0;
39
40 - *flag_buf_ptr(tb, tb->used) = flag;
41 + if (~tb->flags & TTYB_NORMAL)
42 + *flag_buf_ptr(tb, tb->used) = flag;
43 *char_buf_ptr(tb, tb->used++) = ch;
44
45 return 1;