netfilter: nf_conntrack: consolidate lock/unlock into unlock_wait
authorNicholas Mc Guire <hofrat@osadl.org>
Mon, 14 Mar 2016 11:39:02 +0000 (12:39 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 15 Mar 2016 00:10:42 +0000 (01:10 +0100)
The spin_lock()/spin_unlock() is synchronizing on the
nf_conntrack_locks_all_lock which is equivalent to
spin_unlock_wait() but the later should be more efficient.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_conntrack_core.c

index f60b4fdeeb8cc4fc600506ecc58e2bdc4cad1654..afde5f5e728a320773be246ecbcfcca7f5a16617 100644 (file)
@@ -74,8 +74,7 @@ void nf_conntrack_lock(spinlock_t *lock) __acquires(lock)
        spin_lock(lock);
        while (unlikely(nf_conntrack_locks_all)) {
                spin_unlock(lock);
-               spin_lock(&nf_conntrack_locks_all_lock);
-               spin_unlock(&nf_conntrack_locks_all_lock);
+               spin_unlock_wait(&nf_conntrack_locks_all_lock);
                spin_lock(lock);
        }
 }
@@ -121,8 +120,7 @@ static void nf_conntrack_all_lock(void)
        nf_conntrack_locks_all = true;
 
        for (i = 0; i < CONNTRACK_LOCKS; i++) {
-               spin_lock(&nf_conntrack_locks[i]);
-               spin_unlock(&nf_conntrack_locks[i]);
+               spin_unlock_wait(&nf_conntrack_locks[i]);
        }
 }