linux/net/ipv4
Arnaldo Carvalho de Melo 2e07fa9cd3 [SK_BUFF]: Use offsets for skb->{mac,network,transport}_header on 64bit architectures
With this we save 8 bytes per network packet, leaving a 4 bytes hole to be used
in further shrinking work, likely with the offsetization of other pointers,
such as ->{data,tail,end}, at the cost of adds, that were minimized by the
usual practice of setting skb->{mac,nh,n}.raw to a local variable that is then
accessed multiple times in each function, it also is not more expensive than
before with regards to most of the handling of such headers, like setting one
of these headers to another (transport to network, etc), or subtracting, adding
to/from it, comparing them, etc.

Now we have this layout for sk_buff on a x86_64 machine:

[acme@mica net-2.6.22]$ pahole vmlinux sk_buff
struct sk_buff {
	struct sk_buff *       next;             /*   0   8 */
	struct sk_buff *       prev;             /*   8   8 */
	struct rb_node         rb;               /*  16  24 */
	struct sock *          sk;               /*  40   8 */
	ktime_t                tstamp;           /*  48   8 */
	struct net_device *    dev;              /*  56   8 */
	/* --- cacheline 1 boundary (64 bytes) --- */
	struct net_device *    input_dev;        /*  64   8 */
	sk_buff_data_t         transport_header; /*  72   4 */
	sk_buff_data_t         network_header;   /*  76   4 */
	sk_buff_data_t         mac_header;       /*  80   4 */

	/* XXX 4 bytes hole, try to pack */

	struct dst_entry *     dst;              /*  88   8 */
	struct sec_path *      sp;               /*  96   8 */
	char                   cb[48];           /* 104  48 */
	/* cacheline 2 boundary (128 bytes) was 24 bytes ago*/
	unsigned int           len;              /* 152   4 */
	unsigned int           data_len;         /* 156   4 */
	unsigned int           mac_len;          /* 160   4 */
	union {
		__wsum         csum;             /*       4 */
		__u32          csum_offset;      /*       4 */
	};                                       /* 164   4 */
	__u32                  priority;         /* 168   4 */
	__u8                   local_df:1;       /* 172   1 */
	__u8                   cloned:1;         /* 172   1 */
	__u8                   ip_summed:2;      /* 172   1 */
	__u8                   nohdr:1;          /* 172   1 */
	__u8                   nfctinfo:3;       /* 172   1 */
	__u8                   pkt_type:3;       /* 173   1 */
	__u8                   fclone:2;         /* 173   1 */
	__u8                   ipvs_property:1;  /* 173   1 */

	/* XXX 2 bits hole, try to pack */

	__be16                 protocol;         /* 174   2 */
	void    (*destructor)(struct sk_buff *); /* 176   8 */
	struct nf_conntrack *  nfct;             /* 184   8 */
	/* --- cacheline 3 boundary (192 bytes) --- */
	struct sk_buff *       nfct_reasm;       /* 192   8 */
	struct nf_bridge_info *nf_bridge;        /* 200   8 */
	__u16                  tc_index;         /* 208   2 */
	__u16                  tc_verd;          /* 210   2 */
	dma_cookie_t           dma_cookie;       /* 212   4 */
	__u32                  secmark;          /* 216   4 */
	__u32                  mark;             /* 220   4 */
	unsigned int           truesize;         /* 224   4 */
	atomic_t               users;            /* 228   4 */
	unsigned char *        head;             /* 232   8 */
	unsigned char *        data;             /* 240   8 */
	unsigned char *        tail;             /* 248   8 */
	/* --- cacheline 4 boundary (256 bytes) --- */
	unsigned char *        end;              /* 256   8 */
}; /* size: 264, cachelines: 5 */
   /* sum members: 260, holes: 1, sum holes: 4 */
   /* bit holes: 1, sum bit holes: 2 bits */
   /* last cacheline: 8 bytes */

