From patchwork Tue Jun 20 21:10:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9800279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E047A6038C for ; Tue, 20 Jun 2017 21:13:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC7AB20408 for ; Tue, 20 Jun 2017 21:13:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C126D274D2; Tue, 20 Jun 2017 21:13:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B31D920408 for ; Tue, 20 Jun 2017 21:13:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752529AbdFTVMv (ORCPT ); Tue, 20 Jun 2017 17:12:51 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:52422 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752477AbdFTVMt (ORCPT ); Tue, 20 Jun 2017 17:12:49 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MSDsY-1dD4KR03cg-00THMG; Tue, 20 Jun 2017 23:11:29 +0200 From: Arnd Bergmann To: Greg Kroah-Hartman , Jiri Slaby Cc: Dmitry Torokhov , kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , linux-kernel@vger.kernel.org, Samuel Thibault , linux-serial@vger.kernel.org, linux-input@vger.kernel.org, Peter Hurley , Arnd Bergmann , Rob Herring , Andy Shevchenko Subject: [PATCH 2/2] tty: improve tty_insert_flip_char() slow path Date: Tue, 20 Jun 2017 23:10:42 +0200 Message-Id: <20170620211112.1490310-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170620211112.1490310-1-arnd@arndb.de> References: <20170620211112.1490310-1-arnd@arndb.de> X-Provags-ID: V03:K0:p768unSm4pTaCqM1pPoUpe1U4tclsF4qKXLra8y4i7kHkGkjAdl 5hH5eese1L8amegtN1Cew5i4tDi7l33kwirz5LB8dR5d/UC1hnMcRatkzMiKJRon1hy7YVp xUmXRh+AyQrlFqi+ZkScyPRlzz9OzzJ8VMb6dfTDP/wHzs/85j1/Hzx4Mq7bfnSLyrkLszt 860zbxNQVp8kEQ0zCgPFw== X-UI-Out-Filterresults: notjunk:1; V01:K0:eIq/A6mgN28=:1V3Ci8gikueRt25/DAmkGz 6Afq7uAgfrXKiTB4MpP8I4e/ef36auJZYZ7cHkC/GX0NSucnHtma/5DVdcyALnbtssnnplwOv BesnbAyPzZ4TxVWdZZkB4j/ir+m/i19Kzjs16wDuqu2rujGQX550jXAy/278PjbwqHGdMV3Yt Hah89kD6bwTamiAo7dn3A9q14//vC44mqxzspOPk95O5p9knt+awFOiyGSSQ7tDRJAvwY4cBr kDsLw/BmXyc+YGvfh1XrSGRxsEnvEaRC6sjzOMBkcQhU2LVzRsXr8fKv9ZUopGkmNX4iBVU6x 1GEkA7vEEASxgInD1XSJMZ/vwBsvYMw0sq2sjQmP0aV5+iDcW8nf2gkULC/pC8m9XxzM/XMao EBGAl/lmSuWq8196fvwskv5VsGCAP4irkklk/WgckxZemnzVYAs27sWdzIgvtKisGjnQDv3ca Mi20poxdG+pHOUh0cZnhfAcbEZyxNwWv3mav4qHR2kBfVBHvmjypBTK7ZgcqqDmJ3QMRyIc8i LK+qGrYUuzxsjX3d1TEhM13EM1T9Nrrettb9/ka85RDg0Gnmiuakacm6M/xLzgGQA7cPjZUMl atZunZ/GHvruB/l4oyskB60KoQSFnKb4biLFoncxaPIFcrSeRomgd+UJiarRW1qnzCBJK7xAW h8+FKluLiHioaciweD2TRgsrUg6mD7cS+tsPQK3DCETK9O8CZNaqIc7poaMmh+WfE74g= Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While working on improving the fast path of tty_insert_flip_char(), I noticed that by calling tty_buffer_request_room(), we needlessly move to the separate flag buffer mode for the tty, even when all characters use TTY_NORMAL as the flag. This changes the code to call __tty_buffer_request_room() with the correct flag, which will then allocate a regular buffer when it rounds out of space but no special flags have been used. I'm guessing that this is the behavior that Peter Hurley intended when he introduced the compacted flip buffers. Fixes: acc0f67f307f ("tty: Halve flip buffer GFP_ATOMIC memory consumption") Cc: Peter Hurley Signed-off-by: Arnd Bergmann --- This patch is just based on my reading of the source code, it's possible that I missed something and the previous behavior was intentional, so please review carefully. --- drivers/tty/tty_buffer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 2da05fa37aec..6a8563633d4b 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -375,10 +375,11 @@ int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag) struct tty_buffer *tb = port->buf.tail; int flags = (flag == TTY_NORMAL) ? TTYB_NORMAL : 0; - if (!tty_buffer_request_room(port, 1)) + if (!__tty_buffer_request_room(port, 1, flags)) return 0; - *flag_buf_ptr(tb, tb->used) = flag; + if (~tb->flags & TTYB_NORMAL) + *flag_buf_ptr(tb, tb->used) = flag; *char_buf_ptr(tb, tb->used++) = ch; return 1;