From patchwork Sat Aug 17 16:33:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingrui Zhang X-Patchwork-Id: 13767202 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C4AE225A2 for ; Sat, 17 Aug 2024 16:35:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723912522; cv=none; b=OmbESGCYsb/Pt385k6/VnFi11O0vDR+9uq+jWN1kAO2T4FtOiMJaCQk12cwc5ffPyvqidnV5tpZP1CyiLQXv1qljk/LQQviHF5prd4TN50MXyBxGODKSP0DO4vXLWRvwTUhys2gMoLtHNBZoda9q2YoNu8JRHmLwEKnGTnInKOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723912522; c=relaxed/simple; bh=q62qOtdxsv9W57eQq5osDzNkxZ8lZ6FUDU9zrCoO/ag=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sELJBxmuZLa6BXJ/9akqZ2f+t2LJTOr2yfAyDXz3oOo5kB25wlSCpLCv9/tJ0DBPX2Y2PA+nbAdQzWUWZyWF8lRpEi4rtwj/JIRXrzwp7OwBbung5EnXBlj/L5FvrtaTzu+ufvq8F8Rs5Ic4g1gXpUFavYAxw7ROVhQ8K6y8TLk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bEl2KHgM; arc=none smtp.client-ip=209.85.219.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bEl2KHgM" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-6bf747371ecso12423806d6.3 for ; Sat, 17 Aug 2024 09:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723912520; x=1724517320; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z0VsA74EdKq55dTEa5TbNU4terTLqHKKcmInS2/omLc=; b=bEl2KHgMWN3e31CW4oZE/F1HR4Tneb0n0lMqK0+2F2hEklqWIhuV3PFOfYfbjz7zWB hpR5woth6Nj8vTeVm6YfP3ntW9/Lp5Ff1zIGXTlJkToRUTP13lpPF8gYikm9ATdVs/8D nzJdtAdHtEsxtZ00EljpC+vLbYc7diGMkdo55KG9CGaQIrVNFzV2DIzd0Za3ktVohYxL nwsrPiWeItfgtwXp+3nvgWWnEBD7g6VhHbl8hlt8cnm81M5W5ClrhbjnR4ZMJGmgYmH/ 3zzTxCTgSq7x61VpJqL3qiEDc/RIAyu9/2Y4Gg5P9gBCmgCb9AjZZL/Eqqu5KySbujFP +SPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723912520; x=1724517320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z0VsA74EdKq55dTEa5TbNU4terTLqHKKcmInS2/omLc=; b=ppWPttu6S1j4pBDt1W+Jpkv4qRGSwuxk86hvEe3tAKI1G5wLO3SO3qCEPDGS218iTw UKd7eG9QwapY2XGQm0BVCVp0XjUsQpWyEyC6LJXOOKj34qzS4sX7b1i/SymOGQ3E94fy Sdlg1S+Ql3P26/7eT1NXoUrJ47ZcXJR00Mqw9Y8P/k454/iqpn6MJcRn7AnbT7mPSTik bwGHV/dmyV7kkl1OWbRRXrIJlfL01xccjZwPAbKIK7eFfK4QBbGD8Q5H7+THhMgUDZQE z5W+INtEVSVKpudTuQBver97LolfepMk3WnuXsMrlCyG8/9y7ObRtZb6zmK3LQPJrowx 9VKA== X-Forwarded-Encrypted: i=1; AJvYcCWrcsxJr2h7scRaPLglPHR5IgnWQwLJ47HHRqIFEnoye0GcOk0DDo7t1CVucUa9fM5ApaMIfvIuK+F3IC0N6sTcSp7k5rTO X-Gm-Message-State: AOJu0YwNSI83bvOtHNJNqNo/b9TN8ggAiyqwHdY6RkscsAfRVDtWS7BY rb/t3LR3C1pnlACq0lN2WUY2WnZH0DfFKxeIPAgi/2QBcVTg+Bzn X-Google-Smtp-Source: AGHT+IFJ8+/wTtIQcrDnhWzhBncH3aC7aw+ywtD7rFJJb38WOKLOdIo5xmU3pXVOsu7tUCBtDtwBaw== X-Received: by 2002:a05:6214:590d:b0:6b7:9bdd:c5ac with SMTP id 6a1803df08f44-6bf7ce7c406mr65466546d6.54.1723912519940; Sat, 17 Aug 2024 09:35:19 -0700 (PDT) Received: from jshao-Precision-Tower-3620.tail18e7e.ts.net ([129.93.161.236]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bf6fef242esm28319406d6.118.2024.08.17.09.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 09:35:19 -0700 (PDT) From: Mingrui Zhang To: edumazet@google.com, davem@davemloft.net, ncardwell@google.com, netdev@vger.kernel.org Cc: Mingrui Zhang , Lisong Xu Subject: [PATCH net v4 1/3] tcp_cubic: fix to run bictcp_update() at least once per RTT Date: Sat, 17 Aug 2024 11:33:58 -0500 Message-Id: <20240817163400.2616134-2-mrzhang97@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240817163400.2616134-1-mrzhang97@gmail.com> References: <20240817163400.2616134-1-mrzhang97@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The original code bypasses bictcp_update() under certain conditions to reduce the CPU overhead. Intuitively, when last_cwnd==cwnd, bictcp_update() is executed 32 times per second. As a result, it is possible that bictcp_update() is not executed for several RTTs when RTT is short (specifically < 1/32 second = 31 ms and last_cwnd==cwnd which may happen in small-BDP networks), thus leading to low throughput in these RTTs. The patched code executes bictcp_update() 32 times per second if RTT > 31 ms or every RTT if RTT < 31 ms, when last_cwnd==cwnd. Fixes: df3271f3361b ("[TCP] BIC: CUBIC window growth (2.0)") Fixes: ac35f562203a ("tcp: bic, cubic: use tcp_jiffies32 instead of tcp_time_stamp") Signed-off-by: Mingrui Zhang Signed-off-by: Lisong Xu --- v3->v4: Replace min() with min_t() v2->v3: Correct the "Fixes:" footer content v1->v2: Separate patches net/ipv4/tcp_cubic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index 5dbed91c6178..00da7d592032 100644 --- a/net/ipv4/tcp_cubic.c +++ b/net/ipv4/tcp_cubic.c @@ -218,8 +218,12 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd, u32 acked) ca->ack_cnt += acked; /* count the number of ACKed packets */ + /* Update 32 times per second if RTT > 1/32 second, + * or every RTT if RTT < 1/32 second even when last_cwnd == cwnd + */ if (ca->last_cwnd == cwnd && - (s32)(tcp_jiffies32 - ca->last_time) <= HZ / 32) + (s32)(tcp_jiffies32 - ca->last_time) <= + min_t(s32, HZ / 32, usecs_to_jiffies(ca->delay_min))) return; /* The CUBIC function can update ca->cnt at most once per jiffy. From patchwork Sat Aug 17 16:33:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mingrui Zhang X-Patchwork-Id: 13767203 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBD21286A8 for ; Sat, 17 Aug 2024 16:35:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723912523; cv=none; b=gV4Kp2vSYOkmd/CeFmWBjK+w2al7VDtjJciujJbJM/aheIFJKVQf2JjowInUD7J/bOGUEeIIo3plRP5lqxN7jqt53M906642R7a5H+RYJxw8oFcgvITwVwgq/SZxtSO38WnzZxYnbvOu8x2DiWh6cYG5B+4ByonH4ShzRMQIJHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723912523; c=relaxed/simple; bh=vLIl8GE+gzXEacY/YHU67fNJq7szOq7C7NEdSXnOVt4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=E8NlbfIrch0L2YRPjMMDE8WQC9cA3qXSPobMWWOXSh5SZbJCa6nCnm25Jg7fUh4fSeOmZUN23EZI/wfU4m9OLyEQZM0186ZErQ17l1ToqYpbam9Fzfr5k9utYhW2DPUn9PYVqBHE+bqg2yGq7Hdo1IRJsYvY9Bo03xaVgOIfD50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XOMb5NMe; arc=none smtp.client-ip=209.85.219.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XOMb5NMe" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-6b78c980981so15862536d6.2 for ; Sat, 17 Aug 2024 09:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723912521; x=1724517321; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RY99jyEwDoh9G30LO2IWPeonxw6+Zj+rZoZ5Mtx/s8E=; b=XOMb5NMeNGjFmLn5IR41/Ia2NYuWQY3s0F38mHlsAjKTeVFhCJHCYmLgwvnSFQKkjV JLyWiSMXVRTw9FI4vgI96oTb68WJOEfwFJN8SBgguDHoiAb0Hb2v0voHnTABOh/SJJDw FeMW/Btf1aNggYxljMeOU6JcUIBorviUWa7NyGJE0Am5JSQBk2lxo8uLl4JzOnf+fcb+ klxqfrYNoBLeiKP0C2JaWkp2qk4Po+4Wqi3hxmWI84EJEnjA/oP2jf85azr/FwJRoW1i AfjFxetjXAUWpRsEwSbj6CcesukMWNIgsyrhsBqO+HBqe5DSDCbNWV2YbHg5NtUYbgZJ ioOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723912521; x=1724517321; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RY99jyEwDoh9G30LO2IWPeonxw6+Zj+rZoZ5Mtx/s8E=; b=gzR3Sg+8PCFkFx3NYv47fCQKulNMjTgb9/KpboqgRe8uodO4TnuOACoxXNBs5UF73C DwCe3UZ3NuJAbsfiBMEWrcNwih+EdSZjDBEVnzaniBj0jzzR+ZuM5RZo91k7NspjARPF rJWI/as5AzQgeYAOj/CIqlGAvetlS9jltlJOOLwxld1ozjSt9Qev+Rg47bifIoYuiMyW 6Qhryh8idqX/SNDLvc4DJxgoaFze0jf56M9CJap/3ZbuVCoOikeyBNTbuyqC6awqIbG9 t14Wqj4A83m1T0WyH1irmWsTIWUvr39FSXMlJIk1h5OzWgvdxsIcJ9hy/AzfrhxwLIgr sQzw== X-Forwarded-Encrypted: i=1; AJvYcCXUk2pCtgRxgEcG+kxxx/2/YB94eLmi4SE+EJUgD1C+7gvQEfDXDO2IoSBf5j9qF00iSXb86xdbAqPtt+98bxe1KlmGhm2u X-Gm-Message-State: AOJu0YzK8rI7vVCbU9+qSuPIBOMCR/q5LTTfQhPkpREOlX69aRlRzDSv sMwe2jveiTW8y6uUtFKA3klKiEXiagTOz85Y4Oh7FaMjyXAxvqdVnhD9SbwE X-Google-Smtp-Source: AGHT+IGIyJaezjhyUTom/w6tUGyfbMAG84Y/H3tYbwkotS7/mouJ6QiJqag0WdQMC/HI+BUC7ss1dA== X-Received: by 2002:a05:6214:5d0b:b0:6bf:69c2:1d39 with SMTP id 6a1803df08f44-6bf7cdca1ecmr126175296d6.7.1723912520820; Sat, 17 Aug 2024 09:35:20 -0700 (PDT) Received: from jshao-Precision-Tower-3620.tail18e7e.ts.net ([129.93.161.236]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bf6fef242esm28319406d6.118.2024.08.17.09.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 09:35:20 -0700 (PDT) From: Mingrui Zhang To: edumazet@google.com, davem@davemloft.net, ncardwell@google.com, netdev@vger.kernel.org Cc: Mingrui Zhang , Lisong Xu Subject: [PATCH net v4 2/3] tcp_cubic: fix to match Reno additive increment Date: Sat, 17 Aug 2024 11:33:59 -0500 Message-Id: <20240817163400.2616134-3-mrzhang97@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240817163400.2616134-1-mrzhang97@gmail.com> References: <20240817163400.2616134-1-mrzhang97@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The original code follows RFC 8312 (obsoleted CUBIC RFC). The patched code follows RFC 9438 (new CUBIC RFC): "Once _W_est_ has grown to reach the _cwnd_ at the time of most recently setting _ssthresh_ -- that is, _W_est_ >= _cwnd_prior_ -- the sender SHOULD set α__cubic_ to 1 to ensure that it can achieve the same congestion window increment rate as Reno, which uses AIMD (1,0.5)." Add new field 'cwnd_prior' in bictcp to hold cwnd before a loss event Fixes: 89b3d9aaf467 ("[TCP] cubic: precompute constants") Signed-off-by: Mingrui Zhang Signed-off-by: Lisong Xu --- v2->v3: Correct the "Fixes:" footer content v1->v2: Add new field 'cwnd_prior' in bictcp to hold cwnd before a loss event v1->v2: Separate patches net/ipv4/tcp_cubic.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index 00da7d592032..03cfbad37dab 100644 --- a/net/ipv4/tcp_cubic.c +++ b/net/ipv4/tcp_cubic.c @@ -102,6 +102,7 @@ struct bictcp { u32 end_seq; /* end_seq of the round */ u32 last_ack; /* last time when the ACK spacing is close */ u32 curr_rtt; /* the minimum rtt of current round */ + u32 cwnd_prior; /* cwnd before a loss event */ }; static inline void bictcp_reset(struct bictcp *ca) @@ -305,7 +306,10 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd, u32 acked) if (tcp_friendliness) { u32 scale = beta_scale; - delta = (cwnd * scale) >> 3; + if (cwnd < ca->cwnd_prior) + delta = (cwnd * scale) >> 3; /* CUBIC additive increment */ + else + delta = cwnd; /* Reno additive increment */ while (ca->ack_cnt > delta) { /* update tcp cwnd */ ca->ack_cnt -= delta; ca->tcp_cwnd++; @@ -355,6 +359,7 @@ __bpf_kfunc static u32 cubictcp_recalc_ssthresh(struct sock *sk) / (2 * BICTCP_BETA_SCALE); else ca->last_max_cwnd = tcp_snd_cwnd(tp); + ca->cwnd_prior = tcp_snd_cwnd(tp); return max((tcp_snd_cwnd(tp) * beta) / BICTCP_BETA_SCALE, 2U); } From patchwork Sat Aug 17 16:34:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingrui Zhang X-Patchwork-Id: 13767204 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D24B615535A for ; Sat, 17 Aug 2024 16:35:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723912524; cv=none; b=Hi67/A+AVFhYJAOrHJh+uP7iihU9/XG2KaDBmFM9YaEoK92IO5vS1dB8GKBi4Ic160KCCG5qop8kdLejFZATQFGd1dujrIVIhUO0NX1WkTqijPLNL5U9HgnVVz/aqEXkce49tSlgE2guxhcRadEvIyviGoORZ1gQ3FcT/MszIGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723912524; c=relaxed/simple; bh=1/9KQ8wnj51hRyT1CcTkFFeJSIPzinRegrHEhCI2kJQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OAuwvbxkwUpb4GX72f0efARtfe7VgVYHsBwcojuCtJEnPYAQ9aYhQ6AoFpDeK5aOviRkviy4/IVWFdeVKW2eRo0xQbCQPw11k/TNehxGX/lGu6rXjiN54FhxovT5hrYDTe3Xz39P5+NIu4oXVOpMCWPyYUrC26k2rs02pJIKM/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=O9K87ce4; arc=none smtp.client-ip=209.85.219.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O9K87ce4" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6bf75ed0e0eso14341886d6.1 for ; Sat, 17 Aug 2024 09:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723912522; x=1724517322; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WS7N6RPOD0Ok7qOs3b3gud2gCuVQz8sQs3a4FSFKrW0=; b=O9K87ce4A1yWOpHH9rSfYESBjBbTliilUwuW6esebD91EKRFdmYxKhYjS8NP09yIv9 dUdXrcz3rXopF7hNUal/w7sLFmWhN/Q+z0RabiEv6rHWowQJ6I77VXUrX/IgwmuZXnbJ 3kHrtnTTaaCvvE3VytyZW3YOsNoZP0VUOwN98IXjFaIchI88m7OHgV1FQHNHlUWBzODw u4pYzCRVoI/2/T6CtooxJuWvAToW//SjL6ugMefadSbzdWCwgW/H5P9hAO4abzsMJz/n 2RBpEBrnmh1iICPuYghOnRCqqRvrlYeRAMD2PZFFMr7aFnqoYk7WhcHWOwXZ3gyZDF7i Rx4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723912522; x=1724517322; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WS7N6RPOD0Ok7qOs3b3gud2gCuVQz8sQs3a4FSFKrW0=; b=L48C5FZauUC3zQXiU94bFIswYngCoLc6AwKg1NPcL9FX25XPtuQ7ACHCK8SeTH7mFI xYSRwjGSjCwzIlVuwUZfqRzsYn0e7JpwBL1VKlCfSGl+0/1uKbaXo7qNwz1WFRNqyCtM k7Qw+1BzxO1dF5kskXaAvE/qn6nAX+ckVYDP6lGir1bUuSDSf32nhbmUrt78TpknhCMM iePLS6aeSaRv0jbV7ryhgNZLo22nwrC3w3XfwhlF7vcP/fS3UCuNajYCH16vOInPSr2O u28Xp635/aH+dsPezosmQyBq5yGFnIqQwuBtR77XF8eTPIQdRcDpKC6S8HmhycaBUmEQ fRGQ== X-Forwarded-Encrypted: i=1; AJvYcCVeD3jqPXLVqJHIAROLnWYkQPVMZvP6h3gI2kSLmovwK2RVHWMyOf2vf9Xts88AfB5IjgT5XP3N0ykLnbkBydfbBo5IyLit X-Gm-Message-State: AOJu0Yz0IU6sXZG4td8L+J0aFdTWT4/j8iyWOuJuBeDBRaC9oxT2U/ih F2k4mvbq9GaVh+X8EmCOKVrF3dPvRSX0MjXwRrDFLrbMKRIq//mk X-Google-Smtp-Source: AGHT+IGtR/M5s65KHYKhziebDGt1l4uc0mB3I4muRJHqmFssuuOYCqHPjjHKBuRcrf1y79/PWA7iWg== X-Received: by 2002:a05:6214:2b87:b0:6bb:ba0a:f4a5 with SMTP id 6a1803df08f44-6bf7ce0fcfdmr70914046d6.33.1723912521640; Sat, 17 Aug 2024 09:35:21 -0700 (PDT) Received: from jshao-Precision-Tower-3620.tail18e7e.ts.net ([129.93.161.236]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bf6fef242esm28319406d6.118.2024.08.17.09.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 09:35:21 -0700 (PDT) From: Mingrui Zhang To: edumazet@google.com, davem@davemloft.net, ncardwell@google.com, netdev@vger.kernel.org Cc: Mingrui Zhang , Lisong Xu Subject: [PATCH net v4 3/3] tcp_cubic: fix to use emulated Reno cwnd one RTT in the future Date: Sat, 17 Aug 2024 11:34:00 -0500 Message-Id: <20240817163400.2616134-4-mrzhang97@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240817163400.2616134-1-mrzhang97@gmail.com> References: <20240817163400.2616134-1-mrzhang97@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The original code estimates RENO snd_cwnd using the estimated RENO snd_cwnd at the current time (i.e., tcp_cwnd). The patched code estimates RENO snd_cwnd using the estimated RENO snd_cwnd after one RTT (i.e., tcp_cwnd_next_rtt), because ca->cnt is used to increase snd_cwnd for the next RTT. Fixes: 89b3d9aaf467 ("[TCP] cubic: precompute constants") Signed-off-by: Mingrui Zhang Signed-off-by: Lisong Xu --- v3->v4: Separate declarations and code of tcp_cwnd_next_rtt v2->v3: Correct the "Fixes:" footer content v1->v2: Separate patches net/ipv4/tcp_cubic.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index 03cfbad37dab..2d7121ca789e 100644 --- a/net/ipv4/tcp_cubic.c +++ b/net/ipv4/tcp_cubic.c @@ -304,7 +304,7 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd, u32 acked) tcp_friendliness: /* TCP Friendly */ if (tcp_friendliness) { - u32 scale = beta_scale; + u32 scale = beta_scale, tcp_cwnd_next_rtt; if (cwnd < ca->cwnd_prior) delta = (cwnd * scale) >> 3; /* CUBIC additive increment */ @@ -315,8 +315,11 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd, u32 acked) ca->tcp_cwnd++; } - if (ca->tcp_cwnd > cwnd) { /* if bic is slower than tcp */ - delta = ca->tcp_cwnd - cwnd; + /* Reno cwnd one RTT in the future */ + tcp_cwnd_next_rtt = ca->tcp_cwnd + (ca->ack_cnt + cwnd) / delta; + + if (tcp_cwnd_next_rtt > cwnd) { /* if bic is slower than Reno */ + delta = tcp_cwnd_next_rtt - cwnd; max_cnt = cwnd / delta; if (ca->cnt > max_cnt) ca->cnt = max_cnt;