From: Florian Westphal <fw@strlen.de>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Florian Westphal <fw@strlen.de>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next] netfilter: nft_set_rbtree: use seqcount to avoid lock in most cases
Date: Wed, 26 Jul 2017 13:04:34 +0200 [thread overview]
Message-ID: <20170726110434.GC28392@breakpoint.cc> (raw)
In-Reply-To: <1501065278.12695.8.camel@edumazet-glaptop3.roam.corp.google.com>
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Wed, 2017-07-26 at 02:09 +0200, Florian Westphal wrote:
> > 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.
> >
> > Note that we take the non-blocking variant (raw_seqcount_begin), i.e.
> > read side will not wait for writer to finish.
> >
> > If we did not find a result we will fall back to use of read-lock.
> >
> > 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.
>
> Please note that in commit b145425f269a17ed344d737f746b844dfac60c82
> ("inetpeer: remove AVL implementation in favor of RB tree")
>
> I chose to also pass the sequence so that the lookup could abort.
> I am not sure that during rb tree write operations, some nodes could be
> left with some kind of loop.
I see.
Ok, I will spin a v2 and will pass the sequence too, thanks Eric.
If we have to abort on seqretry anyway then I can also use
read_seqcount_begin to force readers to wait until writer is done, so I
will change that as well.
next prev parent reply other threads:[~2017-07-26 11:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-26 0:09 [PATCH nf-next] netfilter: nft_set_rbtree: use seqcount to avoid lock in most cases Florian Westphal
2017-07-26 10:34 ` Eric Dumazet
2017-07-26 11:04 ` Florian Westphal [this message]
2017-07-26 11:15 ` Pablo Neira Ayuso
2017-07-26 11:25 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170726110434.GC28392@breakpoint.cc \
--to=fw@strlen.de \
--cc=eric.dumazet@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.