netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel <netfilter-devel@vger.kernel.org>
Subject: Re: [nf-next 0/2] netfilter: nf_tables: make set flush more resistant to memory pressure
Date: Wed, 20 Aug 2025 00:23:58 +0200	[thread overview]
Message-ID: <aKT5fjEqDmQPdFFy@calendula> (raw)
In-Reply-To: <aKTMMmGdaURKNLou@strlen.de>

On Tue, Aug 19, 2025 at 09:10:42PM +0200, Florian Westphal wrote:
> Florian Westphal <fw@strlen.de> wrote:
> > > For the commit phase, I suggest to add a list of dying elements to the
> > > transaction object. After unlinking the element from the (internal)
> > > set data structure, add it to this transaction dying list so it
> > > remains reachable to be released after the rcu grace period.
> > 
> > Thats what I meant by 'stick a pointer into struct nft_set_ext'.
> > Its awkward but I should be able to get the priv pointer back
> > by doing the inverse of nft_set_elem_ext().
> > 
> > The cleaner solution would be to turn nft_elem_priv into a
> > 'nft_elem_common', place a hlist_node into that and then
> > use container_of().  But its too much code churn for my
> > liking.
> > 
> > So I'll extend each set element with a pointer and
> > add a removed_elements hlist_head to struct nft_trans_elem.
> > 
> > The transacion id isn't needed I think once that list exist:
> > it provides the needed info to undo previous operations
> > without the need to walk the set again.
> > 
> > We can probably even rework struct nft_trans_elem to always use
> > this pointer, even for inserts, and only use the 
> > 
> > struct nft_trans_one_elem       elems[]
> > 
> > member for elements that we update (no add or removal).
> > But thats something for a later time.
> 
> This doesn't work.
> NEWSETELEM cannot (re)use the same list node as DELSETELEM.
> 
> Reason is that a set flush will also flush elements
> added in the same batch.
> 
> But if NEWSETELEM uses a list (instead of priv pointer
> as we do now), then at the time of the set flush, the
> encountered element is already on a NEWSETELEM trans_elem list.
> 
> I'll try doing:
> 
>  struct nft_set_ext {
>         u8      genmask;
>         u8      offset[NFT_SET_EXT_NUM];
> +       struct llist_node trans_list_new;
> +       struct llist_node trans_list_del;
>         char    data[];
> 
> to avoid this problem.

Hm, I think this is not looking good.

I am considering it is better to take your patch by now, then postpone
explore further memory consumption reduction at a later stage.

Thanks for addressing my suggestion, let me know if you prefer this
path, I apologize for delaying your original proposal.

      reply	other threads:[~2025-08-19 22:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-04 12:30 [nf-next 0/2] netfilter: nf_tables: make set flush more resistant to memory pressure Florian Westphal
2025-07-04 12:30 ` [nf-next 1/2] netfilter: nf_tables: allow iter callbacks to sleep Florian Westphal
2025-07-04 12:30 ` [nf-next 2/2] netfilter: nf_tables: all transaction allocations can now sleep Florian Westphal
2025-07-24 23:19 ` [nf-next 0/2] netfilter: nf_tables: make set flush more resistant to memory pressure Pablo Neira Ayuso
2025-07-25  0:24   ` Florian Westphal
2025-07-25 10:10     ` Pablo Neira Ayuso
2025-07-25 11:15       ` Florian Westphal
2025-07-25 15:03         ` Pablo Neira Ayuso
2025-07-28 21:28           ` Florian Westphal
2025-07-29  7:22             ` Jozsef Kadlecsik
2025-07-29 10:27               ` Pablo Neira Ayuso
2025-07-29 10:50                 ` Jozsef Kadlecsik
2025-07-29 10:38             ` Pablo Neira Ayuso
2025-07-29 11:37               ` Florian Westphal
2025-07-30 16:16                 ` Pablo Neira Ayuso
2025-07-30 16:35                   ` Florian Westphal
2025-08-19 19:10                     ` Florian Westphal
2025-08-19 22:23                       ` Pablo Neira Ayuso [this message]

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=aKT5fjEqDmQPdFFy@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).