From nobody Fri May 19 15:17:44 2023 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 4QN9Sn4mjBz4C3qv; Fri, 19 May 2023 15:17:45 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QN9Sn1SCLz3xxc; Fri, 19 May 2023 15:17:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684509465; 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=ttldxMgTzBhsG8MCGTvAW22bRIHiJubfMy18cGfl3xo=; b=EIECC0xKmjtiusfmr3M0Nmi11trca+wkthq0y+Hl9pB3hbtmc2XeVtsHRSKgWIPWiZ0pKT gyq900Z090u9CyPShk2JiW7PJjM+H8vbnTLS9iis6LNCUX5CQ8TA8By1L7DxU41n80cneF ft4iaZbGCkhiWygzLjAZb87//LXVBSzoSMle5LaL8AfVbSeR7fLnjyRr2M0iCmoQMZfi0j v+mpNMBTE7gHd0h0aqB49MWVPZM++ASSzh18Ujbeg01sBzxqhfuIdGrUDmEmtBxMryLYDw qyLVKD2AB5e2JlkWETNpVrSYmF47zGbg6/5lCTURZo8XNnX3QTAZj032jHbIYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684509465; 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=ttldxMgTzBhsG8MCGTvAW22bRIHiJubfMy18cGfl3xo=; b=riFU9lKmzmj+Faht2BRcWL7jIWBqzvMuOpeP9vWtjG7U3HzR4VtZTmqzORVM9DUwTVpbo6 v7AcitasJVvMEy7GyY76JnjEf0sU3m1X9iqRphybmnNXoCtuIjZP0Hqqw1Rykpx4j5mCmS I1rrjw7b4Ua2bn2HYFvnlXo6e/Eea0CsSQ1eBM3emmq6QxTSN3yIqMPjIybbPvx8522C+M uOwakeEWy1B4A/yA+Eh3CApyUw8nOAW7x5HACNFg4yQHyespz9AIjHcPWK40Ieyey8oQd0 6+bYCkTouQ+1WES0xox7BwLPHGfYjZtqyZ8ot5AwG2VmggGYUIXK0JxpPFWuqA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684509465; a=rsa-sha256; cv=none; b=YuAXlcrSH3i1CuC44oS/jEkYPlvbosgjIgdoXeg2RhJwMrWRpzKAc4bk1r6gj5zRsFibb7 FkmAW6bAHEYAQ8pBd0iRMthHJG3SVRQ48eiT9cyq02nt97r6X7bG7TZbVxkzj6MbVjWOzX /YM/RCbyUvnysLopLXshZzK9jRjD+MEs28mqIrBnT/hsuCh9WQpYYCCJfh3Pzl4dz6/KOF o3x919kVBvQFNH0MHzWGMuJtl8USYMKFpoTa5HJ48v/+CBWBL980oUg4fTgjRpehK4JuO9 UukBA7Gd4ndZBM3pFGO8xEIk6az54ARCJ5e0bR2ZRQd3JJi6bd/zK3TmJNqnnA== 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 4QN9Sn0Y4HzY79; Fri, 19 May 2023 15:17:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34JFHi6A009020; Fri, 19 May 2023 15:17:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34JFHix2009019; Fri, 19 May 2023 15:17:44 GMT (envelope-from git) Date: Fri, 19 May 2023 15:17:44 GMT Message-Id: <202305191517.34JFHix2009019@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Randall Stewart Subject: git: ec6d620b197e - main - There are congestion control algorithms will that pull in srtt, and this can cause issues with rack. 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rrs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ec6d620b197e0973102db134a59e34efcc4bbec8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rrs: URL: https://cgit.FreeBSD.org/src/commit/?id=ec6d620b197e0973102db134a59e34efcc4bbec8 commit ec6d620b197e0973102db134a59e34efcc4bbec8 Author: Randall Stewart AuthorDate: 2023-05-19 15:16:28 +0000 Commit: Randall Stewart CommitDate: 2023-05-19 15:16:28 +0000 There are congestion control algorithms will that pull in srtt, and this can cause issues with rack. When using rack, cubic and htcp will grab the srtt, but they think it is in ticks. For rack it is in micro-seconds (which we should probably move all stacks to actually). This causes issues so instead lets make a new interface so that any CC module can pull the srtt in whatever granularity they want. Reviewed by: tuexen Sponsored by: Netflix Inc Differential Revision:https://reviews.freebsd.org/D40146 --- sys/netinet/cc/cc_cubic.c | 4 ++-- sys/netinet/cc/cc_htcp.c | 10 +++++----- sys/netinet/tcp_subr.c | 30 +++++++++++++++++++++++++++++- sys/netinet/tcp_var.h | 1 + 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/sys/netinet/cc/cc_cubic.c b/sys/netinet/cc/cc_cubic.c index 71bd51da8d0c..8992b9beba13 100644 --- a/sys/netinet/cc/cc_cubic.c +++ b/sys/netinet/cc/cc_cubic.c @@ -570,8 +570,8 @@ cubic_record_rtt(struct cc_var *ccv) /* Ignore srtt until a min number of samples have been taken. */ if (CCV(ccv, t_rttupdated) >= CUBIC_MIN_RTT_SAMPLES) { cubic_data = ccv->cc_data; - t_srtt_ticks = CCV(ccv, t_srtt) / TCP_RTT_SCALE; - + t_srtt_ticks = tcp_get_srtt(ccv->ccvc.tcp, + TCP_TMR_GRANULARITY_TICKS); /* * Record the current SRTT as our minrtt if it's the smallest * we've seen or minrtt is currently equal to its initialised diff --git a/sys/netinet/cc/cc_htcp.c b/sys/netinet/cc/cc_htcp.c index 4dd612e2cd7d..ea0f14ed12a8 100644 --- a/sys/netinet/cc/cc_htcp.c +++ b/sys/netinet/cc/cc_htcp.c @@ -444,7 +444,7 @@ htcp_recalc_alpha(struct cc_var *ccv) */ if (V_htcp_rtt_scaling) alpha = max(1, (min(max(HTCP_MINROWE, - (CCV(ccv, t_srtt) << HTCP_SHIFT) / + (tcp_get_srtt(ccv->ccvc.tcp, TCP_TMR_GRANULARITY_TICKS) << HTCP_SHIFT) / htcp_rtt_ref), HTCP_MAXROWE) * alpha) >> HTCP_SHIFT); @@ -495,18 +495,18 @@ htcp_record_rtt(struct cc_var *ccv) * or minrtt is currently equal to its initialised value. Ignore SRTT * until a min number of samples have been taken. */ - if ((CCV(ccv, t_srtt) < htcp_data->minrtt || + if ((tcp_get_srtt(ccv->ccvc.tcp, TCP_TMR_GRANULARITY_TICKS) < htcp_data->minrtt || htcp_data->minrtt == TCPTV_SRTTBASE) && (CCV(ccv, t_rttupdated) >= HTCP_MIN_RTT_SAMPLES)) - htcp_data->minrtt = CCV(ccv, t_srtt); + htcp_data->minrtt = tcp_get_srtt(ccv->ccvc.tcp, TCP_TMR_GRANULARITY_TICKS); /* * Record the current SRTT as our maxrtt if it's the largest we've * seen. Ignore SRTT until a min number of samples have been taken. */ - if (CCV(ccv, t_srtt) > htcp_data->maxrtt + if (tcp_get_srtt(ccv->ccvc.tcp, TCP_TMR_GRANULARITY_TICKS) > htcp_data->maxrtt && CCV(ccv, t_rttupdated) >= HTCP_MIN_RTT_SAMPLES) - htcp_data->maxrtt = CCV(ccv, t_srtt); + htcp_data->maxrtt = tcp_get_srtt(ccv->ccvc.tcp, TCP_TMR_GRANULARITY_TICKS); } /* diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index a8a896b7ebe6..db0b3b76088e 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -4316,7 +4316,7 @@ tcp_http_log_req_info(struct tcpcb *tp, struct http_sendfile_track *http, memset(&log.u_bbr, 0, sizeof(log.u_bbr)); #ifdef TCPHPTS - log.u_bbr.inhpts = tcp_in_hpts(tptoinpcb(tp)); + log.u_bbr.inhpts = tcp_in_hpts(tp); #endif log.u_bbr.flex8 = val; log.u_bbr.rttProp = http->timestamp; @@ -4641,3 +4641,31 @@ tcp_log_socket_option(struct tcpcb *tp, uint32_t option_num, uint32_t option_val } } } + +uint32_t +tcp_get_srtt(struct tcpcb *tp, int granularity) +{ + uint32_t srtt; + + if (tp->t_tmr_granularity == TCP_TMR_GRANULARITY_USEC) + srtt = tp->t_srtt; + else if (tp->t_tmr_granularity == TCP_TMR_GRANULARITY_TICKS) + srtt = tp->t_srtt >> TCP_RTT_SHIFT; + if (tp->t_tmr_granularity == granularity) + return (srtt); + /* If we reach here they are oppsite what the caller wants */ + if (granularity == TCP_TMR_GRANULARITY_USEC) { + /* + * The user wants useconds and internally + * its kept in ticks, convert to useconds. + */ + srtt = TICKS_2_USEC(srtt); + } else if (granularity == TCP_TMR_GRANULARITY_TICKS) { + /* + * The user wants ticks and internally its + * kept in useconds, convert to ticks. + */ + srtt = USEC_2_TICKS(srtt); + } + return (srtt); +} diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index a8bd6f8732cc..680797e508a2 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1400,6 +1400,7 @@ int deregister_tcp_functions(struct tcp_function_block *blk, bool quiesce, bool force); struct tcp_function_block *find_and_ref_tcp_functions(struct tcp_function_set *fs); int find_tcp_function_alias(struct tcp_function_block *blk, struct tcp_function_set *fs); +uint32_t tcp_get_srtt(struct tcpcb *tp, int granularity); void tcp_switch_back_to_default(struct tcpcb *tp); struct tcp_function_block * find_and_ref_tcp_fb(struct tcp_function_block *fs);