From patchwork Fri Oct 6 11:17:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Levin, Alexander \(Sasha Levin\)" X-Patchwork-Id: 115053 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1249142edb; Fri, 6 Oct 2017 04:22:54 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCqmMdG+v/iXsILvPiFfP8p19Ap5RyaxLv8A/eE4XErKpsFJgPnqQOMx7mGP56RFX7F1QF6 X-Received: by 10.101.74.206 with SMTP id c14mr1769697pgu.190.1507288829477; Fri, 06 Oct 2017 04:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507288829; cv=none; d=google.com; s=arc-20160816; b=WaENAJWrvh17zoNfbdfF8sSVw2cDTr3Npf3lgh1SK2R2f/esDM89NeB675VEUh6hru 51sTLRwbt/EFxNAJVvjYp+KCrWKAMc7kksPtY4pigomZSBZQpJ2JIjonL603NbhuYTKU 7qomYANxAvkme42Hnf1F6kelWHsmmcN1C0rsTEkNskzwa4JtBIo1vOMuXWwDtpzQ2/Cg ly9C1bGmI67Q/5CdNu91GPpGLK40Tga9Ypq/ihxb94XxYu5CseJEB6B3EUWwqTpeAA4v gRmZtGyXh03wDz943uGEYfMUT6cX/M6fSM2WrnHOKH4VIfBcsK4x5QriTc6AwATQ4M9P pkug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:dkim-signature :dkim-signature:cc:from:dkim-signature:arc-authentication-results; bh=t5dp+wGEM/aRzim34eRqKs2r0xRPM718a06yaSlLXKc=; b=N5I5o6mtYsI+aYG/ty/5ZGjo2xr51gX67zgyzoFc1/M5MfAQ8R6JzV/z7TZ50Y5uhT iFFM5i34ffQb4Bw90eA5/AXp7NwHnACo6p52n2VWj/7TBEcrxpInwiS1fLKL3OGiaQUb 1FpcwiWBuaYxav1chOGwgvi3qdsJNyFbMljpHaAr9E16h6Xi7bAIbHWyCwiExaP/EnVb grADxWYAuzRH2vX8H6TnLQhAwUu63X401I2ETDwmyjczqJRlFpGNchMh6jKePUT9G6ZT 0yC+J+YOBPeVwqm3fBdH10qNQVYc4PmcxdohMKJ5gmpqT2k7nBMyimHY/LgTXy2xUBQb G13w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verizon.com header.s=corp header.b=FHENKVRx; dkim=fail header.i=@verizon.com header.s=corp header.b=tS5GS1PZ; dkim=fail header.i=@verizon.com header.s=corp header.b=tS5GS1PZ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si954507pgu.126.2017.10.06.04.20.29; Fri, 06 Oct 2017 04:20:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@verizon.com header.s=corp header.b=FHENKVRx; dkim=fail header.i=@verizon.com header.s=corp header.b=tS5GS1PZ; dkim=fail header.i=@verizon.com header.s=corp header.b=tS5GS1PZ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752065AbdJFLU0 (ORCPT + 8 others); Fri, 6 Oct 2017 07:20:26 -0400 Received: from omzsmtpe03.verizonbusiness.com ([199.249.25.208]:54675 "EHLO omzsmtpe03.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752149AbdJFLUW (ORCPT ); Fri, 6 Oct 2017 07:20:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1507288822; x=1538824822; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=hRCc3kkkmpKloh4PawmZ8LDNImNf9HyTeSPnK/Zfle8=; b=FHENKVRxYD5Kqk6BzYG5sw0vlrE5XAjHxXwEGA51uf6xjnEd4Lco90DH ubWI2bRtvTqPamjk0yWA2ezEvUFlViTelsZjrdRLr2njosJUucsJ/CD0z HofJ5q3blQpNZ8Jx1syrqQ2hM1TyGFci2EXwSLlBfHwctzzq/FnNXmDu8 4=; Received: from unknown (HELO fldsmtpi02.verizon.com) ([166.68.71.144]) by omzsmtpe03.verizonbusiness.com with ESMTP; 06 Oct 2017 11:20:20 +0000 From: "Levin, Alexander (Sasha Levin)" Cc: Arnd Bergmann , Greg Kroah-Hartman , "Levin, Alexander (Sasha Levin)" Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO atlantis.verizonwireless.com) ([10.255.192.101]) by fldsmtpi02.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Oct 2017 11:19:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1507288793; x=1538824793; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=hRCc3kkkmpKloh4PawmZ8LDNImNf9HyTeSPnK/Zfle8=; b=tS5GS1PZkEO2x1gQfz1YnBWSPqBbEQI08s5O1M8zVPcsIoM4ogjDjP5S yy5VUZtVmvky0vENIHInt3o+QLEOfu4W2tuzTvzv7GjzyJGLp+dxIonEm MBDhyehIqSAePTSe45u7mhVeH3+utyAU2mDu8utyt5RAlsXFy45fyJyte w=; Received: from surveyor.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.83]) by atlantis.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Oct 2017 07:19:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1507288793; x=1538824793; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=hRCc3kkkmpKloh4PawmZ8LDNImNf9HyTeSPnK/Zfle8=; b=tS5GS1PZkEO2x1gQfz1YnBWSPqBbEQI08s5O1M8zVPcsIoM4ogjDjP5S yy5VUZtVmvky0vENIHInt3o+QLEOfu4W2tuzTvzv7GjzyJGLp+dxIonEm MBDhyehIqSAePTSe45u7mhVeH3+utyAU2mDu8utyt5RAlsXFy45fyJyte w=; X-Host: surveyor.tdc.vzwcorp.com Received: from ohtwi1exh003.uswin.ad.vzwcorp.com ([10.144.218.45]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 06 Oct 2017 11:19:52 +0000 Received: from tbwexch22apd.uswin.ad.vzwcorp.com (153.114.162.46) by OHTWI1EXH003.uswin.ad.vzwcorp.com (10.144.218.45) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 6 Oct 2017 07:19:52 -0400 Received: from OMZP1LUMXCA13.uswin.ad.vzwcorp.com (144.8.22.188) by tbwexch22apd.uswin.ad.vzwcorp.com (153.114.162.46) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Fri, 6 Oct 2017 07:19:52 -0400 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA13.uswin.ad.vzwcorp.com (144.8.22.188) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Fri, 6 Oct 2017 06:19:51 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Fri, 6 Oct 2017 06:19:51 -0500 To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" Subject: [added to the v4.1 stable tree] tty: improve tty_insert_flip_char() slow path Thread-Topic: [added to the v4.1 stable tree] tty: improve tty_insert_flip_char() slow path Thread-Index: AQHTPpS7vDJfY3k6IEKEo1WRV5Farg== Date: Fri, 6 Oct 2017 11:17:44 +0000 Message-ID: <20171006111704.25872-99-alexander.levin@verizon.com> References: <20171006111704.25872-1-alexander.levin@verizon.com> In-Reply-To: <20171006111704.25872-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann This patch has been added to the v4.1 stable tree. If you have any objections, please let us know. -- 2.11.0 =============== [ Upstream commit 065ea0a7afd64d6cf3464bdd1d8cd227527e2045 ] 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 Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 2843c2d4936d..1e485adf008a 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -369,10 +369,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;