From: Eric Dumazet <edumazet@google.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net,
netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,
fw@strlen.de
Subject: Re: [PATCH net 14/14] netfilter: ipset: fix performance regression in swap operation
Date: Thu, 18 Jan 2024 11:08:00 +0100 [thread overview]
Message-ID: <CANn89iKtpVy1kSSuk_RSGN0R6L+roNJr81ED4+a2SZ2WKzGsng@mail.gmail.com> (raw)
In-Reply-To: <20240117160030.140264-15-pablo@netfilter.org>
On Wed, Jan 17, 2024 at 5:00 PM Pablo Neira Ayuso <pablo@netfilter.org> wrote:
>
> From: Jozsef Kadlecsik <kadlec@netfilter.org>
>
> The patch "netfilter: ipset: fix race condition between swap/destroy
> and kernel side add/del/test", commit 28628fa9 fixes a race condition.
> But the synchronize_rcu() added to the swap function unnecessarily slows
> it down: it can safely be moved to destroy and use call_rcu() instead.
> Thus we can get back the same performance and preventing the race condition
> at the same time.
>
> Fixes: 28628fa952fe ("netfilter: ipset: fix race condition between swap/destroy and kernel side add/del/test")
> Link: https://lore.kernel.org/lkml/C0829B10-EAA6-4809-874E-E1E9C05A8D84@automattic.com/
> Reported-by: Ale Crismani <ale.crismani@automattic.com>
> Reported-by: David Wang <00107082@163.com
> Tested-by: Ale Crismani <ale.crismani@automattic.com>
> Tested-by: David Wang <00107082@163.com
> Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> include/linux/netfilter/ipset/ip_set.h | 2 ++
> net/netfilter/ipset/ip_set_core.c | 31 +++++++++++++++++++-------
> 2 files changed, 25 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
> index e8c350a3ade1..912f750d0bea 100644
> --- a/include/linux/netfilter/ipset/ip_set.h
> +++ b/include/linux/netfilter/ipset/ip_set.h
> @@ -242,6 +242,8 @@ extern void ip_set_type_unregister(struct ip_set_type *set_type);
>
> /* A generic IP set */
> struct ip_set {
> + /* For call_cru in destroy */
> + struct rcu_head rcu;
> /* The name of the set */
> char name[IPSET_MAXNAMELEN];
> /* Lock protecting the set data */
> diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
> index 4c133e06be1d..3bf9bb345809 100644
> --- a/net/netfilter/ipset/ip_set_core.c
> +++ b/net/netfilter/ipset/ip_set_core.c
> @@ -1182,6 +1182,14 @@ ip_set_destroy_set(struct ip_set *set)
> kfree(set);
> }
>
> +static void
> +ip_set_destroy_set_rcu(struct rcu_head *head)
> +{
> + struct ip_set *set = container_of(head, struct ip_set, rcu);
> +
> + ip_set_destroy_set(set);
Calling ip_set_destroy_set() from BH (rcu callbacks) is not working.
I think you should test your patch with LOCKDEP enabled, and/or
CONFIG_DEBUG_ATOMIC_SLEEP=y
next prev parent reply other threads:[~2024-01-18 10:08 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 16:00 [PATCH net 00/14] Netfilter fixes for net Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 01/14] netfilter: nf_tables: reject invalid set policy Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 02/14] netfilter: nf_tables: validate .maxattr at expression registration Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 03/14] netfilter: nf_tables: bail out if stateful expression provides no .clone Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 04/14] netfilter: nft_limit: do not ignore unsupported flags Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 05/14] netfilter: nfnetlink_log: use proper helper for fetching physinif Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 06/14] netfilter: nf_queue: remove excess nf_bridge variable Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 07/14] netfilter: propagate net to nf_bridge_get_physindev Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 08/14] netfilter: bridge: replace physindev with physinif in nf_bridge_info Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 09/14] netfilter: nf_tables: check if catch-all set element is active in next generation Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 10/14] netfilter: nf_tables: do not allow mismatch field size and set key length Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 11/14] netfilter: nf_tables: skip dead set elements in netlink dump Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 12/14] netfilter: nf_tables: reject NFT_SET_CONCAT with not field length description Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 13/14] ipvs: avoid stat macros calls from preemptible context Pablo Neira Ayuso
2024-01-17 16:00 ` [PATCH net 14/14] netfilter: ipset: fix performance regression in swap operation Pablo Neira Ayuso
2024-01-17 16:08 ` Eric Dumazet
2024-01-17 16:23 ` Jozsef Kadlecsik
2024-01-17 16:28 ` Eric Dumazet
2024-01-18 11:08 ` Paolo Abeni
2024-01-18 12:14 ` Eric Dumazet
2024-01-18 10:08 ` Eric Dumazet [this message]
2024-01-18 14:24 ` Jozsef Kadlecsik
2024-01-23 9:03 ` Jozsef Kadlecsik
2024-01-23 17:20 ` David Wang
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=CANn89iKtpVy1kSSuk_RSGN0R6L+roNJr81ED4+a2SZ2WKzGsng@mail.gmail.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.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).