From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf 1/2] netfilter: nft_set_rbtree: move sync GC from insert path to set->ops->commit
Date: Sun, 1 Oct 2023 22:10:03 +0200 [thread overview]
Message-ID: <ZRnSGwk40jpUActD@calendula> (raw)
In-Reply-To: <20230930081038.GB23327@breakpoint.cc>
Hi Florian,
On Sat, Sep 30, 2023 at 10:10:38AM +0200, Florian Westphal wrote:
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > - read spin lock is required for the sync GC to make sure this does
> > not zap entries that are being used from the datapath.
>
> It needs to grab the write spinlock for each rb_erase, plus
> the seqcount increase to make sure that parallel lookup doesn't
> miss an element in the tree.
Right, read lock is not enough for sync GC, and it would be also
required by this approach.
> > - the full GC batch could be used to amortize the memory allocation
> > (not only two slots as it happens now, I am recycling an existing
> > function).
>
> Yes.
>
> > - ENOMEM on GC sync commit path could be an issue. It is too late to
> > fail. The tree would start collecting expired elements that might
> > duplicate existing, triggering bogus mismatches. In this path the
> > commit_mutex is held, and this set backend does not support for
> > lockless read,
>
> It does. If lockless doesn't return a match it falls back to readlock.
And it will in case of the update to remove the expired element, right?
> > it might be possible to simply grab the spinlock
> > in write mode and release entries inmediately, without requiring the
> > sync GC batch infrastructure that pipapo is using.
>
> Is there evidence that the on-demand GC is a problem?
After your last fix, not really, other than we have to be care not to
zap elements that are in any of the pending transaction in this batch.
> It only searches in the relevant subtree, it should rarely, if ever,
> encounter any expired element.
Not a problem now, but this path that we follow blocks a requested
feature.
I currently do not know how to support for set element timeout update
with this on-demand GC on the rbtree. This feature will require a new
update state in the transaction to update the timer for an element. We
will have to be careful because on-demand GC might zap an expired
element that got just refreshed in this transaction (unless we
reintroduce some sort of 'busy' bit for updates again which is
something I prefer we do not). With 2ee52ae94baa ("netfilter:
nft_set_rbtree: skip sync GC for new elements in this transaction")
I could fix by looking at the generation mask to infer that this
element is 'busy' by some pending transaction, but I do not see a way
with an element update command in place.
Maybe take your patch and then follow up to nf-next with this approach
based once set element timer update is introduced? Otherwise, rbtree
will block the introduction of this new feature for other sets too.
next prev parent reply other threads:[~2023-10-01 20:10 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-29 16:44 [PATCH nf 1/2] netfilter: nft_set_rbtree: move sync GC from insert path to set->ops->commit Pablo Neira Ayuso
2023-09-29 16:44 ` [PATCH nf 2/2] netfilter: nft_set_rbtree: remove async GC Pablo Neira Ayuso
2023-09-29 22:25 ` [PATCH nf 1/2] netfilter: nft_set_rbtree: move sync GC from insert path to set->ops->commit Pablo Neira Ayuso
2023-09-30 8:10 ` Florian Westphal
2023-10-01 20:10 ` Pablo Neira Ayuso [this message]
2023-10-01 21:08 ` Florian Westphal
2023-10-02 8:20 ` Pablo Neira Ayuso
2023-10-02 8:47 ` Florian Westphal
2023-10-02 10:24 ` Pablo Neira Ayuso
2023-10-02 12:42 ` update element timeout support [was Re: [PATCH nf 1/2] netfilter: nft_set_rbtree: move sync GC from insert path to set->ops->commit] Pablo Neira Ayuso
2023-10-02 13:58 ` Florian Westphal
2023-10-02 14:21 ` Florian Westphal
2023-10-03 8:22 ` Pablo Neira Ayuso
2023-10-03 9:04 ` Florian Westphal
2023-10-03 9:42 ` Pablo Neira Ayuso
2023-10-03 18:24 ` Florian Westphal
2023-10-04 8:30 ` Pablo Neira Ayuso
2023-10-02 21:10 ` Pablo Neira Ayuso
2023-10-02 21:14 ` Pablo Neira Ayuso
2023-10-02 14:23 ` [PATCH nf 1/2] netfilter: nft_set_rbtree: move sync GC from insert path to set->ops->commit Florian Westphal
2023-10-02 21:37 ` Pablo Neira Ayuso
2023-10-02 21:42 ` 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=ZRnSGwk40jpUActD@calendula \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).