All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] netfilter: nf_conntrack: consolidate lock/unlock into unlock_wait
@ 2016-03-14 11:39 Nicholas Mc Guire
  2016-03-15  0:11 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Mc Guire @ 2016-03-14 11:39 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Patrick McHardy, Jozsef Kadlecsik, David S. Miller,
	netfilter-devel, coreteam, netdev, linux-kernel,
	Nicholas Mc Guire

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>
---

Patch was compile tested with: x86_64_defconfig (implies CONFIG_NETFILTER=y)
Simple run test on x86 64 with a few trivial ipfilter rules active.

Patch is against linux-next (localversion-next is next-20160311)

 net/netfilter/nf_conntrack_core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index f60b4fd..afde5f5 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -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]);
 	}
 }
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] netfilter: nf_conntrack: consolidate lock/unlock into unlock_wait
  2016-03-14 11:39 [PATCH] netfilter: nf_conntrack: consolidate lock/unlock into unlock_wait Nicholas Mc Guire
@ 2016-03-15  0:11 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2016-03-15  0:11 UTC (permalink / raw)
  To: Nicholas Mc Guire
  Cc: Patrick McHardy, Jozsef Kadlecsik, David S. Miller,
	netfilter-devel, coreteam, netdev, linux-kernel

On Mon, Mar 14, 2016 at 12:39:02PM +0100, Nicholas Mc Guire wrote:
> 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.

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-15  0:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-14 11:39 [PATCH] netfilter: nf_conntrack: consolidate lock/unlock into unlock_wait Nicholas Mc Guire
2016-03-15  0:11 ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.