aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
authorIlpo Järvinen <ilpo.jarvinen@helsinki.fi>2009-03-14 18:45:16 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-15 23:09:55 -0400
commit2a3a041c4e2c1685e668b280c121a5a40a029a03 (patch)
treedab327c0cbebec79968c3c2207d064a9152857f0 /net/ipv4/tcp.c
parent0c54b85f2828128274f319a1eb3ce7f604fe2a53 (diff)
tcp: cache result of earlier divides when mss-aligning things
The results is very unlikely change every so often so we hardly need to divide again after doing that once for a connection. Yet, if divide still becomes necessary we detect that and do the right thing and again settle for non-divide state. Takes the u16 space which was previously taken by the plain xmit_size_goal. This should take care part of the tso vs non-tso difference we found earlier. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r--net/ipv4/tcp.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 886596ff0aae..0db9f3b984f7 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -665,7 +665,7 @@ static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now,
665 int large_allowed) 665 int large_allowed)
666{ 666{
667 struct tcp_sock *tp = tcp_sk(sk); 667 struct tcp_sock *tp = tcp_sk(sk);
668 u32 xmit_size_goal; 668 u32 xmit_size_goal, old_size_goal;
669 669
670 xmit_size_goal = mss_now; 670 xmit_size_goal = mss_now;
671 671
@@ -676,7 +676,17 @@ static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now,
676 tp->tcp_header_len); 676 tp->tcp_header_len);
677 677
678 xmit_size_goal = tcp_bound_to_half_wnd(tp, xmit_size_goal); 678 xmit_size_goal = tcp_bound_to_half_wnd(tp, xmit_size_goal);
679 xmit_size_goal -= (xmit_size_goal % mss_now); 679
680 /* We try hard to avoid divides here */
681 old_size_goal = tp->xmit_size_goal_segs * mss_now;
682
683 if (likely(old_size_goal <= xmit_size_goal &&
684 old_size_goal + mss_now > xmit_size_goal)) {
685 xmit_size_goal = old_size_goal;
686 } else {
687 tp->xmit_size_goal_segs = xmit_size_goal / mss_now;
688 xmit_size_goal = tp->xmit_size_goal_segs * mss_now;
689 }
680 } 690 }
681 691
682 return xmit_size_goal; 692 return xmit_size_goal;