Message ID | 1487272989-8215-2-git-send-email-jgunthorpe@obsidianresearch.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
diff --git a/providers/mlx5/mlx5.h b/providers/mlx5/mlx5.h index be52a0a75dded0..e63164c2caea7b 100644 --- a/providers/mlx5/mlx5.h +++ b/providers/mlx5/mlx5.h @@ -35,6 +35,7 @@ #include <stddef.h> #include <stdio.h> +#include <stdatomic.h> #include <util/compiler.h> #include <infiniband/driver.h> @@ -683,7 +684,11 @@ static inline int mlx5_spin_lock(struct mlx5_spinlock *lock) abort(); } else { lock->in_use = 1; - wmb(); + /* + * This fence is not at all correct, but it increases the + * chance that in_use is detected by another thread without + * much runtime cost. */ + atomic_thread_fence(memory_order_acq_rel); } return 0;
Since this is not a DMA barrier we do not want to use wmb() here. Replace it with a weak atomic fence. For x86-64 this has no change to the assembly output. Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> --- providers/mlx5/mlx5.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)