Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1309512

Re: [PATCH v2] netfilter: nf_conntrack: use safer way to lock all buckets

From Florian Westphal <fw@strlen.de>
Newsgroups linux.kernel
Subject Re: [PATCH v2] netfilter: nf_conntrack: use safer way to lock all buckets
Date 2016-01-14 18:30 +0100
Message-ID <qQTSI-1KH-41@gated-at.bofh.it> (permalink)
References <qQTzk-1Du-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Sasha Levin <sasha.levin@oracle.com> wrote:
> When we need to lock all buckets in the connection hashtable we'd attempt to
> lock 1024 spinlocks, which is way more preemption levels than supported by
> the kernel. Furthermore, this behavior was hidden by checking if lockdep is
> enabled, and if it was - use only 8 buckets(!).
> 
> Fix this by using a global lock and synchronize all buckets on it when we
> need to lock them all. This is pretty heavyweight, but is only done when we
> need to resize the hashtable, and that doesn't happen often enough (or at all).
> 
> diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
> index 3cb3cb8..4ccf5ad 100644
> --- a/net/netfilter/nf_conntrack_core.c
> +++ b/net/netfilter/nf_conntrack_core.c
> @@ -66,6 +66,21 @@ EXPORT_SYMBOL_GPL(nf_conntrack_locks);
>  __cacheline_aligned_in_smp DEFINE_SPINLOCK(nf_conntrack_expect_lock);
>  EXPORT_SYMBOL_GPL(nf_conntrack_expect_lock);
>  
> +spinlock_t nf_conntrack_locks_all_lock;
> +bool nf_conntrack_locks_all;

warning: symbol 'nf_conntrack_locks_all_lock' was not declared. Should it be static?
warning: symbol 'nf_conntrack_locks_all' was not declared.  Should it be static?

> +void nf_conntrack_lock(spinlock_t *lock)

__acquires(lock)

It avoids 'context imbalance in 'nf_conntrack_lock' - wrong count at exit'
sparse error.

Other than that this looks good, thanks.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2] netfilter: nf_conntrack: use safer way to lock all buckets Sasha Levin <sasha.levin@oracle.com> - 2016-01-14 18:10 +0100
  Re: [PATCH v2] netfilter: nf_conntrack: use safer way to lock all  buckets Florian Westphal <fw@strlen.de> - 2016-01-14 18:30 +0100
  Re: [PATCH v2] netfilter: nf_conntrack: use safer way to lock all  buckets Jesper Dangaard Brouer <brouer@redhat.com> - 2016-01-15 08:10 +0100

csiph-web