Skip to contentSkip to conversation

: Reorganize struct tcp_sock to save 16 bytes on 64-bit arch

PATCH In review Arnaldo Carvalho de Melo 2 participants 4 messages Jan 31, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 6/6 : Reorganize struct tcp_sock to save 16 bytes on 64-bit arch

/home/acme/git/net-2.6/net/ipv6/tcp_ipv6.c:

  struct tcp_sock  |  -16
  struct tcp6_sock |  -16

2 structs changed

Now it is at:

/* size: 1552, cachelines: 25 */
/* paddings: 2, sum paddings: 8 */
/* last cacheline: 16 bytes */

As soon as we stop using skb_queue_list we'll get it down to 24 cachelines.

---
 include/linux/tcp.h |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
include/linux/tcp.h +4 -2
index 08027f1..f48644d 100644
@@ -304,7 +304,6 @@ struct tcp_sock {
 	u32	rtt_seq;	/* sequence number to update rttvar	*/
 
 	u32	packets_out;	/* Packets which are "in flight"	*/
-	u32	retrans_out;	/* Retransmitted packets out		*/
 /*
  *      Options received (usually on last packet, some only on SYN packets).
  */
@@ -332,6 +331,8 @@ struct tcp_sock {
 
 	struct tcp_sack_block recv_sack_cache[4];
 
+	u32	retrans_out;	/* Retransmitted packets out		*/
+
 	struct sk_buff *highest_sack;   /* highest skb with SACK received
 					 * (validity guaranteed only if
 					 * sacked_out > 0)
@@ -372,7 +373,6 @@ struct tcp_sock {
 
 	unsigned int		keepalive_time;	  /* time before keep alive takes place */
 	unsigned int		keepalive_intvl;  /* time interval between keep alive probes */
-	int			linger2;
 
 	unsigned long last_synq_overflow; 
 
@@ -398,6 +398,8 @@ struct tcp_sock {
 		u32		  probe_seq_end;
 	} mtu_probe;
 
+	int			linger2;
+
 #ifdef CONFIG_TCP_MD5SIG
 /* TCP AF-Specific parts; only used by MD5 Signature support so far */
 	struct tcp_sock_af_ops	*af_specific;
Signature · 1 line
1.5.3.8
#1 lore raw
Quoted 31 lines · Arnaldo Carvalho de Melo

/home/acme/git/net-2.6/net/ipv6/tcp_ipv6.c:

  struct tcp_sock  |  -16
  struct tcp6_sock |  -16

2 structs changed

Now it is at:

/* size: 1552, cachelines: 25 */
/* paddings: 2, sum paddings: 8 */
/* last cacheline: 16 bytes */

As soon as we stop using skb_queue_list we'll get it down to 24 cachelines.

---
 include/linux/tcp.h |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
include/linux/tcp.h +0 -1
index 08027f1..f48644d 100644
@@ -304,7 +304,6 @@ struct tcp_sock {
 	u32	rtt_seq;	/* sequence number to update rttvar	*/
 
 	u32	packets_out;	/* Packets which are "in flight"	*/
-	u32	retrans_out;	/* Retransmitted packets out		*/
 /*
  *      Options received (usually on last packet, some only on SYN packets).
  */

include/linux/tcp.h struct tcp_sock { · line 335

Quoted 5 lines
include/linux/tcp.h +2 -0
@@ -332,6 +331,8 @@ struct tcp_sock {
 
 	struct tcp_sack_block recv_sack_cache[4];
 
+	u32	retrans_out;	/* Retransmitted packets out		*/
+

Hum... retrans_out should sit close to packets_out (or lost_out/sacked_out ???), please.

'struct tcp_sock' is very large on 64 bits, so I would prefer to make sure most paths dont need to touch all 24 cache lines (or 25 cache lines).

#2 lore raw
In reply to Arnaldo Carvalho de Melo

Em Thu, Jan 31, 2008 at 08:57:53PM +0100, Eric Dumazet escreveu:

Quoted 38 lines
Quoted 30 lines · Arnaldo Carvalho de Melo

/home/acme/git/net-2.6/net/ipv6/tcp_ipv6.c:

  struct tcp_sock  |  -16
  struct tcp6_sock |  -16

2 structs changed

Now it is at:

/* size: 1552, cachelines: 25 */
/* paddings: 2, sum paddings: 8 */
/* last cacheline: 16 bytes */

As soon as we stop using skb_queue_list we'll get it down to 24 cachelines.

---
 include/linux/tcp.h |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
include/linux/tcp.h +0 -1
index 08027f1..f48644d 100644
@@ -304,7 +304,6 @@ struct tcp_sock {
 	u32	rtt_seq;	/* sequence number to update rttvar	*/
  	u32	packets_out;	/* Packets which are "in flight"	*/
-	u32	retrans_out;	/* Retransmitted packets out		*/
 /*
  *      Options received (usually on last packet, some only on SYN packets).
  */

include/linux/tcp.h struct tcp_sock { · line 333

Quoted 3 lines
include/linux/tcp.h +1 -0
@@ -332,6 +331,8 @@ struct tcp_sock {
  	struct tcp_sack_block recv_sack_cache[4];
 +	u32	retrans_out;	/* Retransmitted packets out		*/
+

Hum... retrans_out should sit close to packets_out (or lost_out/sacked_out ???), please.

Quoted 2 lines

'struct tcp_sock' is very large on 64 bits, so I would prefer to make sure most paths dont need to touch all 24 cache lines (or 25 cache lines).

That is perfectly fine, I'll replace my patch with another, that states this beyond doubt.

- Arnaldo

#3 lore raw
In reply to Arnaldo Carvalho de Melo

Em Thu, Jan 31, 2008 at 06:17:20PM -0200, Arnaldo Carvalho de Melo escreveu:

Quoted 9 lines

Em Thu, Jan 31, 2008 at 08:57:53PM +0100, Eric Dumazet escreveu:

Quoted 5 lines

Hum... retrans_out should sit close to packets_out (or lost_out/sacked_out ???), please.

'struct tcp_sock' is very large on 64 bits, so I would prefer to make sure most paths dont need to touch all 24 cache lines (or 25 cache lines).

That is perfectly fine, I'll replace my patch with another, that states this beyond doubt.

David, I just removed this patch from my net-2.6 tree, if you are ok with the others, please pull.

- Arnaldo