netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] tcp: tcp_make_synack() minor changes
@ 2014-03-26 16:57 Eric Dumazet
  2014-03-26 18:25 ` David Miller
  2014-03-27 19:10 ` David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Eric Dumazet @ 2014-03-26 16:57 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

From: Eric Dumazet <edumazet@google.com>

There is no need to allocate 15 bytes in excess for a SYNACK packet,
as it contains no data, only headers.

SYNACK are always generated in softirq context, and contain a single
segment, we can use TCP_INC_STATS_BH()

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

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index e0a7b33fe953..3d2124d2cc4a 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2741,7 +2741,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
 	int tcp_header_size;
 	int mss;
 
-	skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15, 1, GFP_ATOMIC);
+	skb = sock_wmalloc(sk, MAX_TCP_HEADER, 1, GFP_ATOMIC);
 	if (unlikely(!skb)) {
 		dst_release(dst);
 		return NULL;
@@ -2811,7 +2811,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
 	th->window = htons(min(req->rcv_wnd, 65535U));
 	tcp_options_write((__be32 *)(th + 1), tp, &opts);
 	th->doff = (tcp_header_size >> 2);
-	TCP_ADD_STATS(sock_net(sk), TCP_MIB_OUTSEGS, tcp_skb_pcount(skb));
+	TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_OUTSEGS);
 
 #ifdef CONFIG_TCP_MD5SIG
 	/* Okay, we have all we need - do the md5 hash if needed */

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

* Re: [PATCH net-next] tcp: tcp_make_synack() minor changes
  2014-03-26 16:57 [PATCH net-next] tcp: tcp_make_synack() minor changes Eric Dumazet
@ 2014-03-26 18:25 ` David Miller
  2014-03-26 18:52   ` Joe Perches
  2014-03-26 19:08   ` Eric Dumazet
  2014-03-27 19:10 ` David Miller
  1 sibling, 2 replies; 7+ messages in thread
From: David Miller @ 2014-03-26 18:25 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 26 Mar 2014 09:57:19 -0700

> From: Eric Dumazet <edumazet@google.com>
> 
> There is no need to allocate 15 bytes in excess for a SYNACK packet,
> as it contains no data, only headers.
> 
> SYNACK are always generated in softirq context, and contain a single
> segment, we can use TCP_INC_STATS_BH()
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
 ...
> -	skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15, 1, GFP_ATOMIC);
> +	skb = sock_wmalloc(sk, MAX_TCP_HEADER, 1, GFP_ATOMIC);

Do you know where this "+ 15" comes from? :-)

It is a kind of Linux networking trivia question.

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

* Re: [PATCH net-next] tcp: tcp_make_synack() minor changes
  2014-03-26 18:25 ` David Miller
@ 2014-03-26 18:52   ` Joe Perches
  2014-03-26 19:11     ` David Miller
  2014-03-26 19:08   ` Eric Dumazet
  1 sibling, 1 reply; 7+ messages in thread
From: Joe Perches @ 2014-03-26 18:52 UTC (permalink / raw)
  To: David Miller; +Cc: eric.dumazet, netdev

On Wed, 2014-03-26 at 14:25 -0400, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Wed, 26 Mar 2014 09:57:19 -0700
> 
> > From: Eric Dumazet <edumazet@google.com>
> > 
> > There is no need to allocate 15 bytes in excess for a SYNACK packet,
> > as it contains no data, only headers.
> > 
> > SYNACK are always generated in softirq context, and contain a single
> > segment, we can use TCP_INC_STATS_BH()
> > 
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
>  ...
> > -	skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15, 1, GFP_ATOMIC);
> > +	skb = sock_wmalloc(sk, MAX_TCP_HEADER, 1, GFP_ATOMIC);
> 
> Do you know where this "+ 15" comes from? :-)
> It is a kind of Linux networking trivia question.

It's really old, pre v1 days.
I presume it was some kind of ethernet minimum packet size padding.

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

* Re: [PATCH net-next] tcp: tcp_make_synack() minor changes
  2014-03-26 18:25 ` David Miller
  2014-03-26 18:52   ` Joe Perches
