All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Florian Westphal <fw@strlen.de>
Cc: <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH nf-next 3/9] netfilter: nft_set_pipapo: prepare destroy function for on-demand clone
Date: Mon, 8 Apr 2024 17:45:03 +0200	[thread overview]
Message-ID: <20240408174503.0792a92e@elisabeth> (raw)
In-Reply-To: <20240403084113.18823-4-fw@strlen.de>

On Wed,  3 Apr 2024 10:41:03 +0200
Florian Westphal <fw@strlen.de> wrote:

> Once priv->clone can be NULL in case no insertions/removals occurred
> in the last transaction we need to drop set elements from priv->match
> if priv->clone is NULL.
> 
> While at it, condense this function by reusing the pipapo_free_match
> helper instead of open-coded version.
> 
> The rcu_barrier() is removed, its not needed: old call_rcu instances
> for pipapo_reclaim_match do not access struct nft_set.

True, pipapo_reclaim_match() won't, but nft_set_pipapo_match_destroy()
will, right? That is:

> 
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
>  net/netfilter/nft_set_pipapo.c | 27 ++++++---------------------
>  1 file changed, 6 insertions(+), 21 deletions(-)
> 
> diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c
> index 48d5600f8836..d2ac2d5560e4 100644
> --- a/net/netfilter/nft_set_pipapo.c
> +++ b/net/netfilter/nft_set_pipapo.c
> @@ -2323,33 +2323,18 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
>  {
>  	struct nft_pipapo *priv = nft_set_priv(set);
>  	struct nft_pipapo_match *m;
> -	int cpu;
>  
>  	m = rcu_dereference_protected(priv->match, true);
> -	if (m) {
> -		rcu_barrier();

...before b0e256f3dd2b ("netfilter: nft_set_pipapo: release elements in
clone only from destroy path"), this rcu_barrier() was needed because we'd
call nft_set_pipapo_match_destroy() on 'm'.

That call is now gone, and we could have dropped it at that point, but:

> -
> -		for_each_possible_cpu(cpu)
> -			pipapo_free_scratch(m, cpu);
> -		free_percpu(m->scratch);
> -		pipapo_free_fields(m);
> -		kfree(m);
> -		priv->match = NULL;
> -	}
>  
>  	if (priv->clone) {
> -		m = priv->clone;
> -
> -		nft_set_pipapo_match_destroy(ctx, set, m);
> -
> -		for_each_possible_cpu(cpu)
> -			pipapo_free_scratch(priv->clone, cpu);
> -		free_percpu(priv->clone->scratch);
> -
> -		pipapo_free_fields(priv->clone);
> -		kfree(priv->clone);
> +		nft_set_pipapo_match_destroy(ctx, set, priv->clone);
> +		pipapo_free_match(priv->clone);
>  		priv->clone = NULL;
> +	} else {
> +		nft_set_pipapo_match_destroy(ctx, set, m);

now it's back, so we should actually move rcu_barrier() before this
call? I think it's needed because nft_set_pipapo_match_destroy() does
access nft_set data.

>  	}
> +
> +	pipapo_free_match(m);
>  }
>  
>  /**

-- 
Stefano


  reply	other threads:[~2024-04-08 15:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03  8:41 [PATCH nf-next 0/9] nft_set_pipapo: remove cannot-fail allocations on commit and abort Florian Westphal
2024-04-03  8:41 ` [PATCH nf-next 1/9] netfilter: nft_set_pipapo: move prove_locking helper around Florian Westphal
2024-04-03  8:41 ` [PATCH nf-next 2/9] netfilter: nft_set_pipapo: make pipapo_clone helper return NULL Florian Westphal
2024-04-03  8:41 ` [PATCH nf-next 3/9] netfilter: nft_set_pipapo: prepare destroy function for on-demand clone Florian Westphal
2024-04-08 15:45   ` Stefano Brivio [this message]
2024-04-09 11:07     ` Florian Westphal
2024-04-09 12:54       ` Stefano Brivio
2024-04-09 13:04         ` Florian Westphal
2024-04-09 13:10           ` Stefano Brivio
2024-04-03  8:41 ` [PATCH nf-next 4/9] netfilter: nft_set_pipapo: prepare walk " Florian Westphal
2024-04-03  8:41 ` [PATCH nf-next 5/9] netfilter: nf_tables: pass new nft_iter_type hint to walker Florian Westphal
2024-04-03  8:41 ` [PATCH nf-next 6/9] netfilter: nft_set_pipapo: merge deactivate helper into caller Florian Westphal
2024-04-03  8:41 ` [PATCH nf-next 7/9] netfilter: nft_set_pipapo: prepare pipapo_get helper for on-demand clone Florian Westphal
2024-04-03  8:41 ` [PATCH nf-next 8/9] netfilter: nft_set_pipapo: move cloning of match info to insert/removal path Florian Westphal
2024-04-08 15:45   ` Stefano Brivio
2024-04-03  8:41 ` [PATCH nf-next 9/9] netfilter: nft_set_pipapo: remove dirty flag Florian Westphal

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=20240408174503.0792a92e@elisabeth \
    --to=sbrivio@redhat.com \
    --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 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.