YATCPP (Yet another TCP patch): writev coallesing

Eric.Schenk@dna.lth.se
Mon, 12 May 1997 20:52:10 +0200


It was recently noticed that Linux did not pack data send with
a single writev into the smallest number of packets possible.
This patch fixes this. Doing a writev with a number of small
buffers will now result in a single packet.

Again this patch goes over pre-2.0.31. Anyone who is testing pre-2.0.31
should apply this patch so we can be sure it does not introduce any new
problems. As usual problem reports to me.

Cheers,

diff -u -r1.28.2.13 -r1.28.2.14
--- old-linux/net/ipv4/tcp.c 1997/05/05 21:58:25 1.28.2.13
+++ linux/net/ipv4/tcp.c 1997/05/12 11:52:09 1.28.2.14
@@ -1260,7 +1260,10 @@
sk->write_seq += copy;
seglen -= copy;
}
- if (tcp_size >= sk->mss || (flags & MSG_OOB) || !sk->packets_out)
+ /* If we have a full packet or a new OOB
+ * message, we have to force this packet out.
+ */
+ if (tcp_size >= sk->mss || (flags & MSG_OOB))
tcp_send_skb(sk, skb);
else
tcp_enqueue_partial(skb, sk);
@@ -1296,8 +1299,14 @@

delay = 0;
tmp = copy + sk->prot->max_header + 15;
- if (copy < sk->mss && !(flags & MSG_OOB) && sk->packets_out)
- {
+ /* If won't fill the current packet, and it's not an OOB message,
+ * then we might want to delay to allow data in the later parts
+ * of iov to fill this packet out. Note that if we aren't
+ * Nagling or there are no packets currently out then the top
+ * level code in tcp_sendmsg() will force any partial packets out
+ * after we finish building the largest packets this write allows.
+ */
+ if (copy < sk->mss && !(flags & MSG_OOB)) {
tmp = tmp - copy + sk->mtu + 128;
delay = 1;
}

--
Eric Schenk                               www: http://www.dna.lth.se/~erics
Dept. of Comp. Sci., Lund University          email: Eric.Schenk@dna.lth.se
Box 118, S-221 00 LUND, Sweden   fax: +46-46 13 10 21  ph: +46-46 222 96 38