This annotation never worked on structure fields, but it does now with
clang 21. The problem is that structures like cmap or rculist are
designed for lockless access for readers and so we're not holding any
locks while reading. That makes new clang generate thread-safety
warnings:
lib/dpif-netdev.c:3632:40:
warning: reading the value pointed to by 'flow_table' requires
holding any mutex [-Wthread-safety-analysis]
3632 | &pmd->flow_table) {
| ^
Signed-off-by: Ilya Maximets <[email protected]>
---
lib/conntrack-private.h | 8 ++++----
lib/dpif-netdev-private-dpcls.h | 2 +-
lib/dpif-netdev-private-thread.h | 10 +++++-----
lib/dpif-netdev.c | 2 +-
lib/netdev-offload-tc.c | 2 +-
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/lib/conntrack-private.h b/lib/conntrack-private.h
index 46b212754..f1132e8aa 100644
--- a/lib/conntrack-private.h
+++ b/lib/conntrack-private.h
@@ -209,10 +209,10 @@ struct conntrack_zone_limit {
struct conntrack {
struct ovs_mutex ct_lock; /* Protects the following fields. */
- struct cmap conns[UINT16_MAX + 1] OVS_GUARDED;
- struct rculist exp_lists[N_EXP_LISTS] OVS_GUARDED;
- struct cmap zone_limits OVS_GUARDED;
- struct cmap timeout_policies OVS_GUARDED;
+ struct cmap conns[UINT16_MAX + 1];
+ struct rculist exp_lists[N_EXP_LISTS];
+ struct cmap zone_limits;
+ struct cmap timeout_policies;
uint32_t zone_limit_seq OVS_GUARDED; /* Used to disambiguate zone limit
* counts. */
atomic_uint32_t default_zone_limit;
diff --git a/lib/dpif-netdev-private-dpcls.h b/lib/dpif-netdev-private-dpcls.h
index 2a9279437..03f07c621 100644
--- a/lib/dpif-netdev-private-dpcls.h
+++ b/lib/dpif-netdev-private-dpcls.h
@@ -66,7 +66,7 @@ uint32_t (*dpcls_subtable_lookup_func)(struct dpcls_subtable
*subtable,
/* A set of rules that all have the same fields wildcarded. */
struct dpcls_subtable {
/* The fields are only used by writers. */
- struct cmap_node cmap_node OVS_GUARDED; /* Within dpcls 'subtables_map'. */
+ struct cmap_node cmap_node; /* Within dpcls 'subtables_map'. */
/* These fields are accessed by readers. */
struct cmap rules; /* Contains "struct dpcls_rule"s. */
diff --git a/lib/dpif-netdev-private-thread.h b/lib/dpif-netdev-private-thread.h
index 8715b3837..1992ba44b 100644
--- a/lib/dpif-netdev-private-thread.h
+++ b/lib/dpif-netdev-private-thread.h
@@ -92,13 +92,13 @@ struct dp_netdev_pmd_thread {
* made while still holding the 'flow_mutex'.
*/
struct ovs_mutex flow_mutex;
- struct cmap flow_table OVS_GUARDED; /* Flow table. */
- struct cmap simple_match_table OVS_GUARDED; /* Flow table with simple
- match flows only. */
+ struct cmap flow_table; /* Flow table. */
+ struct cmap simple_match_table; /* Flow table with simple
+ * match flows only. */
/* Number of flows in the 'flow_table' per in_port. */
- struct ccmap n_flows OVS_GUARDED;
+ struct ccmap n_flows;
/* Number of flows in the 'simple_match_table' per in_port. */
- struct ccmap n_simple_flows OVS_GUARDED;
+ struct ccmap n_simple_flows;
/* One classifier per in_port polled by the pmd */
struct cmap classifiers;
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index a0d939dfb..99d802bde 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -286,7 +286,7 @@ struct dp_netdev {
/* Meters. */
struct ovs_mutex meters_lock;
- struct cmap meters OVS_GUARDED;
+ struct cmap meters;
/* Probability of EMC insertions is a factor of 'emc_insert_min'.*/
atomic_uint32_t emc_insert_min;
diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c
index 804885285..9491dc90e 100644
--- a/lib/netdev-offload-tc.c
+++ b/lib/netdev-offload-tc.c
@@ -81,7 +81,7 @@ struct policer_node {
/* ccmap and protective mutex for counting recirculation id (chain) usage. */
static struct ovs_mutex used_chains_mutex = OVS_MUTEX_INITIALIZER;
-static struct ccmap used_chains OVS_GUARDED;
+static struct ccmap used_chains;
/* Protects below meter police ids pool. */
static struct ovs_mutex meter_police_ids_mutex = OVS_MUTEX_INITIALIZER;
--
2.51.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev