Patchwork [net-next,04/15] tcp: convert retransmit_cnt_hint to seqno

login
register
mail settings
Submitter Ilpo Järvinen
Date Sept. 20, 2008, 5:52 p.m.
Message ID <1221933153-11874-5-git-send-email-ilpo.jarvinen@helsinki.fi>
Download mbox | patch
Permalink /patch/727/
State Rejected
Headers show

Comments

Ilpo Järvinen - Sept. 20, 2008, 5:52 p.m.
Main benefit in this is that we can then freely point
the retransmit_skb_hint to anywhere we want to because
there's no longer need to know what would be the count
changes involve, and since this is really used only as a
terminator, unnecessary work is one time walk at most,
and if some retransmissions are necessary after that
point later on, the walk is not full waste of time
anyway.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
---
 include/linux/tcp.h   |    2 +-
 include/net/tcp.h     |    3 +++
 net/ipv4/tcp_input.c  |   12 +++++++++---
 net/ipv4/tcp_output.c |   16 +++++-----------
 4 files changed, 18 insertions(+), 15 deletions(-)
Ilpo Järvinen - Sept. 20, 2008, 5:59 p.m.
On Sat, 20 Sep 2008, Ilpo Järvinen wrote:

> +
> +	if (!tp->lost_out ||

Never-mind about this patchset, this is a broken to begin with in certain 
cases where we weren't that lucky (once a again the right after posting I 
notice a problem :-)). The problem is basically that we do increments for 
lost_out in many place before calling the verify. I'll fix it and repost 
once I get that done.
David Miller - Sept. 20, 2008, 8:36 p.m.
From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
Date: Sat, 20 Sep 2008 20:59:29 +0300 (EEST)

> On Sat, 20 Sep 2008, Ilpo Järvinen wrote:
> 
> > +
> > +	if (!tp->lost_out ||
> 
> Never-mind about this patchset, this is a broken to begin with in certain 
> cases where we weren't that lucky (once a again the right after posting I 
> notice a problem :-)). The problem is basically that we do increments for 
> lost_out in many place before calling the verify. I'll fix it and repost 
> once I get that done.

Ok, I'll drop these patches :)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 2e25573..d7637c4 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -358,7 +358,7 @@  struct tcp_sock {
 					 */
 
 	int     lost_cnt_hint;
-	int     retransmit_cnt_hint;
+	u32     retransmit_high;	/* L-bits may be on up to this seqno */
 
 	u32	lost_retrans_low;	/* Sent seq after any rxmit (lowest) */
 
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 38551bb..9be41c9 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1044,6 +1044,9 @@  static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp)
 	tp->forward_skb_hint = NULL;
 }
 
+extern void tcp_verify_retransmit_hint(struct tcp_sock *tp,
+				       struct sk_buff *skb);
+
 /* MD5 Signature */
 struct crypto_hash;
 
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index f46c7fe..84935cf 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -984,12 +984,16 @@  static void tcp_update_reordering(struct sock *sk, const int metric,
  * retransmitted past LOST markings in the first place? I'm not fully sure
  * about undo and end of connection cases, which can cause R without L?
  */
-static void tcp_verify_retransmit_hint(struct tcp_sock *tp, struct sk_buff *skb)
+void tcp_verify_retransmit_hint(struct tcp_sock *tp, struct sk_buff *skb)
 {
-	if ((tp->retransmit_skb_hint != NULL) &&
+	if ((tp->retransmit_skb_hint == NULL) ||
 	    before(TCP_SKB_CB(skb)->seq,
 		   TCP_SKB_CB(tp->retransmit_skb_hint)->seq))
-		tp->retransmit_skb_hint = NULL;
+		tp->retransmit_skb_hint = skb;
+
+	if (!tp->lost_out ||
+	    after(TCP_SKB_CB(skb)->end_seq, tp->retransmit_high))
+		tp->retransmit_high = TCP_SKB_CB(skb)->end_seq;
 }
 
 static void __tcp_skb_mark_lost(struct tcp_sock *tp, struct sk_buff *skb)
@@ -1888,6 +1892,7 @@  static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag)
 		if (!(TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)) {
 			TCP_SKB_CB(skb)->sacked |= TCPCB_LOST;
 			tp->lost_out += tcp_skb_pcount(skb);
+			tp->retransmit_high = TCP_SKB_CB(skb)->end_seq;
 		}
 	}
 	tcp_verify_left_out(tp);
@@ -1972,6 +1977,7 @@  void tcp_enter_loss(struct sock *sk, int how)
 			TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_ACKED;
 			TCP_SKB_CB(skb)->sacked |= TCPCB_LOST;
 			tp->lost_out += tcp_skb_pcount(skb);
+			tp->retransmit_high = TCP_SKB_CB(skb)->end_seq;
 		}
 	}
 	tcp_verify_left_out(tp);
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 1b8d980..fbe10f4 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1851,6 +1851,7 @@  void tcp_simple_retransmit(struct sock *sk)
 				tcp_skb_mark_lost(tp, skb);
 				lost = 1;
 			}
+			tcp_verify_retransmit_hint(tp, skb);
 		}
 	}
 
@@ -2006,15 +2007,11 @@  void tcp_xmit_retransmit_queue(struct sock *sk)
 	const struct inet_connection_sock *icsk = inet_csk(sk);
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct sk_buff *skb;
-	int packet_cnt;
 
-	if (tp->retransmit_skb_hint) {
+	if (tp->retransmit_skb_hint)
 		skb = tp->retransmit_skb_hint;
-		packet_cnt = tp->retransmit_cnt_hint;
-	} else {
+	else
 		skb = tcp_write_queue_head(sk);
-		packet_cnt = 0;
-	}
 
 	/* First pass: retransmit lost packets. */
 	if (tp->lost_out) {
@@ -2025,7 +2022,6 @@  void tcp_xmit_retransmit_queue(struct sock *sk)
 				break;
 			/* we could do better than to assign each time */
 			tp->retransmit_skb_hint = skb;
-			tp->retransmit_cnt_hint = packet_cnt;
 
 			/* Assume this retransmit will generate
 			 * only one packet for congestion window
@@ -2036,6 +2032,8 @@  void tcp_xmit_retransmit_queue(struct sock *sk)
 			 */
 			if (tcp_packets_in_flight(tp) >= tp->snd_cwnd)
 				return;
+			if (!before(TCP_SKB_CB(skb)->seq, tp->retransmit_high))
+				break;
 
 			if (sacked & TCPCB_LOST) {
 				if (!(sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS))) {
@@ -2056,10 +2054,6 @@  void tcp_xmit_retransmit_queue(struct sock *sk)
 									  inet_csk(sk)->icsk_rto,
 									  TCP_RTO_MAX);
 				}
-
-				packet_cnt += tcp_skb_pcount(skb);
-				if (packet_cnt >= tp->lost_out)
-					break;
 			}
 		}
 	}