diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-11-30 14:04:07 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-09 23:05:58 -0500 |
commit | 68835aba4d9b74e2f94106d13b6a4bddc447c4c8 (patch) | |
tree | 468a9465acfa027791facef13fb6ef5129dda257 /include/net/sock.h | |
parent | defb3519a64141608725e2dac5a5aa9a3c644bae (diff) |
net: optimize INET input path further
Followup of commit b178bb3dfc30 (net: reorder struct sock fields)
Optimize INET input path a bit further, by :
1) moving sk_refcnt close to sk_lock.
This reduces number of dirtied cache lines by one on 64bit arches (and
64 bytes cache line size).
2) moving inet_daddr & inet_rcv_saddr at the beginning of sk
(same cache line than hash / family / bound_dev_if / nulls_node)
This reduces number of accessed cache lines in lookups by one, and dont
increase size of inet and timewait socks.
inet and tw sockets now share same place-holder for these fields.
Before patch :
offsetof(struct sock, sk_refcnt) = 0x10
offsetof(struct sock, sk_lock) = 0x40
offsetof(struct sock, sk_receive_queue) = 0x60
offsetof(struct inet_sock, inet_daddr) = 0x270
offsetof(struct inet_sock, inet_rcv_saddr) = 0x274
After patch :
offsetof(struct sock, sk_refcnt) = 0x44
offsetof(struct sock, sk_lock) = 0x48
offsetof(struct sock, sk_receive_queue) = 0x68
offsetof(struct inet_sock, inet_daddr) = 0x0
offsetof(struct inet_sock, inet_rcv_saddr) = 0x4
compute_score() (udp or tcp) now use a single cache line per ignored
item, instead of two.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r-- | include/net/sock.h | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 3482004e5c29..82e86034702f 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -105,10 +105,8 @@ struct net; | |||
105 | 105 | ||
106 | /** | 106 | /** |
107 | * struct sock_common - minimal network layer representation of sockets | 107 | * struct sock_common - minimal network layer representation of sockets |
108 | * @skc_node: main hash linkage for various protocol lookup tables | 108 | * @skc_daddr: Foreign IPv4 addr |
109 | * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol | 109 | * @skc_rcv_saddr: Bound local IPv4 addr |
110 | * @skc_refcnt: reference count | ||
111 | * @skc_tx_queue_mapping: tx queue number for this connection | ||
112 | * @skc_hash: hash value used with various protocol lookup tables | 110 | * @skc_hash: hash value used with various protocol lookup tables |
113 | * @skc_u16hashes: two u16 hash values used by UDP lookup tables | 111 | * @skc_u16hashes: two u16 hash values used by UDP lookup tables |
114 | * @skc_family: network address family | 112 | * @skc_family: network address family |
@@ -119,20 +117,20 @@ struct net; | |||
119 | * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol | 117 | * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol |
120 | * @skc_prot: protocol handlers inside a network family | 118 | * @skc_prot: protocol handlers inside a network family |
121 | * @skc_net: reference to the network namespace of this socket | 119 | * @skc_net: reference to the network namespace of this socket |
120 | * @skc_node: main hash linkage for various protocol lookup tables | ||
121 | * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol | ||
122 | * @skc_tx_queue_mapping: tx queue number for this connection | ||
123 | * @skc_refcnt: reference count | ||
122 | * | 124 | * |
123 | * This is the minimal network layer representation of sockets, the header | 125 | * This is the minimal network layer representation of sockets, the header |
124 | * for struct sock and struct inet_timewait_sock. | 126 | * for struct sock and struct inet_timewait_sock. |
125 | */ | 127 | */ |
126 | struct sock_common { | 128 | struct sock_common { |
127 | /* | 129 | /* skc_daddr and skc_rcv_saddr must be grouped : |
128 | * first fields are not copied in sock_copy() | 130 | * cf INET_MATCH() and INET_TW_MATCH() |
129 | */ | 131 | */ |
130 | union { | 132 | __be32 skc_daddr; |
131 | struct hlist_node skc_node; | 133 | __be32 skc_rcv_saddr; |
132 | struct hlist_nulls_node skc_nulls_node; | ||
133 | }; | ||
134 | atomic_t skc_refcnt; | ||
135 | int skc_tx_queue_mapping; | ||
136 | 134 | ||
137 | union { | 135 | union { |
138 | unsigned int skc_hash; | 136 | unsigned int skc_hash; |
@@ -150,6 +148,18 @@ struct sock_common { | |||
150 | #ifdef CONFIG_NET_NS | 148 | #ifdef CONFIG_NET_NS |
151 | struct net *skc_net; | 149 | struct net *skc_net; |
152 | #endif | 150 | #endif |
151 | /* | ||
152 | * fields between dontcopy_begin/dontcopy_end | ||
153 | * are not copied in sock_copy() | ||
154 | */ | ||
155 | int skc_dontcopy_begin[0]; | ||
156 | union { | ||
157 | struct hlist_node skc_node; | ||
158 | struct hlist_nulls_node skc_nulls_node; | ||
159 | }; | ||
160 | int skc_tx_queue_mapping; | ||
161 | atomic_t skc_refcnt; | ||
162 | int skc_dontcopy_end[0]; | ||
153 | }; | 163 | }; |
154 | 164 | ||
155 | /** | 165 | /** |
@@ -232,7 +242,8 @@ struct sock { | |||
232 | #define sk_refcnt __sk_common.skc_refcnt | 242 | #define sk_refcnt __sk_common.skc_refcnt |
233 | #define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping | 243 | #define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping |
234 | 244 | ||
235 | #define sk_copy_start __sk_common.skc_hash | 245 | #define sk_dontcopy_begin __sk_common.skc_dontcopy_begin |
246 | #define sk_dontcopy_end __sk_common.skc_dontcopy_end | ||
236 | #define sk_hash __sk_common.skc_hash | 247 | #define sk_hash __sk_common.skc_hash |
237 | #define sk_family __sk_common.skc_family | 248 | #define sk_family __sk_common.skc_family |
238 | #define sk_state __sk_common.skc_state | 249 | #define sk_state __sk_common.skc_state |