net: convert TCP/DCCP ehash rwlocks to spinlocks
Now TCP & DCCP use RCU lookups, we can convert ehash rwlocks to spinlocks. /proc/net/tcp and other seq_file 'readers' can safely be converted to 'writers'. This should speedup writers, since spin_lock()/spin_unlock() only use one atomic operation instead of two for write_lock()/write_unlock() Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
b8c26a33c8
commit
9db66bdcc8
@@ -38,14 +38,14 @@ void __inet6_hash(struct sock *sk)
|
||||
} else {
|
||||
unsigned int hash;
|
||||
struct hlist_nulls_head *list;
|
||||
rwlock_t *lock;
|
||||
spinlock_t *lock;
|
||||
|
||||
sk->sk_hash = hash = inet6_sk_ehashfn(sk);
|
||||
list = &inet_ehash_bucket(hashinfo, hash)->chain;
|
||||
lock = inet_ehash_lockp(hashinfo, hash);
|
||||
write_lock(lock);
|
||||
spin_lock(lock);
|
||||
__sk_nulls_add_node_rcu(sk, list);
|
||||
write_unlock(lock);
|
||||
spin_unlock(lock);
|
||||
}
|
||||
|
||||
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
|
||||
@@ -195,13 +195,12 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
|
||||
const unsigned int hash = inet6_ehashfn(net, daddr, lport, saddr,
|
||||
inet->dport);
|
||||
struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
|
||||
rwlock_t *lock = inet_ehash_lockp(hinfo, hash);
|
||||
spinlock_t *lock = inet_ehash_lockp(hinfo, hash);
|
||||
struct sock *sk2;
|
||||
const struct hlist_nulls_node *node;
|
||||
struct inet_timewait_sock *tw;
|
||||
|
||||
prefetch(head->chain.first);
|
||||
write_lock(lock);
|
||||
spin_lock(lock);
|
||||
|
||||
/* Check TIME-WAIT sockets first. */
|
||||
sk_nulls_for_each(sk2, node, &head->twchain) {
|
||||
@@ -230,8 +229,8 @@ unique:
|
||||
WARN_ON(!sk_unhashed(sk));
|
||||
__sk_nulls_add_node_rcu(sk, &head->chain);
|
||||
sk->sk_hash = hash;
|
||||
spin_unlock(lock);
|
||||
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
|
||||
write_unlock(lock);
|
||||
|
||||
if (twp != NULL) {
|
||||
*twp = tw;
|
||||
@@ -246,7 +245,7 @@ unique:
|
||||
return 0;
|
||||
|
||||
not_unique:
|
||||
write_unlock(lock);
|
||||
spin_unlock(lock);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user