From: Adrian Moreno <amorenoz@redhat.com>
To: netdev@vger.kernel.org
Cc: aconole@redhat.com, pabeni@redhat.com,
Adrian Moreno <amorenoz@redhat.com>,
Eelco Chaudron <echaudro@redhat.com>,
Ilya Maximets <i.maximets@ovn.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
dev@openvswitch.org (open list:OPENVSWITCH),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH net-next v4 4/4] net: openvswitch: avoid double-rcu wait period
Date: Thu, 11 Jun 2026 06:58:11 +0200 [thread overview]
Message-ID: <20260611045817.1302665-5-amorenoz@redhat.com> (raw)
In-Reply-To: <20260611045817.1302665-1-amorenoz@redhat.com>
Avoid waiting for two rcu periods by scheduling the deletion of the
flow_table and all of its referenced structs at the same time.
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
net/openvswitch/flow_table.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c
index 3934873a44c3..35232e1af8aa 100644
--- a/net/openvswitch/flow_table.c
+++ b/net/openvswitch/flow_table.c
@@ -527,30 +527,33 @@ static void table_instance_destroy(struct table_instance *ti,
call_rcu(&ufid_ti->rcu, flow_tbl_destroy_rcu_cb);
}
-/* No need for locking this function is called from RCU callback. */
static void ovs_flow_tbl_destroy_rcu(struct rcu_head *rcu)
{
struct flow_table *table = container_of(rcu, struct flow_table, rcu);
- struct table_instance *ti = rcu_dereference_raw(table->ti);
- struct table_instance *ufid_ti = rcu_dereference_raw(table->ufid_ti);
- struct mask_cache *mc = rcu_dereference_raw(table->mask_cache);
- struct mask_array *ma = rcu_dereference_raw(table->mask_array);
-
- call_rcu(&mc->rcu, mask_cache_rcu_cb);
- call_rcu(&ma->rcu, mask_array_rcu_cb);
- table_instance_destroy(ti, ufid_ti);
mutex_destroy(&table->lock);
kfree(table);
}
void ovs_flow_tbl_put(struct flow_table *table)
{
+ struct table_instance *ufid_ti;
+ struct table_instance *ti;
+ struct mask_cache *mc;
+ struct mask_array *ma;
+
if (refcount_dec_and_test(&table->refcnt)) {
mutex_lock(&table->lock);
- table_instance_flow_flush(table,
- ovs_tbl_dereference(table->ti, table),
- ovs_tbl_dereference(table->ufid_ti, table));
+ ufid_ti = ovs_tbl_dereference(table->ufid_ti, table);
+ ti = ovs_tbl_dereference(table->ti, table);
+ table_instance_flow_flush(table, ti, ufid_ti);
+ table_instance_destroy(ti, ufid_ti);
+
+ mc = ovs_tbl_dereference(table->mask_cache, table);
+ ma = ovs_tbl_dereference(table->mask_array, table);
+ call_rcu(&mc->rcu, mask_cache_rcu_cb);
+ call_rcu(&ma->rcu, mask_array_rcu_cb);
+
mutex_unlock(&table->lock);
call_rcu(&table->rcu, ovs_flow_tbl_destroy_rcu);
}
--
2.54.0
next prev parent reply other threads:[~2026-06-11 4:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 4:58 [PATCH net-next v4 0/4] net: openvswitch: Decouple flow operations from RTNL Adrian Moreno
2026-06-11 4:58 ` [PATCH net-next v4 1/4] net: openvswitch: make flow_table an rcu pointer Adrian Moreno
2026-06-12 12:32 ` Eelco Chaudron
2026-06-11 4:58 ` [PATCH net-next v4 2/4] net: openvswitch: add per-flow_table lockdep checks Adrian Moreno
2026-06-15 13:55 ` Eelco Chaudron
2026-06-11 4:58 ` [PATCH net-next v4 3/4] net: openvswitch: decouple flow_table from ovs_mutex Adrian Moreno
2026-06-15 13:55 ` Eelco Chaudron
2026-06-11 4:58 ` Adrian Moreno [this message]
2026-06-15 13:56 ` [PATCH net-next v4 4/4] net: openvswitch: avoid double-rcu wait period Eelco Chaudron
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=20260611045817.1302665-5-amorenoz@redhat.com \
--to=amorenoz@redhat.com \
--cc=aconole@redhat.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=echaudro@redhat.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=i.maximets@ovn.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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