From patchwork Tue Jun 30 20:51:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 216764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.6 required=3.0 tests=DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98BEEC433E0 for ; Tue, 30 Jun 2020 20:51:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 629AC20702 for ; Tue, 30 Jun 2020 20:51:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PyelTbsC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726219AbgF3Uvc (ORCPT ); Tue, 30 Jun 2020 16:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgF3Uvb (ORCPT ); Tue, 30 Jun 2020 16:51:31 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A11B4C061755 for ; Tue, 30 Jun 2020 13:51:31 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id h30so15291306qtb.7 for ; Tue, 30 Jun 2020 13:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=a8Mna9JvTOrVKn6Q1hMZon3VYM7qkCojbUu1upW8NtY=; b=PyelTbsCd7F7Y1Rpa56IhJz/ojjwC6zoG9nmXSMpk2vU1wGTV1hUTOBxsEidPjcKvs f6BN406O53SPpAIqiWLWDCwjkJvgNEVxOCkvIMM+zYnckOOIRsSHkAjvP+LECdkUuA8x 6fB4/9S4DuHA94Nc/hlBO60XV0lZEUKtXVHcszbdvEgIxL7D1rl1Dm7majn6WGW+0JA+ 7THIYirx/jueV8D6aYYG60tuhtmcTtAoMsoKSNslzlnmlHbvUX5zDfJsdn6BObYXRmmu tPfcWF6rjpEIglmH6wsEU8C7ik36nibDi2Sn4ng/Ro9KQ6P78ErIqTj5fohl2Ph1Kqb+ 6mpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=a8Mna9JvTOrVKn6Q1hMZon3VYM7qkCojbUu1upW8NtY=; b=ge8jVITJwH1hdsOjfMAvjo+y7eC4wqGyTLgW4teOlXjpOEXVsQFHopK9EkI20Gt5i0 MPMgmO038yINvX2o8XTspEEGr/OEABy7IfJJbt1clx8eIkpHDRtFBTSiCXFcVjpq/jd7 GI+Dob5xfkjomCvwfnaOJSByYOJrOCj2WpG6Y8n/H4vZAaqgW0epS3hSybWnXSDfOVB3 yeNiz0OMduF19x54wU3bYhbcdF6Uryp1A6KcocfXBIwoVKbGBv1mxpbzgo/M9M7vH3U+ 89HhvUyFOkS5TwHy7918Nrb3tSADXfH9iHghtJcO1OvBLgqZmltOEqDMCht3CYkfvgN7 XSOg== X-Gm-Message-State: AOAM533p/Xk2TC71MbBG31Kq2JZhQytqQBd/ok3sZi0WeOuD03HWXX9h e6QaD9Qe37ZM+B6Gs0ioxim5k9zq4CNWGQ== X-Google-Smtp-Source: ABdhPJw3abcUm3vvpABx6WRyLQ1bJ/kWVSEK8IvnNYtX//Yiphey9ETFrsl9t+NeIw9M3HC0zYLTwMHEdhPIPQ== X-Received: by 2002:ad4:57b2:: with SMTP id g18mr21641219qvx.207.1593550290775; Tue, 30 Jun 2020 13:51:30 -0700 (PDT) Date: Tue, 30 Jun 2020 13:51:28 -0700 Message-Id: <20200630205128.3162961-1-edumazet@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH net] tcp: fix SO_RCVLOWAT possible hangs under high mem pressure From: Eric Dumazet To: "David S . Miller" Cc: netdev , Eric Dumazet , Eric Dumazet Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Whenever tcp_try_rmem_schedule() returns an error, we are under trouble and should make sure to wakeup readers so that they can drain socket queues and eventually make room. Fixes: 03f45c883c6f ("tcp: avoid extra wakeups for SO_RCVLOWAT users") Signed-off-by: Eric Dumazet --- net/ipv4/tcp_input.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index f3a0eb139b7633ebc1ddb801de232bcd3a0cbdc6..9615e72656d12e9c7298bf7087792d0209897b50 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4582,6 +4582,7 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) if (unlikely(tcp_try_rmem_schedule(sk, skb, skb->truesize))) { NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFODROP); + sk->sk_data_ready(sk); tcp_drop(sk, skb); return; } @@ -4828,6 +4829,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) sk_forced_mem_schedule(sk, skb->truesize); else if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) { NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRCVQDROP); + sk->sk_data_ready(sk); goto drop; }