Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1101666ybg; Tue, 2 Jun 2020 01:07:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3mtUEEZhuFA6vcWbemrzukqDUnySgCWn4wgYbxOHDSPLoXoIN+F3VB/m9fgZgbN5oEy7O X-Received: by 2002:a17:906:3b57:: with SMTP id h23mr10941236ejf.326.1591085265612; Tue, 02 Jun 2020 01:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591085265; cv=none; d=google.com; s=arc-20160816; b=mLbRpBHdCc5EKnw5rwKQRFxFpAAZoCeHcUyY6O9/dP944cjldWO+96ZaqtvL6PrMOB Y0fjY39PjFYNZBgEuMkb5u8uEpTdf5mt2CGlDwBpqTlTSELJwxXkkDtpFo6BOu+E/FMV UCLVJMrhjbUf9qX70NJBf7YtVZc+6W+v9zMGEJLIKCcSmuReQXqU1LFaANrh7DuX/1sg pn879qShRkn6ht53ygVJNahnr+D9FRCYeG7lBkVwUJuBLD9ULAiaWAWTV0CYCNYgnH2p O5+DEg2TEwlSYYRcVYKJoVxLa4uiqqrCf/NkvpeNx5M+0+EgBe8X72N7WGr0XP8cz5JS BeZw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=VmsAWnP0O08xC6A5/1RKLXXMeARPygzzyLJjjBOAChY=; b=jU9/UJthj7fWnalBcO7ikfgtkGcHtECnMd2Z27Y31V72NwNkH0KqSgdgFtJeFEhwz3 a11DTKaZPPAK5OAfuf9LfMehrlen9oD6Uk5sKvEGN0U3RPQS7snKKYj6V1ZgHZIGLd1o Oyn+8vNRvsjD+jOjkreGNGcaa91jjPjLmlaJrRwH+17b03ByjwGh14GwPFRwLCJzlkst Q1ccH5vAoA8Quusjbmix2w4CvNVoPiCPn1dWwX3mMnUH6tCH81Nek+cs9JM1OYtcnM/5 cnFvoVHGS3G+5QTJlkIGqiJwF+fe5yj8NFH44G7R/hPdSL8Gw4yL0Wn0FUsGIvbz6gql 8/4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QDtXRSN+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de22si1133720edb.242.2020.06.02.01.07.22; Tue, 02 Jun 2020 01:07:45 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=QDtXRSN+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726315AbgFBIFA (ORCPT + 99 others); Tue, 2 Jun 2020 04:05:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbgFBIFA (ORCPT ); Tue, 2 Jun 2020 04:05:00 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26FAAC061A0E; Tue, 2 Jun 2020 01:05:00 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id b201so595469pfb.0; Tue, 02 Jun 2020 01:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VmsAWnP0O08xC6A5/1RKLXXMeARPygzzyLJjjBOAChY=; b=QDtXRSN+kdE4n7U+lfSCk+i6qwtZE06oSr5hlb9glQkQu5gzoyG8WNElhPTGX7Bz9r bO8MYBypauImxehYw9HTibVqrdKSfLsUNAanIieDIarNpuntaMqiNpeKRaE+hWeEbI9F DgkPF+OzsCNzSEBbDXQ5y2j2S2MwFpyqhC4HyTnVCS15ZV8RWZvZ9CUYn3pDU8291U2x /ACXph1uR2Dn0CnriE+lV9PVtcAl+4CmIc6oaAZkZxJW9plcMr8WGaTojaQQdLgtL1MD UKOd4n0YMuEfvzo9rC/zUCJvfs4vSg7rwc0q2XlirtMLufYDKEpRcJnzOGHRqxH3NRcq iM+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VmsAWnP0O08xC6A5/1RKLXXMeARPygzzyLJjjBOAChY=; b=hgltD1hVcnK45awcR3KymCmZs50axeR6UZ0kwvboyvKLNWdqj3jtZnm0IJD2uu6Zyf rhd6FAw3ckZgjfqrIdeMSPmenLn9juIEHiEYWVhTv9oxy3HSxz2nb5OQ80makuTm6eLB BXkU2NPpUOcaIiA1hyJvurY5z8Ai4I3qFFnEHnBlpLEFojrQa/oUU08huFjzfecl3R7J Aj/jGRnkEAW940rClmcfijQ5amIJjsMkkCATNBUcvb6KrH1ZSjYI6qPtXZaArbPVETSE oTS9StbEMoFTtsAEjcfZ5Pm5oRRebpGouvJKmhw0YHHzHERabA5SR0/vYfc6BdatO468 YFKA== X-Gm-Message-State: AOAM533ZNoaL60kFmNOS3ehIvEARwcBIon9DiUsKVIWArS19YslGiZZr wrA2GUwewrjBvTEYztyf9vY= X-Received: by 2002:aa7:93ac:: with SMTP id x12mr26297388pff.143.1591085099727; Tue, 02 Jun 2020 01:04:59 -0700 (PDT) Received: from localhost.localdomain ([45.192.173.250]) by smtp.gmail.com with ESMTPSA id j7sm1545305pfh.154.2020.06.02.01.04.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2020 01:04:58 -0700 (PDT) From: kerneljasonxing@gmail.com To: edumazet@google.com, davem@davemloft.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, linux-kernel@vger.kernel.org, liweishi@kuaishou.com, lishujin@kuaishou.com Subject: [PATCH] tcp: fix TCP socks unreleased in BBR mode Date: Tue, 2 Jun 2020 16:04:25 +0800 Message-Id: <20200602080425.93712-1-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Xing TCP socks cannot be released because of the sock_hold() increasing the sk_refcnt in the manner of tcp_internal_pacing() when RTO happens. Therefore, this situation could increase the slab memory and then trigger the OOM if the machine has beening running for a long time. This issue, however, can happen on some machine only running a few days. We add one exception case to avoid unneeded use of sock_hold if the pacing_timer is enqueued. Reproduce procedure: 0) cat /proc/slabinfo | grep TCP 1) switch net.ipv4.tcp_congestion_control to bbr 2) using wrk tool something like that to send packages 3) using tc to increase the delay in the dev to simulate the busy case. 4) cat /proc/slabinfo | grep TCP 5) kill the wrk command and observe the number of objects and slabs in TCP. 6) at last, you could notice that the number would not decrease. Signed-off-by: Jason Xing Signed-off-by: liweishi Signed-off-by: Shujin Li --- net/ipv4/tcp_output.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index cc4ba42..5cf63d9 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -969,7 +969,8 @@ static void tcp_internal_pacing(struct sock *sk, const struct sk_buff *skb) u64 len_ns; u32 rate; - if (!tcp_needs_internal_pacing(sk)) + if (!tcp_needs_internal_pacing(sk) || + hrtimer_is_queued(&tcp_sk(sk)->pacing_timer)) return; rate = sk->sk_pacing_rate; if (!rate || rate == ~0U) -- 1.8.3.1