]> git.baikalelectronics.ru Git - kernel.git/commit
net: move inet_dport/inet_num in sock_common
authorEric Dumazet <edumazet@google.com>
Fri, 30 Nov 2012 09:49:27 +0000 (09:49 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 30 Nov 2012 20:02:56 +0000 (15:02 -0500)
commit4fc0c51cdf6ba25fa16e96ca066378722a8066a1
tree0cd6679992bd810371620fcab52c24ce39a89aa8
parentb41bde445b71177dbc406ed9bd6a6d8521701159
net: move inet_dport/inet_num in sock_common

commit f461a6db0cc6 (net: optimize INET input path further)
moved some fields used for tcp/udp sockets lookup in the first cache
line of struct sock_common.

This patch moves inet_dport/inet_num as well, filling a 32bit hole
on 64 bit arches and reducing number of cache line misses in lookups.

Also change INET_MATCH()/INET_TW_MATCH() to perform the ports match
before addresses match, as this check is more discriminant.

Remove the hash check from MATCH() macros because we dont need to
re validate the hash value after taking a refcount on socket, and
use likely/unlikely compiler hints, as the sk_hash/hash check
makes the following conditional tests 100% predicted by cpu.

Introduce skc_addrpair/skc_portpair pair values to better
document the alignment requirements of the port/addr pairs
used in the various MATCH() macros, and remove some casts.

The namespace check can also be done at last.

This slightly improves TCP/UDP lookup times.

IP/TCP early demux needs inet->rx_dst_ifindex and
TCP needs inet->min_ttl, lets group them together in same cache line.

With help from Ben Hutchings & Joe Perches.

Idea of this patch came after Ling Ma proposal to move skc_hash
to the beginning of struct sock_common, and should allow him
to submit a final version of his patch. My tests show an improvement
doing so.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Cc: Joe Perches <joe@perches.com>
Cc: Ling Ma <ling.ma.program@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/ipv6.h
include/net/inet_hashtables.h
include/net/inet_sock.h
include/net/inet_timewait_sock.h
include/net/sock.h
net/ipv4/inet_hashtables.c
net/ipv6/inet6_hashtables.c