netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] tcp: tcp_tso_segment() small optimization
@ 2013-04-13 13:14 Eric Dumazet
  2013-04-13 13:22 ` [PATCH v2 " Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2013-04-13 13:14 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

From: Eric Dumazet <edumazet@google.com>

We can more th->check computation out of the loop, as compiler
doesn't know each skb initially share same tcp headers after
skb_segment()

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 963bda1..dcb116d 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2886,6 +2886,7 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb,
 	unsigned int oldlen;
 	unsigned int mss;
 	struct sk_buff *gso_skb = skb;
+	__sum16 newcheck;
 
 	if (!pskb_may_pull(skb, sizeof(*th)))
 		goto out;
@@ -2936,11 +2937,13 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb,
 	th = tcp_hdr(skb);
 	seq = ntohl(th->seq);
 
+	newcheck = ~csum_fold((__force __wsum)((__force u32)th->check +
+					       (__force u32)delta));
+
 	do {
 		th->fin = th->psh = 0;
+		th->check = newcheck;
 
-		th->check = ~csum_fold((__force __wsum)((__force u32)th->check +
-				       (__force u32)delta));
 		if (skb->ip_summed != CHECKSUM_PARTIAL)
 			th->check =
 			     csum_fold(csum_partial(skb_transport_header(skb),

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 net-next] tcp: tcp_tso_segment() small optimization
  2013-04-13 13:14 [PATCH net-next] tcp: tcp_tso_segment() small optimization Eric Dumazet
@ 2013-04-13 13:22 ` Eric Dumazet
  2013-04-13 20:56   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2013-04-13 13:22 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

From: Eric Dumazet <edumazet@google.com>

We can move th->check computation out of the loop, as compiler
doesn't know each skb initially share same tcp headers after
skb_segment()

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
v2: Typo in change log : more -> move

 net/ipv4/tcp.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 963bda1..dcb116d 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2886,6 +2886,7 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb,
 	unsigned int oldlen;
 	unsigned int mss;
 	struct sk_buff *gso_skb = skb;
+	__sum16 newcheck;
 
 	if (!pskb_may_pull(skb, sizeof(*th)))
 		goto out;
@@ -2936,11 +2937,13 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb,
 	th = tcp_hdr(skb);
 	seq = ntohl(th->seq);
 
+	newcheck = ~csum_fold((__force __wsum)((__force u32)th->check +
+					       (__force u32)delta));
+
 	do {
 		th->fin = th->psh = 0;
+		th->check = newcheck;
 
-		th->check = ~csum_fold((__force __wsum)((__force u32)th->check +
-				       (__force u32)delta));
 		if (skb->ip_summed != CHECKSUM_PARTIAL)
 			th->check =
 			     csum_fold(csum_partial(skb_transport_header(skb),

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 net-next] tcp: tcp_tso_segment() small optimization
  2013-04-13 13:22 ` [PATCH v2 " Eric Dumazet
@ 2013-04-13 20:56   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2013-04-13 20:56 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sat, 13 Apr 2013 06:22:08 -0700

> From: Eric Dumazet <edumazet@google.com>
> 
> We can move th->check computation out of the loop, as compiler
> doesn't know each skb initially share same tcp headers after
> skb_segment()
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Looks good, applied, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-13 20:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-13 13:14 [PATCH net-next] tcp: tcp_tso_segment() small optimization Eric Dumazet
2013-04-13 13:22 ` [PATCH v2 " Eric Dumazet
2013-04-13 20:56   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).