From: Stephen Hemminger <shemminger@vyatta.com>
To: davem@davemloft.net, sangtae.ha@gmail.com, rhee@ncsu.edu
Cc: netdev@vger.kernel.org
Subject: [PATCH 5/6] tcp_cubic: fix clock dependency
Date: Thu, 10 Mar 2011 08:51:27 -0800 [thread overview]
Message-ID: <20110310165329.187344604@vyatta.com> (raw)
In-Reply-To: 20110310165119.224046957@vyatta.com
[-- Attachment #1: tcp-cubic-minrtt.patch --]
[-- Type: text/plain, Size: 3050 bytes --]
The hystart code was written with assumption that HZ=1000.
Replace the use of jiffies with bictcp_clock as a millisecond
real time clock.
Warning: this is still experimental, there may still be mistakes
in units (ms vs. jiffies).
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
P.s: tried using ktime_t but 'struct bictcp' is bumping against limit
of CA_PRIV_SIZE.
--- a/net/ipv4/tcp_cubic.c 2011-03-10 08:35:45.532695373 -0800
+++ b/net/ipv4/tcp_cubic.c 2011-03-10 08:35:59.968882888 -0800
@@ -88,7 +88,7 @@ struct bictcp {
u32 last_time; /* time when updated last_cwnd */
u32 bic_origin_point;/* origin point of bic function */
u32 bic_K; /* time to origin point from the beginning of the current epoch */
- u32 delay_min; /* min delay */
+ u32 delay_min; /* min delay (msec << 3) */
u32 epoch_start; /* beginning of an epoch */
u32 ack_cnt; /* number of acks */
u32 tcp_cwnd; /* estimated tcp cwnd */
@@ -98,7 +98,7 @@ struct bictcp {
u8 found; /* the exit point is found? */
u32 round_start; /* beginning of each round */
u32 end_seq; /* end_seq of the round */
- u32 last_jiffies; /* last time when the ACK spacing is close */
+ u32 last_ack; /* last time when the ACK spacing is close */
u32 curr_rtt; /* the minimum rtt of current round */
};
@@ -119,12 +119,21 @@ static inline void bictcp_reset(struct b
ca->found = 0;
}
+static inline u32 bictcp_clock(void)
+{
+#if HZ < 1000
+ return ktime_to_ms(ktime_get_real());
+#else
+ return jiffies_to_ms(jiffies);
+#endif
+}
+
static inline void bictcp_hystart_reset(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
struct bictcp *ca = inet_csk_ca(sk);
- ca->round_start = ca->last_jiffies = jiffies;
+ ca->round_start = ca->last_ack = bictcp_clock();
ca->end_seq = tp->snd_nxt;
ca->curr_rtt = 0;
ca->sample_cnt = 0;
@@ -239,7 +248,7 @@ static inline void bictcp_update(struct
*/
/* change the unit from HZ to bictcp_HZ */
- t = ((tcp_time_stamp + (ca->delay_min>>3) - ca->epoch_start)
+ t = ((tcp_time_stamp + msecs_to_jiffies(ca->delay_min>>3) - ca->epoch_start)
<< BICTCP_HZ) / HZ;
if (t < ca->bic_K) /* t - K */
@@ -342,14 +351,12 @@ static void hystart_update(struct sock *
struct bictcp *ca = inet_csk_ca(sk);
if (!(ca->found & hystart_detect)) {
- u32 curr_jiffies = jiffies;
+ u32 now = bictcp_clock();
/* first detection parameter - ack-train detection */
- if ((s32)(curr_jiffies - ca->last_jiffies) <=
- msecs_to_jiffies(hystart_ack_delta)) {
- ca->last_jiffies = curr_jiffies;
- if ((s32) (curr_jiffies - ca->round_start) <=
- ca->delay_min >> 4)
+ if ((s32)(now - ca->last_ack) <= hystart_ack_delta) {
+ ca->last_ack = now;
+ if ((s32)(now - ca->round_start) <= ca->delay_min >> 4)
ca->found |= HYSTART_ACK_TRAIN;
}
@@ -396,7 +403,7 @@ static void bictcp_acked(struct sock *sk
if ((s32)(tcp_time_stamp - ca->epoch_start) < HZ)
return;
- delay = usecs_to_jiffies(rtt_us) << 3;
+ delay = (rtt_us << 3) / USEC_PER_MSEC;
if (delay == 0)
delay = 1;
next prev parent reply other threads:[~2011-03-10 16:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-10 16:51 [PATCH 0/6] TCP CUBIC and Hystart Stephen Hemminger
2011-03-10 16:51 ` [PATCH 1/6] tcp: fix RTT for quick packets in congestion control Stephen Hemminger
2011-03-10 16:51 ` [PATCH 2/6] tcp: timestamp code clarification Stephen Hemminger
2011-03-10 16:51 ` [PATCH 3/6] tcp_cubic: fix comparison of jiffies Stephen Hemminger
2011-03-11 9:40 ` Lucas Nussbaum
2011-03-10 16:51 ` [PATCH 4/6] tcp_cubic: make ack train delta value a parameter Stephen Hemminger
2011-03-10 16:51 ` Stephen Hemminger [this message]
2011-03-11 16:26 ` [PATCH 5/6] tcp_cubic: fix clock dependency Sangtae Ha
2011-03-10 16:51 ` [PATCH 6/6] tcp_cubic: enable high resolution ack time if needed Stephen Hemminger
2011-03-11 10:28 ` [PATCH 0/6] TCP CUBIC and Hystart Lucas Nussbaum
2011-03-11 10:49 ` Injong Rhee
2011-03-11 15:58 ` Sangtae Ha
2011-03-11 16:08 ` Lucas Nussbaum
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=20110310165329.187344604@vyatta.com \
--to=shemminger@vyatta.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=rhee@ncsu.edu \
--cc=sangtae.ha@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.