]> git.proxmox.com Git - mirror_ubuntu-bionic-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)
commit9b7e26aee7cf27ffb37bb2f17229cecc89a833bd
tree12db224d80fe10f6a39a40f77a26c8e776f6410b
parent615095752100748e221028fc96163c2b78185ae4
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