From 0e1efe9d5e10921f1e2152b108e013605fca3c9f Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 5 Dec 2012 09:18:10 +0000 Subject: ipv6: avoid taking locks at socket dismantle ipv6_sock_mc_close() is called for ipv6 sockets at close time, and most of them don't use multicast. Add a test to avoid contention on a shared spinlock. Same heuristic applies for ipv6_sock_ac_close(), to avoid contention on a shared rwlock. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- net/ipv6/anycast.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'net/ipv6/anycast.c') diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c index 2f4f584d796..757a810d8f1 100644 --- a/net/ipv6/anycast.c +++ b/net/ipv6/anycast.c @@ -189,6 +189,9 @@ void ipv6_sock_ac_close(struct sock *sk) struct net *net = sock_net(sk); int prev_index; + if (!np->ipv6_ac_list) + return; + write_lock_bh(&ipv6_sk_ac_lock); pac = np->ipv6_ac_list; np->ipv6_ac_list = NULL; -- cgit v1.2.3-70-g09d2