From patchwork Thu Aug 15 21:40:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingrui Zhang X-Patchwork-Id: 13765214 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 37CEF1494C4 for ; Thu, 15 Aug 2024 21:41:35 +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=1723758097; cv=none; b=MQ4fjUEGDbeiAdQrRnjVaF1tpYEOe8AC3BMqGaHkM2ogQLrxEZd+d57nsWeN2ut2i7ldAU44ZojJ0pVdecS6LbSIRryzd1EdTlO6PQ4DU8AEFvqzmGhf0z52j/i43IqZF5OwunH9JaaIVaXDERBwlaHEe0m9SdiWzVDNLZwqkxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723758097; c=relaxed/simple; bh=RJOdyQk5YS5vkcEStZbhhx/Fp61qZXNrMPZ5Tz0sNxM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z7tjcRFa6d7+tOWmBqcK63Se0HUs1ft06ottusgxRGwv/ep8bpjOBSWxVBGKJl+pU5GpMdITuIEMuP+LYEsDCirBV+NAIk/GBguHDS2zT3vBJBWSYneDQ/zGe9VQxKRDpQ1AZmD3BgW+ulAv+E1rO7XXWlpiirS/aWt0Jhao52U= 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=BJnRyG2M; 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="BJnRyG2M" Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-39d2256ee95so4052885ab.2 for ; Thu, 15 Aug 2024 14:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723758095; x=1724362895; 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=JoERIu1FC2fazUz3T9WwFNEk7GAnoCdN5OwGuGypPeM=; b=BJnRyG2MRDY5L2624o8pnUfdlmS1TZXpPtWeCDqvV6p7BRYZGCksK5cB+n5pbufNZl kVWvGw1tt0cNwZ2KrWoK1PaZ10DdO6rktzcWVMU0wDxWQOu6wbeihaKyhQ/zpe7C1t6X KDSq3OgPXBTQ3vg1OdHvSP/ODPY0w9hhkR+W8pVIdylXXlzOOY0e/G8BdIRMlKFhS4F/ RtKhULLOceBq5Kk7+dJSeSGFbqd6GXHw4v3wGzqZSSOhpbHUyX+J5+YTB9m2Kg8FOYfS oshO/M1F+CsQcfFZaUG+caUBUBj0/q5KIMRvDWRNlKev4MRC+Qqsh5pRzeax8qP4EB2L +nkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723758095; x=1724362895; 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=JoERIu1FC2fazUz3T9WwFNEk7GAnoCdN5OwGuGypPeM=; b=OBskSNwb1RiGJ/ilbEMpsmrOVyYqs/8mLm+rojbRxVVmzjjR+SqLAsbBclWdiNp2qK DnF2gHkq0ZwpZghkPu2Xwy5qtKoDjkhilIaiwmCJQ6TBnvey10JKeVUfnTZTa5qLCmKz Oc0G4sWdFJkTjNkvZRYF8dETmXPeYvSsiblCu+Sdr8SBCT5JfuFc6mUXJ4+fOqA+dIpp u0eMhwd8NRQ+AUsA40CzuHm4N0vBJ1wPSEOvxubJeHWQNJLNWPiFBngEVyaoXJl9xnjb Y4UqDq1MxDn4DHFlrQkrltnN8fP+1b5f7RKFbsFxt/JrVpsLUhBvJK9n9IuXiRHDka5o 9rVg== X-Forwarded-Encrypted: i=1; AJvYcCUYINOrgxQD+c1cODo1oOtugFqmMmIjuwqqYGe90SbQxuBr2e8PtX1kUY8cD5RCwld1IWj55QwC9/WNDPzE6UBk8RdwJ+qS X-Gm-Message-State: AOJu0YzIUEb87QKY6kK69Sib9fDvq4gJe2pTaIWyhyLu9ME8Mc788DP+ 0n45QeNfW5ksWDw0AssE8pKWT/7d063rjkZmiOGYbTmq4pb1CIF1 X-Google-Smtp-Source: AGHT+IES2u0xs3lzQZfRNAAejaxbCSxLljDZjByIRvJIZpMaaD50Gf3BmzaU67RH6k2wKaUPZNLTqQ== X-Received: by 2002:a05:6e02:19c8:b0:375:9c7e:d09 with SMTP id e9e14a558f8ab-39d26ce63abmr11003235ab.7.1723758095207; Thu, 15 Aug 2024 14:41:35 -0700 (PDT) Received: from jshao-Precision-Tower-3620.tail18e7e.ts.net ([129.93.161.236]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39d28e13cd8sm642125ab.22.2024.08.15.14.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 14:41:35 -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 v3 1/3] tcp_cubic: fix to run bictcp_update() at least once per RTT Date: Thu, 15 Aug 2024 16:40:33 -0500 Message-Id: <20240815214035.1145228-2-mrzhang97@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815214035.1145228-1-mrzhang97@gmail.com> References: <20240815214035.1145228-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 --- v2->v3: Corrent 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..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 21:40:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mingrui Zhang X-Patchwork-Id: 13765215 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (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 547671514C8 for ; Thu, 15 Aug 2024 21:41:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723758106; cv=none; b=kqF/z+b21PT/L75z1+VgK/f1nfGr4OMpzI62PUvkbocTV2X0OBdPuv/mYoPzeNzWYc3r3WQScsK7F/MoCmZtq6WAKlCzGsV8GWolOeTd9AhfAqLM+HwioX0RVGRt7DOrdkgHma3OIk78naxbPcSIRnH7gMiHIgTUY7aUBNEVt2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723758106; c=relaxed/simple; bh=GGMtPrAVGvi2K/4qPq/ljnpN+pRfL5lsV5NlF6JMVMs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=K7Gsaz44IaQRTNVa3vs2LbcTQiil6lqLKAMyX5n8QFMVezSLpkQu+osBVWUL0ckE9pIfBlUvUC1OopzQZjX5+FGbivMr4qp3kQ6xZivfBoa/vDniE7hhCzZj2Yl9QWmGZHZNIzx0S/GfHzkcBs5IbtaKWv2vIwc3k29uPVwXNpw= 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=cR1ZhJ4r; arc=none smtp.client-ip=209.85.166.174 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="cR1ZhJ4r" Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-39b06af1974so5468475ab.2 for ; Thu, 15 Aug 2024 14:41:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723758104; x=1724362904; 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=KvPly2LZhVx2LvQ1pKkjUeoR0Rz5L5mNxo86sOIiCzU=; b=cR1ZhJ4rsgqiMg6BD8ZBdJigasJ3O6/YaOq72ajeiEb44obAUYa5Py0aB0sSLqx0O/ owAZq2lzAGGdqY+QLDPNqsnSSBGFLbkgy9tp9v2tZB5ssyRVFSAdB1+s5RVmuaZI1S19 giuRDo6bUSD8ZOiwWH4G6iWSjfhWl3wzPB5qv5Swmi8EBDeLWxwGtxLUsNMSdD8zmdtJ ybT1AEcS1PG99DdfMEYUHURpa/Fra4Cz8R9C0Q9q7WS6G3vhIEJ5ibWYDtcS5bXWU3nS 7ktz6RwOSH/Y2NrBAaMDsTa1Hjow2Cb7WohuJVfCDyT2FIvgckvwha5K7R3RbTEFHS+A UxWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723758104; x=1724362904; 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=KvPly2LZhVx2LvQ1pKkjUeoR0Rz5L5mNxo86sOIiCzU=; b=XSXCZM9xHflgmq3aYJZG7+RqqveN7pPqBcGdK5fjiUNnnmWJKd+WLJBL3Gxl28M0wT iJkbaLKOM1qeoaBanlX+Q5HL8SCVfMZhBdEh40f6DmHW/vgqHjt3dVM+987vTw4Blqlo artmh/PXtaAfjyuEhPtoM9sqZrHNsodvqFlPSuJhi+9RR9887U9TTC0NsJVe4NzgUgtN 8/4LYViTOEsrjWuGIQEnyLDSUiH0roKeXx1pSTVRdKCmluAM8zLD1c7yBwTi0KGVruPs qOyWzlgcbAs3u2HecvNxg0peYJkDKDOZJSHFFHnarEJd4pKsTW+jDKNZJgYPtOXiVyFC HmVw== X-Forwarded-Encrypted: i=1; AJvYcCVpS15gtoQmc1cf6cP0qXukdCiMIoS/JWSheksu9AYnUF7XIR6TtAAyQ+/TM/Znffmzjoeuh4w4EXLnyJtjCTNWA4Dmvphq X-Gm-Message-State: AOJu0YxU33Qkhheg+FLU09VlEMARYYGLuLjOW0bapaQGvlyojhimliqq gX7A3icUvyZV/J7guKfZ/RQmbPKC/Ln29sxMv5ddpGU28ocx4Tovuh2op3tN X-Google-Smtp-Source: AGHT+IFkxUoMomrjCcrlyw2Ma1YZM1Ps9QdhhBBISPDvxIUztiFgFZzxSNqBXt9ZgsqkrjuYkbXV/w== X-Received: by 2002:a05:6e02:1a21:b0:39a:13e3:9176 with SMTP id e9e14a558f8ab-39d26d02582mr10702805ab.15.1723758104399; Thu, 15 Aug 2024 14:41:44 -0700 (PDT) Received: from jshao-Precision-Tower-3620.tail18e7e.ts.net ([129.93.161.236]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39d28e13cd8sm642125ab.22.2024.08.15.14.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 14:41: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 v3 2/3] tcp_cubic: fix to match Reno additive increment Date: Thu, 15 Aug 2024 16:40:34 -0500 Message-Id: <20240815214035.1145228-3-mrzhang97@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815214035.1145228-1-mrzhang97@gmail.com> References: <20240815214035.1145228-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: Corrent 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 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 21:40:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingrui Zhang X-Patchwork-Id: 13765216 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) (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 AE4C91537D9 for ; Thu, 15 Aug 2024 21:41:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723758112; cv=none; b=prafxRiChYCY7N8kpIXFe8VIUCx5zkQMG03lvUNKlnnYqD92o1fT2XQo6SmF55F7VHgBkf5zfQkZb+FDKoGW1yzUNdt0J3f6m4Uctf++sd2E94E984fpwAjd/bfhNnU+IkIuE6ynLZSS7Uw35iVWhzaf5Nx8dCde41W+PIUQIYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723758112; c=relaxed/simple; bh=4XKDJ2bCqnBWJ8j950CFtg4kuxeFoCoq9gkSPMwTOeY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DPKqpyAggHUfQRw+ovnu3IyIhJY7DKhs5Cv+qnAIMfUrukME2dkv6cZE7yoZXGcEXhW2iO77401xfnGLKQgJSM3bIUJZLS4qSGbTSdzC0RNjoKuT4w2VQ9OwuSKscYAEFhYMYKc7vWVZJ2KvrO2OBHBmQXUSIf3ws7rJ5UlZ6uQ= 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=iuZlv9KJ; arc=none smtp.client-ip=209.85.166.46 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="iuZlv9KJ" Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-81fd1e1d38bso72924839f.1 for ; Thu, 15 Aug 2024 14:41:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723758110; x=1724362910; 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=bXaU+LmZo4dJEO29WyuVDJEWmFHTosV3Q9/izfCnvaI=; b=iuZlv9KJnbBp/X6699OkTyAPFGxuF84AafihKgnWsZz0MO19qybwJ/tKdIr5rP2N7i gOmfbyVks4CpjiPhfDuWhgs4OSdJbIIylIS7TwgD4YCEWlhD9MSWFOGLfTQDjvdjTwWi tJvDu/EUORIwbmr8GPVt45PFHDr1fbit7DmZ9IGLN9hW2TCHJJDh2n6AowFaC0RXx3Qb 7louClVD18MKL5eHA7Go/fCGT7hzN0jjd6oQdxwGwLh5Tyis17GLBBVjInwqposiPs6L viAOdeuC9UpQq3jWJjOYLXgfnyE4ji1zaMF5+PnO5RpuPpvChhXJq6UDcB0cWJAE8gcz 2RTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723758110; x=1724362910; 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=bXaU+LmZo4dJEO29WyuVDJEWmFHTosV3Q9/izfCnvaI=; b=Wnjr2SV7TrVmrC9EgJMjHfmAwkkmXse9nvdkAiXh6tu8fxjDb8xi9/WYS78Jumz7Ks QG2MIWyBOVx2jlVF/BHTVH7P2rN/KKokXzUrKGPbxQ7UvLfKQsTOWqag8D87OdG8P7Or TtOcrY49j0aDt517t71io5O/FqphanARwTQ9J4fNsDQnjRhavCf1wIMQ5tyxjuzxvyfL dFVsL3DJK2EDBml04gGceJqqO5R2bpAYUzzFmIfsQJWtgwushVDWj+2ydlwhVmJOXECO zT303sUZ8yOR6hCrsuEo+N2AY53MzALnwI6PW9E1nW2jjViiRINYsSoaNigMMQnlEVTc YTtg== X-Forwarded-Encrypted: i=1; AJvYcCV5ButFz7WBbkwteRP3fP6yhd5TbWtz4/cNGMQBUqLX4LErmdc0udbFXOPBhhjNnK/8JRPZd3ST5aFmmquxEFs8tB5o0Tmc X-Gm-Message-State: AOJu0YxAHyz6alB2Z/v2JBeZ7jxx7S/molKnK0yERNbmB7fKSr4psa3/ tT0tqBTKr9fz1nw6S9J3yWvFCB9qwv3SUXjGWIWsvNQGumd5dXx1 X-Google-Smtp-Source: AGHT+IF8gD8L/u7JWscMIjLHOXrnEZCMtvWWBvRBSRlQeAo3Yprnsl87czA4vhAVzek2zM0OYo+9rw== X-Received: by 2002:a05:6e02:20ce:b0:39a:e9f4:87b7 with SMTP id e9e14a558f8ab-39d26d71a00mr12535415ab.26.1723758109692; Thu, 15 Aug 2024 14:41:49 -0700 (PDT) Received: from jshao-Precision-Tower-3620.tail18e7e.ts.net ([129.93.161.236]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39d28e13cd8sm642125ab.22.2024.08.15.14.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 14:41:49 -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 v3 3/3] tcp_cubic: fix to use emulated Reno cwnd one RTT in the future Date: Thu, 15 Aug 2024 16:40:35 -0500 Message-Id: <20240815214035.1145228-4-mrzhang97@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815214035.1145228-1-mrzhang97@gmail.com> References: <20240815214035.1145228-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 --- v2->v3: Corrent the "Fixes:" footer content v1->v2: Separate patches 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;