From owner-svn-src-projects@FreeBSD.ORG Thu Aug 6 17:34:16 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B7BC106564A; Thu, 6 Aug 2009 17:34:16 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A4AB8FC18; Thu, 6 Aug 2009 17:34:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n76HYGWE061144; Thu, 6 Aug 2009 17:34:16 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n76HYGiu061143; Thu, 6 Aug 2009 17:34:16 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <200908061734.n76HYGiu061143@svn.freebsd.org> From: Lawrence Stewart Date: Thu, 6 Aug 2009 17:34:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196083 - projects/tcp_ffcaia2008_8.x/sys/netinet X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Aug 2009 17:34:16 -0000 Author: lstewart Date: Thu Aug 6 17:34:15 2009 New Revision: 196083 URL: http://svn.freebsd.org/changeset/base/196083 Log: Keep a sender-side tally of the total number of bytes outstanding at the receiver when SACK is in use. This allows us to *accurately* gauge how much of the outstanding window of data is actually sitting in the receiver's buffers. This in turn will be used by follow up work to improve fast recovery performance for SACK enabled connections. Sponsored by: FreeBSD Foundation Modified: projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_input.c projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_sack.c projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_var.h Modified: projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_input.c ============================================================================== --- projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_input.c Thu Aug 6 09:07:07 2009 (r196082) +++ projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_input.c Thu Aug 6 17:34:15 2009 (r196083) @@ -2073,8 +2073,8 @@ tcp_do_segment(struct mbuf *m, struct tc /* * Compute the amount of data in flight first. - * We can inject new data into the pipe iff - * we have less than 1/2 the original window's + * We can inject new data into the pipe iff + * we have less than 1/2 the original window's * worth of data in flight. */ awnd = (tp->snd_nxt - tp->snd_fack) + Modified: projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_sack.c ============================================================================== --- projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_sack.c Thu Aug 6 09:07:07 2009 (r196082) +++ projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_sack.c Thu Aug 6 17:34:15 2009 (r196083) @@ -316,6 +316,8 @@ tcp_sackhole_insert(struct tcpcb *tp, tc else TAILQ_INSERT_TAIL(&tp->snd_holes, hole, scblink); + tp->sack_hole_bytes += hole->end - hole->start; + /* Update SACK hint. */ if (tp->sack_nexthole == NULL) tp->sack_nexthole = hole; @@ -337,8 +339,22 @@ tcp_sackhole_remove(struct tcpcb *tp, st /* Remove this SACK hole. */ TAILQ_REMOVE(&tp->snd_holes, hole, scblink); + tp->sack_hole_bytes -= hole->end - hole->start; + /* Free this SACK hole. */ tcp_sackhole_free(tp, hole); + + /* +#ifdef INVARIANTS + if (TAILQ_EMPTY(&tp->snd_holes)) + KASSERT(tp->sack_hole_bytes == 0, + ("tp->sack_hole_bytes is %d instead of 0", tp->sack_hole_bytes)); +#endif + */ + if (TAILQ_EMPTY(&tp->snd_holes) && tp->sack_hole_bytes != 0) { + printf("tp->sack_hole_bytes is %d instead of 0", tp->sack_hole_bytes); + tp->sack_hole_bytes = 0; + } } /* @@ -499,14 +515,16 @@ tcp_sack_doack(struct tcpcb *tp, struct */ continue; } else { - /* Move start of hole forward. */ + /* Shrink hole: slide start of hole forward. */ + tp->sack_hole_bytes -= sblkp->end - cur->start; cur->start = sblkp->end; cur->rxmit = SEQ_MAX(cur->rxmit, cur->start); } } else { /* Data acks at least the end of hole. */ if (SEQ_GEQ(sblkp->end, cur->end)) { - /* Move end of hole backward. */ + /* Shrink hole: slide end of hole backward. */ + tp->sack_hole_bytes -= sblkp->start - cur->end; cur->end = sblkp->start; cur->rxmit = SEQ_MIN(cur->rxmit, cur->end); } else { @@ -523,6 +541,20 @@ tcp_sack_doack(struct tcpcb *tp, struct += (temp->rxmit - temp->start); } + /* + * Adjust tp->sack_hole_bytes specially + * here because tcp_sackhole_insert + * adds bytes to the tally that were + * already accounted for. Undo the + * addition of cur->end-sblkp->end bytes + * and also adjust for number of bytes + * in the sack block i.e. + * sblkp->end-sblkp->start + */ + tp->sack_hole_bytes -= cur->end - + sblkp->end - + sblkp->end + + sblkp->start; cur->end = sblkp->start; cur->rxmit = SEQ_MIN(cur->rxmit, cur->end); Modified: projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_var.h ============================================================================== --- projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_var.h Thu Aug 6 09:07:07 2009 (r196082) +++ projects/tcp_ffcaia2008_8.x/sys/netinet/tcp_var.h Thu Aug 6 17:34:15 2009 (r196083) @@ -186,6 +186,8 @@ struct tcpcb { episode starts at this seq number */ struct sackhole *sack_nexthole; /* next hole to rexmt */ int sack_bytes_rexmit; /* # bytes rexmt this RTT */ + int sack_hole_bytes; /* # bytes not yet sacked by rcv'r + this recovery episode */ int t_rttlow; /* smallest observerved RTT */ u_int32_t rfbuf_ts; /* recv buffer autoscaling timestamp */ int rfbuf_cnt; /* recv buffer autoscaling byte count */