diff options
author | Yanqin Wei <Yanqin.Wei@arm.com> | 2019-11-18 10:45:18 +0800 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-10-18 12:20:55 +0200 |
commit | 31db0e043119cf597d720d94f70ec19cf5b8b7d4 (patch) | |
tree | 56b170ae415e824353bdda5f0a521efb924e272c /lib | |
parent | 6f535383948664794ceccf5471e6d77000478877 (diff) | |
download | openvswitch-31db0e043119cf597d720d94f70ec19cf5b8b7d4.tar.gz |
cmap: Add thread fence for slot update.
Bucket update in the cmap lib is protected by a counter. But hash setting
is possible to be moved before counter update. This patch fix this issue.
Reviewed-by: Ola Liljedahl <Ola.Liljedahl@arm.com>
Reviewed-by: Gavin Hu <Gavin.Hu@arm.com>
Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cmap.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/cmap.c b/lib/cmap.c index c9eef3f4a..8ca893b0b 100644 --- a/lib/cmap.c +++ b/lib/cmap.c @@ -598,7 +598,9 @@ cmap_set_bucket(struct cmap_bucket *b, int i, uint32_t c; atomic_read_explicit(&b->counter, &c, memory_order_acquire); - atomic_store_explicit(&b->counter, c + 1, memory_order_release); + atomic_store_explicit(&b->counter, c + 1, memory_order_relaxed); + /* Need to make sure setting hash is not moved up before counter update. */ + atomic_thread_fence(memory_order_release); ovsrcu_set(&b->nodes[i].next, node); /* Also atomic. */ b->hashes[i] = hash; atomic_store_explicit(&b->counter, c + 2, memory_order_release); |