]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nft_set_rbtree: use seqcount to avoid lock in most cases
authorFlorian Westphal <fw@strlen.de>
Fri, 28 Jul 2017 08:34:42 +0000 (10:34 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 31 Jul 2017 18:41:59 +0000 (20:41 +0200)
commit3cf32b978f5e2231b720042c7d968164838a7fba
tree12db224d80fe10f6a39a40f77a26c8e776f6410b
parent44a5446768444a0c216444782f4532814c8eb930
netfilter: nft_set_rbtree: use seqcount to avoid lock in most cases

switch to lockless lockup. write side now also increments sequence
counter.  On lookup, sample counter value and only take the lock
if we did not find a match and the counter has changed.

This avoids need to write to private area in normal (lookup) cases.

In case we detect a writer (seqretry is true) we fall back to taking
the readlock.

The readlock is also used during dumps to ensure we get a consistent
tree walk.

Similar technique (rbtree+seqlock) was used by David Howells in rxrpc.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_set_rbtree.c