On 32 bits nothing changes, and pointers continue to be used with the compiler
turning all this abstraction layer into dust. But there are some sk_buff
validation tricks that are now possible, humm... :-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-25 22:26:21 -07:00
..
ipvs [SK_BUFF]: Use offsets for skb->{mac,network,transport}_header on 64bit architectures 2007-04-25 22:26:21 -07:00
netfilter [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
af_inet.c [SK_BUFF]: Introduce skb_reset_transport_header(skb) 2007-04-25 22:25:15 -07:00
ah4.c [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
arp.c [SK_BUFF]: Introduce arp_hdr(), remove skb->nh.arph 2007-04-25 22:25:12 -07:00
cipso_ipv4.c [SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph 2007-04-25 22:25:10 -07:00
datagram.c
devinet.c [IPV4]: cleanup 2007-04-25 22:24:11 -07:00
esp4.c [SK_BUFF]: Introduce icmp_hdr(), remove skb->h.icmph 2007-04-25 22:25:23 -07:00
fib_frontend.c [NETLINK]: Infinite recursion in netlink. 2007-04-25 13:07:28 -07:00
fib_hash.c [NET]: make seq_operations const 2007-04-25 22:25:03 -07:00
fib_lookup.h
fib_rules.c [NET]: Fix fib_rules compatibility breakage 2007-03-25 18:48:00 -07:00
fib_semantics.c [IPv4] fib: Fix out of bound access of fib_props[] 2007-03-25 18:48:03 -07:00
fib_trie.c [NET]: make seq_operations const 2007-04-25 22:25:03 -07:00
icmp.c [SK_BUFF]: Introduce icmp_hdr(), remove skb->h.icmph 2007-04-25 22:25:23 -07:00
igmp.c [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
inet_connection_sock.c
inet_diag.c
inet_hashtables.c
inet_timewait_sock.c
inetpeer.c [IPV4]: Optimize inet_getpeer() 2007-04-25 22:23:49 -07:00
ip_forward.c [SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph 2007-04-25 22:25:10 -07:00
ip_fragment.c [SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph 2007-04-25 22:25:10 -07:00
ip_gre.c [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
ip_input.c [SK_BUFF]: Introduce skb_reset_transport_header(skb) 2007-04-25 22:25:15 -07:00
ip_options.c [SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph 2007-04-25 22:25:10 -07:00
ip_output.c [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
ip_sockglue.c [SK_BUFF]: More skb_reset_transport_header conversions 2007-04-25 22:25:29 -07:00
ipcomp.c [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
ipconfig.c [SK_BUFF]: Introduce skb_transport_header(skb) 2007-04-25 22:25:31 -07:00
ipip.c [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
ipmr.c [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
Kconfig [TCP] YeAH-TCP: algorithm implementation 2007-04-25 22:23:18 -07:00
Makefile [TCP] YeAH-TCP: algorithm implementation 2007-04-25 22:23:18 -07:00
multipath_drr.c
multipath_random.c
multipath_rr.c
multipath_wrandom.c
multipath.c
netfilter.c [SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph 2007-04-25 22:25:10 -07:00
proc.c
protocol.c
raw.c [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
route.c [SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph 2007-04-25 22:25:10 -07:00
syncookies.c [SK_BUFF]: Introduce tcp_hdr(), remove skb->h.th 2007-04-25 22:25:26 -07:00
sysctl_net_ipv4.c [TCP]: Add two new spurious RTO responses to FRTO 2007-04-25 22:23:23 -07:00
tcp_bic.c
tcp_cong.c [TCP]: Add RFC3742 Limited Slow-Start, controlled by variable sysctl_tcp_max_ssthresh. 2007-04-25 22:23:19 -07:00
tcp_cubic.c [TCP] tcp_cubic: faster cube root 2007-04-25 22:23:47 -07:00
tcp_diag.c
tcp_highspeed.c
tcp_htcp.c
tcp_hybla.c [TCP]: whitespace cleanup 2007-04-25 22:24:13 -07:00
tcp_input.c [SK_BUFF]: Introduce skb_transport_header(skb) 2007-04-25 22:25:31 -07:00
tcp_ipv4.c [SK_BUFF]: Introduce tcp_hdr(), remove skb->h.th 2007-04-25 22:25:26 -07:00
tcp_lp.c
tcp_minisocks.c [SK_BUFF]: Introduce tcp_hdr(), remove skb->h.th 2007-04-25 22:25:26 -07:00
tcp_output.c [SK_BUFF]: Introduce tcp_hdr(), remove skb->h.th 2007-04-25 22:25:26 -07:00
tcp_probe.c
tcp_scalable.c
tcp_timer.c [TCP]: Abstract out all write queue operations. 2007-04-25 22:24:02 -07:00
tcp_vegas.c
tcp_veno.c
tcp_westwood.c [TCP]: whitespace cleanup 2007-04-25 22:24:13 -07:00
tcp_yeah.c [TCP] TCP Yeah: cleanup 2007-04-25 22:23:48 -07:00
tcp_yeah.h [NET]: div64_64 consolidate (rev3) 2007-04-25 22:23:33 -07:00
tcp.c [SK_BUFF]: Introduce skb_transport_header(skb) 2007-04-25 22:25:31 -07:00
tunnel4.c
udp_impl.h
udp.c [SK_BUFF]: Introduce icmp_hdr(), remove skb->h.icmph 2007-04-25 22:25:23 -07:00
udplite.c [UDP]: Clean up UDP-Lite receive checksum 2007-04-25 22:23:51 -07:00
xfrm4_input.c [SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph 2007-04-25 22:25:10 -07:00
xfrm4_mode_beet.c [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
xfrm4_mode_transport.c [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
xfrm4_mode_tunnel.c [SK_BUFF]: unions of just one member don't get anything done, kill them 2007-04-25 22:26:20 -07:00
xfrm4_output.c [SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph 2007-04-25 22:25:10 -07:00
xfrm4_policy.c [SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph 2007-04-25 22:25:10 -07:00
xfrm4_state.c
xfrm4_tunnel.c [SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph 2007-04-25 22:25:10 -07:00