vppinfra: refactor use of CLIB_MEMORY_BARRIER ()
All instances of test_and_set locks used the following sequence
to release the locks:
CLIB_MEMORY_BARRIER ();
p->lock = 0; // p is a generic struct with a TAS lock
Use clib_atomic_release to generate more efficient assembly code.
Type: refactor
Change-Id: Idca3a38b1cf43578108bdd1afe83b6ebc17a4c68
Signed-off-by: Jason Zhang <jason.zhang2@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Lijian Zhang <Lijian.Zhang@arm.com>
diff --git a/src/svm/ssvm.h b/src/svm/ssvm.h
index 6c67945..60e0cc6 100644
--- a/src/svm/ssvm.h
+++ b/src/svm/ssvm.h
@@ -128,8 +128,7 @@
{
h->owner_pid = 0;
h->tag = 0;
- CLIB_MEMORY_BARRIER ();
- h->lock = 0;
+ clib_atomic_release (&h->lock);
}
}
@@ -137,8 +136,7 @@
ssvm_unlock_non_recursive (ssvm_shared_header_t * h)
{
h->tag = 0;
- CLIB_MEMORY_BARRIER ();
- h->lock = 0;
+ clib_atomic_release (&h->lock);
}
static inline void *