diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2007-02-09 18:44:52 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-02-11 02:20:29 -0500 |
commit | 95f30b336b944e3e418f825044b4793d9e9aac09 (patch) | |
tree | 4faf8cc7a061fdf7d85f94768ca1150f8580e700 /net/ipv6/udp.c | |
parent | 4768fbcbcfbbcacb785ae08eef33767a0b4fdcdd (diff) |
[UDP]: UDP can use sk_hash to speedup lookups
In a prior patch, I introduced a sk_hash field (__sk_common.skc_hash) to let
tcp lookups use one cache line per unmatched entry instead of two.
We can also use sk_hash to speedup UDP part as well. We store in sk_hash the
hnum value, and use sk->sk_hash (same cache line than 'next' pointer),
instead of inet->num (different cache line)
Note : We still have a false sharing problem for SMP machines, because
sock_hold(sock) dirties the cache line containing the 'next' pointer. Not
counting the udp_hash_lock rwlock. (did someone mentioned RCU ? :) )
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/udp.c')
-rw-r--r-- | net/ipv6/udp.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index dbe2748db1e9..ccf2f4d196be 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -71,7 +71,7 @@ static struct sock *__udp6_lib_lookup(struct in6_addr *saddr, __be16 sport, | |||
71 | sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) { | 71 | sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) { |
72 | struct inet_sock *inet = inet_sk(sk); | 72 | struct inet_sock *inet = inet_sk(sk); |
73 | 73 | ||
74 | if (inet->num == hnum && sk->sk_family == PF_INET6) { | 74 | if (sk->sk_hash == hnum && sk->sk_family == PF_INET6) { |
75 | struct ipv6_pinfo *np = inet6_sk(sk); | 75 | struct ipv6_pinfo *np = inet6_sk(sk); |
76 | int score = 0; | 76 | int score = 0; |
77 | if (inet->dport) { | 77 | if (inet->dport) { |
@@ -309,7 +309,7 @@ static struct sock *udp_v6_mcast_next(struct sock *sk, | |||
309 | sk_for_each_from(s, node) { | 309 | sk_for_each_from(s, node) { |
310 | struct inet_sock *inet = inet_sk(s); | 310 | struct inet_sock *inet = inet_sk(s); |
311 | 311 | ||
312 | if (inet->num == num && s->sk_family == PF_INET6) { | 312 | if (s->sk_hash == num && s->sk_family == PF_INET6) { |
313 | struct ipv6_pinfo *np = inet6_sk(s); | 313 | struct ipv6_pinfo *np = inet6_sk(s); |
314 | if (inet->dport) { | 314 | if (inet->dport) { |
315 | if (inet->dport != rmt_port) | 315 | if (inet->dport != rmt_port) |