From: Stephen Hemminger <shemminger@linux-foundation.org>
To: "Angelo P. Castellani" <angelo.castellani@gmail.com>,
"David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org,
Andrea Baiocchi <andrea.baiocchi@uniroma1.it>,
Francesco Vacirca <francesco@net.infocom.uniroma1.it>
Subject: [PATCH] TCP Yeah: cleanup
Date: Tue, 6 Mar 2007 14:56:05 -0800 [thread overview]
Message-ID: <20070306145605.3731d39d@freekitty> (raw)
In-Reply-To: <45D98084.5030907@gmail.com>
Eliminate need for full 6/4/64 divide to compute queue.
Variable maxqueue was really a constant.
Fix indentation.
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
---
net/ipv4/tcp_yeah.c | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
--- net-2.6.22.orig/net/ipv4/tcp_yeah.c 2007-03-06 11:46:34.000000000 -0800
+++ net-2.6.22/net/ipv4/tcp_yeah.c 2007-03-06 11:54:54.000000000 -0800
@@ -74,7 +74,7 @@
}
static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack,
- u32 seq_rtt, u32 in_flight, int flag)
+ u32 seq_rtt, u32 in_flight, int flag)
{
struct tcp_sock *tp = tcp_sk(sk);
struct yeah *yeah = inet_csk_ca(sk);
@@ -142,8 +142,8 @@
*/
if (yeah->cntRTT > 2) {
- u32 rtt;
- u32 queue, maxqueue;
+ u32 rtt, queue;
+ u64 bw;
/* We have enough RTT samples, so, using the Vegas
* algorithm, we determine if we should increase or
@@ -158,32 +158,36 @@
*/
rtt = yeah->minRTT;
- queue = (u32)div64_64((u64)tp->snd_cwnd * (rtt - yeah->baseRTT), rtt);
-
- maxqueue = TCP_YEAH_ALPHA;
-
- if (queue > maxqueue ||
- rtt - yeah->baseRTT > (yeah->baseRTT / TCP_YEAH_PHY)) {
-
- if (queue > maxqueue && tp->snd_cwnd > yeah->reno_count) {
- u32 reduction = min( queue / TCP_YEAH_GAMMA ,
- tp->snd_cwnd >> TCP_YEAH_EPSILON );
+ /* Compute excess number of packets above bandwidth
+ * Avoid doing full 64 bit divide.
+ */
+ bw = tp->snd_cwnd;
+ bw *= rtt - yeah->baseRTT;
+ do_div(bw, rtt);
+ queue = bw;
+
+ if (queue > TCP_YEAH_ALPHA ||
+ rtt - yeah->baseRTT > (yeah->baseRTT / TCP_YEAH_PHY)) {
+ if (queue > TCP_YEAH_ALPHA
+ && tp->snd_cwnd > yeah->reno_count) {
+ u32 reduction = min(queue / TCP_YEAH_GAMMA ,
+ tp->snd_cwnd >> TCP_YEAH_EPSILON);
tp->snd_cwnd -= reduction;
- tp->snd_cwnd = max( tp->snd_cwnd, yeah->reno_count);
+ tp->snd_cwnd = max(tp->snd_cwnd,
+ yeah->reno_count);
tp->snd_ssthresh = tp->snd_cwnd;
- }
+ }
if (yeah->reno_count <= 2)
- yeah->reno_count = max( tp->snd_cwnd>>1, 2U);
+ yeah->reno_count = max(tp->snd_cwnd>>1, 2U);
else
yeah->reno_count++;
- yeah->doing_reno_now =
- min_t( u32, yeah->doing_reno_now + 1 , 0xffffff);
-
+ yeah->doing_reno_now = min(yeah->doing_reno_now + 1,
+ 0xffffffU);
} else {
yeah->fast_count++;
next prev parent reply other threads:[~2007-03-06 22:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-19 10:46 [PATCH 1/2][TCP] YeAH-TCP: algorithm implementation Angelo P. Castellani
2007-02-19 10:48 ` Angelo P. Castellani
2007-03-06 22:56 ` Stephen Hemminger [this message]
2007-03-07 4:21 ` [PATCH] TCP Yeah: cleanup David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070306145605.3731d39d@freekitty \
--to=shemminger@linux-foundation.org \
--cc=andrea.baiocchi@uniroma1.it \
--cc=angelo.castellani@gmail.com \
--cc=davem@davemloft.net \
--cc=francesco@net.infocom.uniroma1.it \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).