From patchwork Thu Aug 15 00:17:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingrui Zhang X-Patchwork-Id: 13764291 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) (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 B99F11878 for ; Thu, 15 Aug 2024 00:19:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723681179; cv=none; b=tC18EJPesi/OU0o3uuLDfr8Cnm+FhybVh4+YU6F2Yjs9U13AIvBSVPo/t387t+ORKKpafhXeDC/ZR/FijDRaSlxeIVI5JtdSBwQS0t6EBYNSYQzczfupJ8IDvDMTgtxqzTHO54UZNgIDyzzQGedhiPkp7zSpRSVgsjvXFvomLu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723681179; c=relaxed/simple; bh=/gx5TOaEDzO6JxN8lEEjbgT3QyvIk0pfBhc1U3cmtbs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pQQ6RdOgZSo60ZzxuWKOCjnpAd45K8mVq/9FDxhofPXB3/IPXpNhnARrkU1UL3NV4NxBKC9SVJfaMTSMk0XVHtg35ZAqcQbAh7+dobiZfEnoektS+IsHcsRDnc9tyltqmY105slJfAnU/B7j+7H3IgnBdM2SSpZGXib36SNr5iU= 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=m3RqVAp8; arc=none smtp.client-ip=209.85.166.180 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="m3RqVAp8" Received: by mail-il1-f180.google.com with SMTP id e9e14a558f8ab-39b38295008so1565985ab.2 for ; Wed, 14 Aug 2024 17:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723681177; x=1724285977; 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=9SEOGsWlqXwcpw2n5tIfIJsDE2WXNGqxy7z4L0W01jY=; b=m3RqVAp8WVVzjOT7iIRDi10x0PxdNxt4TB9SpxCKHbMi5OrhQ3gNo4MeJlC0nZXfRQ PknSr1IhaxIaVLiPzuzwcMzETT+bPT09+xAmrX02DgmnZb2AB/PoL5n/9qlZuOcvOAJz ++zQXx8PKkHUuAztqHBgA3n0CTZ41qNRW5CSAu6lmH6Lcmn+QTB9JxvMng5X28e7ju/O 3DVrgdVW0ltmlk2GX/3UiePZQjyrFrKk+DOcpwvMFQRyDM8InfOeSPUsTbkTnCWFGm4r cJbOPxtYEPrw1dlBPAnXImJM7KoJB/IXL+bO8l575lEgX/Fhirtn6K0v3Fut/zFQVGjD qgPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723681177; x=1724285977; 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=9SEOGsWlqXwcpw2n5tIfIJsDE2WXNGqxy7z4L0W01jY=; b=AQxoXpulJJz+1zfaJxE03X0YYSLS2znUZ2xFyfmSPDvotyH+OxjUGb2Hh05EJfOZZc y+vqExRFdv5njNIhoSpV0baoMEBQpOlvCYq/UM5WSwRBI2n1iQlnkaBx5liiRhNJGrVR ghaLhjBBjIzkaMNaMA+L2l+A0D4BRG9e8zQwfYzOd2h3/pZQnptxuS72Eq4eRsR1MFgu jGYnMmUgdLNWjHrvLvO3FtRWKlPtRB+x8U+e0nC8U/9PU0FiL6dRght6H2vVqNNu7+H1 gBbRVZuA/mVl8mF8/6lqJYM0Ek0vmy7QTr9oblAyXLdEDjWc25SxeWyEMRan3V59I7Mx UvBg== X-Forwarded-Encrypted: i=1; AJvYcCUoj5i0TG18nUiMaqaaQrZUUgBI8/P1bQvgM654Lszi3xVcKoVul9O90dmaydGaN3JUMxtRzoQA/D09uiBs2P9VjAHgMFS0 X-Gm-Message-State: AOJu0YwhujL6GH0BOusODMVzX5txlruwJcYaaKTsu4kmRhbj9sVejXId hSrLaPoXJpxeSrasiYzNNSs0mKFLIEKKtpoN80frBy6urErBGxos X-Google-Smtp-Source: AGHT+IE3HAt0MpwiDiq6l2ffmq/tvlPmWYckzKhvSvoQUed7eyax/9skQONVdZ3rsmLbzv+0JgObpQ== X-Received: by 2002:a92:c541:0:b0:39b:2133:8ec7 with SMTP id e9e14a558f8ab-39d124cd81bmr52019095ab.18.1723681176805; Wed, 14 Aug 2024 17:19:36 -0700 (PDT) Received: from jshao-Precision-Tower-3620.tail18e7e.ts.net ([129.93.161.236]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39d1ed74e0dsm1244935ab.78.2024.08.14.17.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 17:19:36 -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 v2 1/3] tcp_cubic: fix to run bictcp_update() at least once per RTT Date: Wed, 14 Aug 2024 19:17:16 -0500 Message-Id: <20240815001718.2845791-2-mrzhang97@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815001718.2845791-1-mrzhang97@gmail.com> References: <20240815001718.2845791-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. Thanks Mingrui, and Lisong Fixes: 91a4599c2ad8 ("tcp_cubic: fix to run bictcp_update() at least once per RTT") Signed-off-by: Mingrui Zhang Signed-off-by: Lisong Xu --- 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..11bad5317a8f 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, + * 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(HZ / 32, usecs_to_jiffies(ca->delay_min))) return; /* The CUBIC function can update ca->cnt at most once per jiffy. From patchwork Thu Aug 15 00:17:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mingrui Zhang X-Patchwork-Id: 13764292 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (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 5794D1878 for ; Thu, 15 Aug 2024 00:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723681186; cv=none; b=kFspo+xJ/aMpVT7sSittFtp3pApxf7O/ihp7qxXQvw+kUml0dK7DJ6yoo4U0F0QEPQqDpD6Jkcb6LaFJ83u5wGIXgikZnKyhnps0YPy9yS6yJ5hmd15pjEdWlh/1RZ+u3wNigK80PbJapxXrSo5/wRrtn/KsJxK9WVI1KQ+fFHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723681186; c=relaxed/simple; bh=Kn4Tbh9cEFtChNo9SEH/kumMDHT2X8Gb2tgDv8B+6M4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ZF3oAcptKP/7VJp5qJb0vxGsqDBExOGxIuZ9jVLA28de3wr5R548gh1H40o/SFMmI8Rm9VcWJdxGQ9GAayxPX73bra8i3LkfwMbEEDzONm3oUZ0Se8GoEwy5aTEmTh7qFtyHkgx58neXdDHFL5sxtiZpxORQJ/AuAiGMflXn85A= 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=mi7276ja; arc=none smtp.client-ip=209.85.166.173 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="mi7276ja" Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-396e2d21812so1876605ab.2 for ; Wed, 14 Aug 2024 17:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723681184; x=1724285984; 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=md0s5iUdURNHRxf3x9cdpW+6TFBpfJS5CRN6qgPKa70=; b=mi7276jaQMFNo0SflvtV/crNzfqzt7Hmwuq0Y9qRf9o7cyIUiGJKBtJqoHo9Rt7oZx LSXYXd5qp/RIqkqZBFwBaUCVVUyZ/Azg79gN7bPT5Pq6d/dC99ePjLLggr8ML1LVfoM6 GfLReuk31Xapv+4nB1+RenF03+8S6PHhjT8kR8nRCs7EyDcZFy0wVCMLqwuvyZbbdX4M TCj9RUEBlMKAwm+u3mRKejQr1h5u2Yk7XKOHVfja4HRUaHM1Tlvx8+PI2XhxeaYiiLoN K+Dc+vKz9pjHIFXau/P/5lwGs0emW/Fm9XIQ1pME03xBmOJEMLpgyp9OPoRcJCRnhiYH 6BkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723681184; x=1724285984; 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=md0s5iUdURNHRxf3x9cdpW+6TFBpfJS5CRN6qgPKa70=; b=BmUvnehtjweHZZ5eizzE5g43OAREr6urJ934Yes5VcFhe+FwhYC+ZK167nlR9HJZBb qBCgOMaHTpUwEf3l3bUx44sgJYpjeAVZw3Gmdlv6RnFA3Ez+p7NPBi60LTSMSs2hgk2u CS+fNvAhY2aqMCw1PyEROVrgvhKcM61n7bnC+16jU7oLxiNuXTGqBFP9UkNndVrgIyxl 7vJ+IdlMnlyfZmhLVcU1iMMT7njxurY0WJbqXiGb0SotxNwpAckmDuwc3sHebLrpz5Lb pD9b/MxaHY8axCxWYtSECKrJtK+FYASWWrI9ptsNKOGjjB9TBqBwNUNLPRRP6WqCqcYR sYRg== X-Forwarded-Encrypted: i=1; AJvYcCUeF0SkWTArXe4YVTgpgD/WFYR7nCYWDnOy8ylGwzPuSduKEf/vYNVtti0DpLSCvtDmtUKdsg4ZPG9JpHIDzaxYoLUKk7iM X-Gm-Message-State: AOJu0YxNGYKgWPXYFlF3sAJDaZqMzj31vdAoYsgleP75CaMweVWCWebA P0RxlvRUV8zL2FuYw/9ANfW8/C365KINy0UqPUL7uQ8GZSbQ8NOAAqbKug3Z X-Google-Smtp-Source: AGHT+IGDm5bMUViOYmdb8xnyCCmFCrnDmU7FdPFN1O5KjPGi+i4gWWO3IOPn7e7OP4Hag2Tu6R+gMA== X-Received: by 2002:a05:6e02:1c0e:b0:398:81e9:3f9e with SMTP id e9e14a558f8ab-39d1245c2d6mr61794825ab.12.1723681184354; Wed, 14 Aug 2024 17:19:44 -0700 (PDT) Received: from jshao-Precision-Tower-3620.tail18e7e.ts.net ([129.93.161.236]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39d1ed74e0dsm1244935ab.78.2024.08.14.17.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 17:19:44 -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 v2 2/3] tcp_cubic: fix to match Reno additive increment Date: Wed, 14 Aug 2024 19:17:17 -0500 Message-Id: <20240815001718.2845791-3-mrzhang97@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815001718.2845791-1-mrzhang97@gmail.com> References: <20240815001718.2845791-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 Add new field 'cwnd_prior' in bictcp for cwnd before a loss event Suggested by Neal Cardwell https://lore.kernel.org/netdev/c3774057-ee75-4a47-8d09-a4575aa42584@gmail.com/T/#t 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)." Thanks Mingrui, and Lisong Fixes: 42da09fdf2bb ("tcp_cubic: fix to match Reno additive increment") Signed-off-by: Mingrui Zhang Signed-off-by: Lisong Xu --- 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 11bad5317a8f..7bc6db82de66 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 Thu Aug 15 00:17:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingrui Zhang X-Patchwork-Id: 13764293 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (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 9FAE518D627 for ; Thu, 15 Aug 2024 00:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723681194; cv=none; b=DpLFb6rLo1jIXtZ6x/bOzQtttVPVd2+iM5glscz/q+BV2uiFlL4BXjMorNOSfc8NQ6xGvLLbRkWphCXDYOcMckNJi3Xbb5Rizeh699j54dwD8NDBuZZdiB0Mvqw4dXBLrEC4LXgvalKNkBnc8eIGa8lTW6UAV7dQyw+HRskUxc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723681194; c=relaxed/simple; bh=8iRzqDoYf39rgtBU1oLcruq0trBu0TN+0kpem5OBr3g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rrlt4KebgkilWz0Jy/gix1MhrWjQ4Q16grThqGcmydFNJxRe4kyaoknXzdDmNxboEtxxL9SSQNdUrgSyCd0BaD/6kmQlQ+lrUTqIVAfqtrlZSMuPk8s18TPwwe42xjU4lzfMH3d945M3G8j7K2nSUt3X36YHpLKIFzZQfu3Hf/I= 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=k2aksTqO; arc=none smtp.client-ip=209.85.166.172 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="k2aksTqO" Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-39834949f27so1902975ab.2 for ; Wed, 14 Aug 2024 17:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723681192; x=1724285992; 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=4BoaaryjN+kmznsXNg0/iu0at6ootyNT2WSzfJdTBZ4=; b=k2aksTqO9fCosCWFYXUor3ovoAuTwveZXI30uiYEpC4zTnSoFM94aRJGxXX9FIOzJS I53jOaT4E0v6iRSMac0iJ+MPh+MHLvAl00z7hmmFm7RtZ9nWCA0BkYuzFOdttX8F+bf5 2Pwt2iMzYsjM0WzRuo6raMmKx4Ap1UPrs2lBUcRy3DBQ8SVJUfQErNzZBKPEN2AyRgRQ s8oM90DUmiDg4YD+G22QKbEkn8tuWg7gDwWHKeS9rhwx+fh+GqKncJlAUHsrhEuuyyj/ rOpJNvc1ag5lNTL6Wzc2zmLK3uYbaRoNLG6R3Npa9/AdFZx65kRlbhwXQqNyPnmLwB01 uzHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723681192; x=1724285992; 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=4BoaaryjN+kmznsXNg0/iu0at6ootyNT2WSzfJdTBZ4=; b=GDfB2JLwrf/Jmbq3wmsqn6RAZV0HeQhXBG4NI2c3VCWEVdpWmspoG9WoIN4dpihf5b YfH8bryDdeNAfj5+26KkboYit5r5xRvSsrL1tBWNXHwxaGD1y/sBE+s6bpGyiWQNJqRj HrGb6ShbMCnF3y+XU1zLOmNUwM/TIrYaBLkhMOMgM0mDd9CkgPw62kXAOKWQ9v2Ve33w TkjkIB16+TXxtPIMZlFO93wFYLCv/fKnqSy1wDXXVyb/zVi4O//buZJ7WFQI7JpmwNbl ghZ7UDQYL3YMfxaqUtgQLMDb0iw8vRdwBRjtPBUrLkpk7LmQ02LjQkHv/OnXvkEu63On Vt1g== X-Forwarded-Encrypted: i=1; AJvYcCWsTbj9yptwj4FX7MD1EKhYw2Mu3WMLUdEl8f4iDUBpmx2EBkSBnSs2unsrrlCvAsYVFVa1xIQ1cXRuMPy/ytG1lo/wYcK8 X-Gm-Message-State: AOJu0YyC8V3Oi4tBDtxm9qm9umtaIJdvNB0Eq87J3V5RAOQEgkIYWJks sMwfcN5gwVIsiV6rLmcD6g1+iFPtM06C8qtVtV/MSQgD2TxwtpbI X-Google-Smtp-Source: AGHT+IFVyn+FvDgaM9qfcrvEI9LQzcnVnP0CS2w58XvbGumiN4Pv5V21D8NMT1A0wMf2Y7MY6enXFg== X-Received: by 2002:a05:6e02:1ca6:b0:397:980d:bb1b with SMTP id e9e14a558f8ab-39d12447b1dmr54817385ab.7.1723681191760; Wed, 14 Aug 2024 17:19:51 -0700 (PDT) Received: from jshao-Precision-Tower-3620.tail18e7e.ts.net ([129.93.161.236]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39d1ed74e0dsm1244935ab.78.2024.08.14.17.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 17:19:51 -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 v2 3/3] tcp_cubic: fix to use emulated Reno cwnd one RTT in the future Date: Wed, 14 Aug 2024 19:17:18 -0500 Message-Id: <20240815001718.2845791-4-mrzhang97@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815001718.2845791-1-mrzhang97@gmail.com> References: <20240815001718.2845791-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. Thanks Mingrui, and Lisong Fixes: 856873e362b0 ("tcp_cubic: fix to use emulated Reno cwnd one RTT in the future") Signed-off-by: Mingrui Zhang Signed-off-by: Lisong Xu --- net/ipv4/tcp_cubic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index 7bc6db82de66..a1467f99a233 100644 --- a/net/ipv4/tcp_cubic.c +++ b/net/ipv4/tcp_cubic.c @@ -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 */ + u32 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;