Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4824299ybl; Wed, 22 Jan 2020 05:26:34 -0800 (PST) X-Google-Smtp-Source: APXvYqxKuGlXelKCCXxEYZWFshJgKKiQOde3RAOG5hejwWm4YKXMPb8aIv2JT5BL2rvA7v+hLcwp X-Received: by 2002:aca:b7c5:: with SMTP id h188mr6735708oif.100.1579699594399; Wed, 22 Jan 2020 05:26:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699594; cv=none; d=google.com; s=arc-20160816; b=iOmmfxbhtEmJDMDPD0Hf0rQLFQRLrb2p22ClBSdKdiyo0k1t+KNpg1v0rKowuDLREF IvdpnIVxDTgSHT3mqdDx81eLzyQCKHzIIFi5QxGrntM3pxEHpoFIc5gI0oMjHugepZUr OV4cp87PfJy+SmbPXUcanJUYMOr3/hMZylAmcP00gSsRMbxst6jXrvtyrKgmMLGylQlf 5zdcKkvypHf5cPSdQBDXgM351xNIb+pptTeKH8YjH3q/f05tHWfrcEew554RRwZnPzmm TRmy3QsDmk87p8WTuZodVWUdRkLqm5qR5EaeP9YA9qnu37CjfzsaLH0BFbLvilmksOT2 K52g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=11cvUjzoHalDQBOHbE8JOzMuIO0wqllfRIcyH8Oc9U4=; b=GKXKxCPKoAZhEwhnFT6d3W/N1NS+jqs6fOiDtWBotO0LSCAMVPno2BJZuh3ovGby6g wsZb2V4btSxw22IaTNhXkS0TXAdrbBcQJOUfV2rBRv+BguJYC9QQhfISyP5ZytoVOsqP KJTgvz8YNBUbyXtUz6GB78vdVMTqtlKse4WZt49/hU9NrGc7spP9PiSfZg7CnwTQW4z6 m/pr3SL318uILFpUMzLK2wYT4DW2n1/S/rQrGfuMGEVPhPeGkZ5mhFgJVmvMM+aYZ8PC vAFmBHnWqy5/64BxdgAHuAd6VNqEGjoS2l419q5XD7B/vQx23GZWUM6voxM2TKT2NYqs XR9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="2NbWu/Qx"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h28si27001183otg.63.2020.01.22.05.26.22; Wed, 22 Jan 2020 05:26:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b="2NbWu/Qx"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730964AbgAVNZa (ORCPT + 99 others); Wed, 22 Jan 2020 08:25:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:45452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730443AbgAVNZ1 (ORCPT ); Wed, 22 Jan 2020 08:25:27 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E66A2467B; Wed, 22 Jan 2020 13:25:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699525; bh=7vA9ZW7WwkHccEel+n+5U8Okkd7rnOSnouieo2fX4dQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2NbWu/QxB+9cKpPAiB9CrGykhIv1CELD0/+b15KUyysEAwVD6os8WMf2vxAAlzrZv lwhC7HYPHSvY+DtKx4yVKHIlHGPI+wLYATw2/d8t4L70eWiteHLUqp5zDvEuFTYs3n 9meWUiReIJRI96l9i3vCVQlmndxe2y07MgU9KNFI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Jason Baron , Neal Cardwell , Soheil Hassas Yeganeh , Jakub Kicinski Subject: [PATCH 5.4 172/222] tcp: refine rule to allow EPOLLOUT generation under mem pressure Date: Wed, 22 Jan 2020 10:29:18 +0100 Message-Id: <20200122092846.021033976@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet commit 216808c6ba6d00169fd2aa928ec3c0e63bef254f upstream. At the time commit ce5ec440994b ("tcp: ensure epoll edge trigger wakeup when write queue is empty") was added to the kernel, we still had a single write queue, combining rtx and write queues. Once we moved the rtx queue into a separate rb-tree, testing if sk_write_queue is empty has been suboptimal. Indeed, if we have packets in the rtx queue, we probably want to delay the EPOLLOUT generation at the time incoming packets will free them, making room, but more importantly avoiding flooding application with EPOLLOUT events. Solution is to use tcp_rtx_and_write_queues_empty() helper. Fixes: 75c119afe14f ("tcp: implement rb-tree based retransmit queue") Signed-off-by: Eric Dumazet Cc: Jason Baron Cc: Neal Cardwell Acked-by: Soheil Hassas Yeganeh Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1087,8 +1087,7 @@ do_error: goto out; out_err: /* make sure we wake any epoll edge trigger waiter */ - if (unlikely(skb_queue_len(&sk->sk_write_queue) == 0 && - err == -EAGAIN)) { + if (unlikely(tcp_rtx_and_write_queues_empty(sk) && err == -EAGAIN)) { sk->sk_write_space(sk); tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED); } @@ -1419,8 +1418,7 @@ out_err: sock_zerocopy_put_abort(uarg, true); err = sk_stream_error(sk, flags, err); /* make sure we wake any epoll edge trigger waiter */ - if (unlikely(skb_queue_len(&sk->sk_write_queue) == 0 && - err == -EAGAIN)) { + if (unlikely(tcp_rtx_and_write_queues_empty(sk) && err == -EAGAIN)) { sk->sk_write_space(sk); tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED); }