Re: [PATCH 1/2] udp: introduce struct udp_table and multiple rwlocks
From: Christian Bell <hidden>
Date: 2008-10-28 21:24:17
From: Christian Bell <hidden>
Date: 2008-10-28 21:24:17
On Oct 28, 2008, at 1:37 PM, Eric Dumazet wrote:
-extern struct hlist_head udp_hash[UDP_HTABLE_SIZE];
-extern rwlock_t udp_hash_lock;
+struct udp_hslot {
+ struct hlist_head head;
+ rwlock_t lock;
+};This structure should be aligned up to cacheline to reduce false sharing of more than one hslot.
+ } else {
+ hslot = &udptable->hash[udp_hashfn(net, snum)];
+ write_lock_bh(&hslot->lock);
+ if (udp_lib_lport_inuse(net, snum, hslot, sk, saddr_comp))
+ goto fail;The fail: label below should still unlock_bh when the above condition fails.
+ }
inet_sk(sk)->num = snum;
sk->sk_hash = snum;
if (sk_unhashed(sk)) {
- sk_add_node(sk, &udptable[udp_hashfn(net, snum)]);
+ sk_add_node(sk, &hslot->head);
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
}
+ write_unlock_bh(&hslot->lock);
error = 0;
fail:
- write_unlock_bh(&udp_hash_lock);
return error;
}cheers, . . christian