@ 2014-03-26 19:08   ` Eric Dumazet
  2014-03-26 19:12     ` David Miller
  1 sibling, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2014-03-26 19:08 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

On Wed, 2014-03-26 at 14:25 -0400, David Miller wrote:
> Do you know where this "+ 15" comes from? :-)
> 
> It is a kind of Linux networking trivia question.

My random guess would be that it is related to a copy/paste
thing, as some tx paths used to allocate skb with a very precise byte
count, and they used HH_DATA_ALIGN().

MAX_TCP_HEADER already includes all needed extra room.

Note tcp_connect() also uses this +15, but not tcp_send_ack() or
tcp_send_active_reset()...

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

* Re: [PATCH net-next] tcp: tcp_make_synack() minor changes
  2014-03-26 18:52   ` Joe Perches
@ 2014-03-26 19:11     ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2014-03-26 19:11 UTC (permalink / raw)
  To: joe; +Cc: eric.dumazet, netdev

From: Joe Perches <joe@perches.com>
Date: Wed, 26 Mar 2014 11:52:48 -0700

> On Wed, 2014-03-26 at 14:25 -0400, David Miller wrote:
>> From: Eric Dumazet <eric.dumazet@gmail.com>
>> Date: Wed, 26 Mar 2014 09:57:19 -0700
>> 
>> > From: Eric Dumazet <edumazet@google.com>
>> > 
>> > There is no need to allocate 15 bytes in excess for a SYNACK packet,
>> > as it contains no data, only headers.
>> > 
>> > SYNACK are always generated in softirq context, and contain a single
>> > segment, we can use TCP_INC_STATS_BH()
>> > 
>> > Signed-off-by: Eric Dumazet <edumazet@google.com>
>>  ...
>> > -	skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15, 1, GFP_ATOMIC);
>> > +	skb = sock_wmalloc(sk, MAX_TCP_HEADER, 1, GFP_ATOMIC);
>> 
>> Do you know where this "+ 15" comes from? :-)
>> It is a kind of Linux networking trivia question.
> 
> It's really old, pre v1 days.
> I presume it was some kind of ethernet minimum packet size padding.

I'm pretty sure it was to accomodate the hard header cache.

HH_DATA_MOD is 16

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

* Re: [PATCH net-next] tcp: tcp_make_synack() minor changes
  2014-03-26 19:08   ` Eric Dumazet
@ 2014-03-26 19:12     ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2014-03-26 19:12 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 26 Mar 2014 12:08:47 -0700

> On Wed, 2014-03-26 at 14:25 -0400, David Miller wrote:
>> Do you know where this "+ 15" comes from? :-)
>> 
>> It is a kind of Linux networking trivia question.
> 
> My random guess would be that it is related to a copy/paste
> thing, as some tx paths used to allocate skb with a very precise byte
> count, and they used HH_DATA_ALIGN().

Yes, this is exactly it.

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

* Re: [PATCH net-next] tcp: tcp_make_synack() minor changes
  2014-03-26 16:57 [PATCH net-next] tcp: tcp_make_synack() minor changes Eric Dumazet
  2014-03-26 18:25 ` David Miller
@ 2014-03-27 19:10 ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2014-03-27 19:10 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 26 Mar 2014 09:57:19 -0700

> From: Eric Dumazet <edumazet@google.com>
> 
> There is no need to allocate 15 bytes in excess for a SYNACK packet,
> as it contains no data, only headers.
> 
> SYNACK are always generated in softirq context, and contain a single
> segment, we can use TCP_INC_STATS_BH()
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied, thanks.

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

end of thread, other threads:[~2014-03-27 19:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-26 16:57 [PATCH net-next] tcp: tcp_make_synack() minor changes Eric Dumazet
2014-03-26 18:25 ` David Miller
2014-03-26 18:52   ` Joe Perches
2014-03-26 19:11     ` David Miller
2014-03-26 19:08   ` Eric Dumazet
2014-03-26 19:12     ` David Miller
2014-03-27 19:10 ` 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).