From nobody Tue Sep 17 14:37:47 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4X7PWv307zz5R8MX; Tue, 17 Sep 2024 14:37:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X7PWv2JGYz4mV9; Tue, 17 Sep 2024 14:37:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726583867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4I1VkdGXeQ8TvAIvrr7f/462X1QYa2fk+cVgAHBimhU=; b=s2OcvLM6246EaVJkaOgVJxIqQJtDkg3K/NtO4FG9nn5OyPjuPCZIAwUZyJ6pAazuK+pJ9t 0V6uGaOlR3cmroTVc8gh+fiHI+UM/q3NHJ4jjblnyz6HZA+7uAAaM8QGMcF/iF7SNkiHid /LGtjYvakmyvoLv1Gb/14eXcEhA9UsIdOJRhWTSvpbrix2XO3FSaAcNrOMBhx4GYMq8d06 s1JHZ6ZmfayK8OFdHzj6EwxPo0nVvxnCkrQ0jJecmMBP5aVsaTM17BMD6LuD7UD3kWJfeF fr35wHkgyWZ8nDLFUlA8B/mMDyf+TcUgVKbmEe/ToBsGgWmr/2U4ooPjcbLB7A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726583867; a=rsa-sha256; cv=none; b=doXbCJINSy/EytkTDkFx8yFdPDbqL2qRXeSC6JjKyw4smA5KJSms/s1t1kDIFI1rhwJS+2 PVij5X+TPZVL+T/nHXyoEnOV+5mb/T/HXdRNT/9zTXUKO7nMIRDjZ4UiVsP7AIUf2cxTCs 7lukwAaBMPAwevpEW/e8TlNH9YS/uad7QNdOfMZ01gX2Jk2wwVAf90MD+JOm3b1JEvFym+ Fp0lrL8j2DYwT9+PLn9e4PBAKPqZbPsF7fFUNvHjW1NkMMZXdsPW8RLDVs1uvkaKU/Wg6g MBcJnQd2JhikS5atpLtMbkBGD1nFb/zOLGdRohF66XvzGldt2DOiyz8Wtmm7bw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726583867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4I1VkdGXeQ8TvAIvrr7f/462X1QYa2fk+cVgAHBimhU=; b=fQmrLZwzS2bCQyc9rPv2Qoi5kfrplGEjsMkT/7bepw3s6hKU8S72yiLylEjvwXgq6SCrov p2vkp3AlCshbvlVeoTLT5L+2Xbxp2xWnXV7Hh1wa9w85vRycn9yo9ZLVoTd8PONcyZdOkI OHKnSbQjxBVW9SQ3qP3b0RzDP1TdD6lSCj6t61fBaFEeXKN0qmZU3FDp3xjIEkNrgzj0g2 wExWOkToIUDkS0eHvA73gbBUOdlgOzUarbnnRZEptF36bMCOlI70x+ZmVAnHFPqkQ/XBFI id66dnUtoJZtcBiPhH7P1QOSnO+LBqIvRoyAeAmKobV9FX51j7qq6bzKnMt+UA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4X7PWv1wRHzj1C; Tue, 17 Sep 2024 14:37:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48HEbljL028736; Tue, 17 Sep 2024 14:37:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48HEbl8c028733; Tue, 17 Sep 2024 14:37:47 GMT (envelope-from git) Date: Tue, 17 Sep 2024 14:37:47 GMT Message-Id: <202409171437.48HEbl8c028733@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Cheng Cui Subject: git: ee4506105171 - main - cc_cubic: use newreno to emulate AIMD in TCP-friendly region List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cc X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ee45061051715be4704ba22d2fcd1c373e29079d Auto-Submitted: auto-generated The branch main has been updated by cc: URL: https://cgit.FreeBSD.org/src/commit/?id=ee45061051715be4704ba22d2fcd1c373e29079d commit ee45061051715be4704ba22d2fcd1c373e29079d Author: Cheng Cui AuthorDate: 2024-09-05 18:52:57 +0000 Commit: Cheng Cui CommitDate: 2024-09-17 14:37:00 +0000 cc_cubic: use newreno to emulate AIMD in TCP-friendly region Reviewed by: rscheff, tuexen Differential Revision: https://reviews.freebsd.org/D46546 --- sys/netinet/cc/cc_cubic.c | 44 ++++++++++++++++++++++---------------------- sys/netinet/cc/cc_cubic.h | 18 +++++------------- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/sys/netinet/cc/cc_cubic.c b/sys/netinet/cc/cc_cubic.c index 45f75efe5ae7..c4b44d5c3660 100644 --- a/sys/netinet/cc/cc_cubic.c +++ b/sys/netinet/cc/cc_cubic.c @@ -288,31 +288,26 @@ cubic_ack_received(struct cc_var *ccv, ccsignal_t type) usecs_since_epoch = INT_MAX; cubic_data->t_epoch = ticks - INT_MAX; } + + W_est = tf_cwnd(ccv); + /* * The mean RTT is used to best reflect the equations in - * the I-D. Using min_rtt in the tf_cwnd calculation - * causes W_est to grow much faster than it should if the - * RTT is dominated by network buffering rather than - * propagation delay. + * the I-D. */ - W_est = tf_cwnd(usecs_since_epoch, cubic_data->mean_rtt_usecs, - cubic_data->W_max, CCV(ccv, t_maxseg)); - W_cubic = cubic_cwnd(usecs_since_epoch + cubic_data->mean_rtt_usecs, cubic_data->W_max, CCV(ccv, t_maxseg), cubic_data->K); - ccv->flags &= ~CCF_ABC_SENTAWND; - if (W_cubic < W_est) { /* * TCP-friendly region, follow tf * cwnd growth. */ - if (CCV(ccv, snd_cwnd) < W_est) - CCV(ccv, snd_cwnd) = ulmin(W_est, INT_MAX); + CCV(ccv, snd_cwnd) = ulmin(W_est, INT_MAX); + cubic_data->flags |= CUBICFLAG_IN_TF; } else if (CCV(ccv, snd_cwnd) < W_cubic) { /* * Concave or convex region, follow CUBIC @@ -320,6 +315,7 @@ cubic_ack_received(struct cc_var *ccv, ccsignal_t type) * Only update snd_cwnd, if it doesn't shrink. */ CCV(ccv, snd_cwnd) = ulmin(W_cubic, INT_MAX); + cubic_data->flags &= ~CUBICFLAG_IN_TF; } /* @@ -644,19 +640,23 @@ cubic_ssthresh_update(struct cc_var *ccv, uint32_t maxseg) cubic_data->undo_W_max = cubic_data->W_max; cubic_data->W_max = cwnd; - /* - * On the first congestion event, set ssthresh to cwnd * 0.5 - * and reduce W_max to cwnd * beta. This aligns the cubic concave - * region appropriately. On subsequent congestion events, set - * ssthresh to cwnd * beta. - */ - if ((cubic_data->flags & CUBICFLAG_CONG_EVENT) == 0) { + if (cubic_data->flags & CUBICFLAG_IN_TF) { + /* If in the TCP friendly region, follow what newreno does */ + ssthresh = newreno_cc_cwnd_on_multiplicative_decrease(ccv, maxseg); + + } else if ((cubic_data->flags & CUBICFLAG_CONG_EVENT) == 0) { + /* + * On the first congestion event, set ssthresh to cwnd * 0.5 + * and reduce W_max to cwnd * beta. This aligns the cubic + * concave region appropriately. + */ ssthresh = cwnd >> 1; - cubic_data->W_max = ((uint64_t)cwnd * - CUBIC_BETA) >> CUBIC_SHIFT; + cubic_data->W_max = ((uint64_t)cwnd * CUBIC_BETA) >> CUBIC_SHIFT; } else { - ssthresh = ((uint64_t)cwnd * - CUBIC_BETA) >> CUBIC_SHIFT; + /* + * On subsequent congestion events, set ssthresh to cwnd * beta. + */ + ssthresh = ((uint64_t)cwnd * CUBIC_BETA) >> CUBIC_SHIFT; } CCV(ccv, snd_ssthresh) = max(ssthresh, 2 * maxseg); } diff --git a/sys/netinet/cc/cc_cubic.h b/sys/netinet/cc/cc_cubic.h index 592703906d1a..b4773618e6f8 100644 --- a/sys/netinet/cc/cc_cubic.h +++ b/sys/netinet/cc/cc_cubic.h @@ -83,6 +83,7 @@ #define CUBICFLAG_RTO_EVENT 0x00000008 /* RTO experienced */ #define CUBICFLAG_HYSTART_ENABLED 0x00000010 /* Hystart++ is enabled */ #define CUBICFLAG_HYSTART_IN_CSS 0x00000020 /* We are in Hystart++ CSS */ +#define CUBICFLAG_IN_TF 0x00000040 /* We are in TCP friendly region */ /* Kernel only bits */ #ifdef _KERNEL @@ -286,22 +287,13 @@ reno_cwnd(int usecs_since_epoch, int rtt_usecs, unsigned long wmax, } /* - * Compute an approximation of the "TCP friendly" cwnd some number of usecs - * after a congestion event that is designed to yield the same average cwnd as - * NewReno while using CUBIC's beta of 0.7. RTT should be the average RTT - * estimate for the path measured over the previous congestion epoch and wmax is - * the value of cwnd at the last congestion event. + * Compute the "TCP friendly" cwnd by newreno in congestion avoidance state. */ static __inline unsigned long -tf_cwnd(int usecs_since_epoch, int rtt_usecs, unsigned long wmax, - uint32_t smss) +tf_cwnd(struct cc_var *ccv) { - - /* Equation 4 of I-D. */ - return (((wmax * CUBIC_BETA) + - (((THREE_X_PT3 * (unsigned long)usecs_since_epoch * - (unsigned long)smss) << CUBIC_SHIFT) / (TWO_SUB_PT3 * rtt_usecs))) - >> CUBIC_SHIFT); + /* newreno is "TCP friendly" */ + return newreno_cc_cwnd_in_cong_avoid(ccv); } #endif /* _NETINET_CC_CUBIC_H_ */