Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp822166pxb; Tue, 3 Nov 2020 13:31:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWCPmHMmBdKfBzG2jtN3iwDBoeh7Y5hNabJ1Q4Ll63n/RHrU6lMv1iunmDF/hfC8fi2bvl X-Received: by 2002:a50:c058:: with SMTP id u24mr9895391edd.28.1604439107243; Tue, 03 Nov 2020 13:31:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439107; cv=none; d=google.com; s=arc-20160816; b=Xyb1tUYPq+BqpSlCK1K01K7tKYfS21muictYje9D3QLm6ehyoXYvIJDs+5IzQGtTfd Wdko9GV7Yqvox4NVJ8JZWgSQUJzkxiNOvx6C9wJ87GlXsSrF6jNpHg698/eCTPw4jurX LF2my+0u7hZw0poLATbrAVb+s0Lse5HM5YXXp3NxKhH70Ezlm940LYDmGeMMLp7gb34i BIevRVV4iOyukrpDD0sfssYDHw188Ir/EKgtsCZL70VG5vkvr8CPqzPXfdCGQURDdw/U 48gnG9rRCx954OJ/ESs6wM9nEUsvsV/2kuI/ocakI8j/jCgqx7T3ZWPgIYj/HJfRJNnk NexQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F5aLt6RqmJn6or58TcFCq+FVJXZtCBT4XrQ5JJzGMS4=; b=fKMpL80FP0OQ/HZ9FTst8jaChSefwFuNGTMUxipGuUAQzkw4Ba6BKiDMk/jFlE40W5 xYJzFr5l83k+EL8QmXCuhk8FI/HIwvw4dp9JOtsuhI7sjk8Fe97n5/YxhajMV/BCATdD 9yFFRjuRm8J26EAmmBbQ4FqdeFv96kXWaDY0LnR9k3R0xJtv/TUtSXzMoQQ1/E/AhCEU lPLG7ECgqbE6Romqz1TKSRGM2IiO5wXZrbCPCC4UXNLBRP4eGC1QdRsp427jx9vI0H5Y KGObgJmPdEf1Xg0XNDw0vStwZjlrZz9wamw9KezDZ4ky0wy+4cNVkxVeH9YIWTlLjjx+ xrrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qa8LsrS+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o12si4882838edz.429.2020.11.03.13.31.24; Tue, 03 Nov 2020 13:31:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qa8LsrS+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387468AbgKCV0q (ORCPT + 99 others); Tue, 3 Nov 2020 16:26:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:38152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387472AbgKCVBc (ORCPT ); Tue, 3 Nov 2020 16:01:32 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 2856E205ED; Tue, 3 Nov 2020 21:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437291; bh=0OvfmFAlz987AQXZ/djOmBuksh38zCwtL39I6TM7+xQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qa8LsrS+ZgL+I2ApZgx0YctJwnpI/4gGu2vZ9/oeUEROJYDKZgpIjkbeEVgML/F4d ZhccGLGbkR+khlzBUfryGhv0wkg+N0zcW7Qs2K7t9geiVQk9j2m8a58vW2MHtLgNPD 1k9xbodp0pXIdQioJfc+3HK3umu2JBZDRBNvYj4U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arjun Roy , Soheil Hassas Yeganeh , Neal Cardwell , Eric Dumazet , Jakub Kicinski Subject: [PATCH 4.19 014/191] tcp: Prevent low rmem stalls with SO_RCVLOWAT. Date: Tue, 3 Nov 2020 21:35:06 +0100 Message-Id: <20201103203234.529152657@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arjun Roy [ Upstream commit 435ccfa894e35e3d4a1799e6ac030e48a7b69ef5 ] With SO_RCVLOWAT, under memory pressure, it is possible to enter a state where: 1. We have not received enough bytes to satisfy SO_RCVLOWAT. 2. We have not entered buffer pressure (see tcp_rmem_pressure()). 3. But, we do not have enough buffer space to accept more packets. In this case, we advertise 0 rwnd (due to #3) but the application does not drain the receive queue (no wakeup because of #1 and #2) so the flow stalls. Modify the heuristic for SO_RCVLOWAT so that, if we are advertising rwnd<=rcv_mss, force a wakeup to prevent a stall. Without this patch, setting tcp_rmem to 6143 and disabling TCP autotune causes a stalled flow. With this patch, no stall occurs. This is with RPC-style traffic with large messages. Fixes: 03f45c883c6f ("tcp: avoid extra wakeups for SO_RCVLOWAT users") Signed-off-by: Arjun Roy Acked-by: Soheil Hassas Yeganeh Acked-by: Neal Cardwell Signed-off-by: Eric Dumazet Link: https://lore.kernel.org/r/20201023184709.217614-1-arjunroy.kdev@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp.c | 2 ++ net/ipv4/tcp_input.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -495,6 +495,8 @@ static inline bool tcp_stream_is_readabl return true; if (tcp_rmem_pressure(sk)) return true; + if (tcp_receive_window(tp) <= inet_csk(sk)->icsk_ack.rcv_mss) + return true; } if (sk->sk_prot->stream_memory_read) return sk->sk_prot->stream_memory_read(sk); --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4704,7 +4704,8 @@ void tcp_data_ready(struct sock *sk) int avail = tp->rcv_nxt - tp->copied_seq; if (avail < sk->sk_rcvlowat && !tcp_rmem_pressure(sk) && - !sock_flag(sk, SOCK_DONE)) + !sock_flag(sk, SOCK_DONE) && + tcp_receive_window(tp) > inet_csk(sk)->icsk_ack.rcv_mss) return; sk->sk_data_ready(sk);