summaryrefslogtreecommitdiff
path: root/lib/netdev-provider.h
diff options
context:
space:
mode:
authorYanqin Wei <Yanqin.Wei@arm.com>2019-11-26 15:35:23 +0800
committerBen Pfaff <blp@ovn.org>2019-12-02 14:48:14 -0800
commit3343f8d6cfbe358e7f28cbd24b750b01e64f5ddd (patch)
treea75585a28a7c312ea7bdab322cf2781516017aaa /lib/netdev-provider.h
parente515e66a1900feffd4af08c2596fb8d59b07ddd6 (diff)
downloadopenvswitch-3343f8d6cfbe358e7f28cbd24b750b01e64f5ddd.tar.gz
netdev: use acquire-release semantics for change_seq in netdev
"rxq_enabled" of netdev is writen in the vhost thread and read by pmd thread once it observes 'change_seq' is updated. This patch is to keep order on aarch64 or other weak memory model CPU to ensure 'rxq_enabled' is observed before 'change_seq'. Reviewed-by: Gavin Hu <Gavin.Hu@arm.com> Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib/netdev-provider.h')
-rw-r--r--lib/netdev-provider.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h
index 1e5a40c89..f109c4e66 100644
--- a/lib/netdev-provider.h
+++ b/lib/netdev-provider.h
@@ -63,7 +63,7 @@ struct netdev {
*
* Minimally, the sequence number is required to change whenever
* 'netdev''s flags, features, ethernet address, or carrier changes. */
- uint64_t change_seq;
+ atomic_uint64_t change_seq;
/* A netdev provider might be unable to change some of the device's
* parameter (n_rxq, mtu) when the device is in use. In this case
@@ -91,12 +91,17 @@ struct netdev {
static inline void
netdev_change_seq_changed(const struct netdev *netdev_)
{
+ uint64_t change_seq;
struct netdev *netdev = CONST_CAST(struct netdev *, netdev_);
seq_change(connectivity_seq_get());
- netdev->change_seq++;
- if (!netdev->change_seq) {
- netdev->change_seq++;
+
+ atomic_read_relaxed(&netdev->change_seq, &change_seq);
+ change_seq++;
+ if (OVS_UNLIKELY(!change_seq)) {
+ change_seq++;
}
+ atomic_store_explicit(&netdev->change_seq, change_seq,
+ memory_order_release);
}
static inline void