All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Phil Sutter <phil@nwl.cc>,
	Fernando Fernandez Mancera <fmancera@suse.de>,
	netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next 0/3] netfilter: nft_set_rbtree: use cloned tree for insertions and removal
Date: Thu, 20 Nov 2025 11:28:16 +0100	[thread overview]
Message-ID: <aR7tQFEkfqotwT36@strlen.de> (raw)
In-Reply-To: <aR5BT0-HnwPEkBR5@orbyte.nwl.cc>

Phil Sutter <phil@nwl.cc> wrote:

Thanks for doing this but I'm not sold on this.
This also traverses the entire tree, which is afaics not avoidable
and also the expensive part.

I don't get much better results with this version
(10 inserts into 800k tree: mainline: ~3m, patchset, 3m47m, your
version 3m47s).

> +static void nft_rbtree_copy(const struct nft_set *set, struct rb_node *parent,
> +			    struct rb_node **pos, struct nft_rbtree_elem *elem)
> +{
> +	struct nft_rbtree *priv = nft_set_priv(set);
> +	u8 genbit = nft_rbtree_genbit_copy(priv);
> +
> +	rb_link_node_rcu(&elem->node[genbit], parent, pos);
> +	rb_set_parent_color(&elem->node[genbit], parent,
> +			    rb_color(&elem->node[!genbit]));
> +
> +	if (elem->node[!genbit].rb_left)
> +		nft_rbtree_copy(set, &elem->node[genbit],
> +				&elem->node[genbit].rb_left,
> +				rb_entry(elem->node[!genbit].rb_left,
> +					 struct nft_rbtree_elem,
> +					 node[!genbit]));

... and that makes recursive calls, i am reluctant here.

It should be fine given its limited by tree height, but it makes
me uneasy to have this.

  reply	other threads:[~2025-11-20 10:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-18 11:16 [PATCH nf-next 0/3] netfilter: nft_set_rbtree: use cloned tree for insertions and removal Florian Westphal
2025-11-18 11:16 ` [PATCH nf-next 1/3] netfilter: nft_set_rbtree: prepare for two rbtrees Florian Westphal
2025-11-18 11:16 ` [PATCH nf-next 2/3] netfilter: nft_set_rbtree: factor out insert helper Florian Westphal
2025-11-18 11:16 ` [PATCH nf-next 3/3] netfilter: nft_set_rbtree: do not modifiy live tree Florian Westphal
2025-11-19  8:29   ` kernel test robot
2025-11-19 10:48     ` Florian Westphal
2025-11-18 16:07 ` [PATCH nf-next 0/3] netfilter: nft_set_rbtree: use cloned tree for insertions and removal Fernando Fernandez Mancera
2025-11-18 16:46   ` Florian Westphal
2025-11-18 17:01     ` Fernando Fernandez Mancera
2025-11-19 12:52   ` Phil Sutter
2025-11-19 15:56     ` Florian Westphal
2025-11-19 22:14       ` Phil Sutter
2025-11-20 10:28         ` Florian Westphal [this message]
2025-11-20 11:39         ` Fernando Fernandez Mancera

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=aR7tQFEkfqotwT36@strlen.de \
    --to=fw@strlen.de \
    --cc=fmancera@suse.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=phil@nwl.cc \
    /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.