summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/elog.c3
-rw-r--r--src/vppinfra/lock.h19
-rw-r--r--src/vppinfra/mheap.c3
3 files changed, 8 insertions, 17 deletions
diff --git a/src/vppinfra/elog.c b/src/vppinfra/elog.c
index 489ccf436d9..caddf6f3757 100644
--- a/src/vppinfra/elog.c
+++ b/src/vppinfra/elog.c
@@ -56,8 +56,7 @@ elog_unlock (elog_main_t * em)
{
if (PREDICT_FALSE (em->lock != 0))
{
- CLIB_MEMORY_BARRIER ();
- *em->lock = 0;
+ clib_atomic_release (em->lock);
}
}
diff --git a/src/vppinfra/lock.h b/src/vppinfra/lock.h
index 337c5a3f0ad..59ab0e33c51 100644
--- a/src/vppinfra/lock.h
+++ b/src/vppinfra/lock.h
@@ -89,9 +89,8 @@ static_always_inline void
clib_spinlock_unlock (clib_spinlock_t * p)
{
CLIB_LOCK_DBG_CLEAR (p);
- /* Make sure all writes are complete before releasing the lock */
- CLIB_MEMORY_BARRIER ();
- (*p)->lock = 0;
+ /* Make sure all reads/writes are complete before releasing the lock */
+ clib_atomic_release (&(*p)->lock);
}
static_always_inline void
@@ -147,9 +146,7 @@ clib_rwlock_reader_lock (clib_rwlock_t * p)
while (clib_atomic_test_and_set (&(*p)->writer_lock))
CLIB_PAUSE ();
}
- CLIB_MEMORY_BARRIER ();
- (*p)->n_readers_lock = 0;
-
+ clib_atomic_release (&(*p)->n_readers_lock);
CLIB_LOCK_DBG (p);
}
@@ -165,12 +162,9 @@ clib_rwlock_reader_unlock (clib_rwlock_t * p)
(*p)->n_readers -= 1;
if ((*p)->n_readers == 0)
{
- CLIB_MEMORY_BARRIER ();
- (*p)->writer_lock = 0;
+ clib_atomic_release (&(*p)->writer_lock);
}
-
- CLIB_MEMORY_BARRIER ();
- (*p)->n_readers_lock = 0;
+ clib_atomic_release (&(*p)->n_readers_lock);
}
always_inline void
@@ -185,8 +179,7 @@ always_inline void
clib_rwlock_writer_unlock (clib_rwlock_t * p)
{
CLIB_LOCK_DBG_CLEAR (p);
- CLIB_MEMORY_BARRIER ();
- (*p)->writer_lock = 0;
+ clib_atomic_release (&(*p)->writer_lock);
}
#endif
diff --git a/src/vppinfra/mheap.c b/src/vppinfra/mheap.c
index 2769838d4ba..b5566bd6389 100644
--- a/src/vppinfra/mheap.c
+++ b/src/vppinfra/mheap.c
@@ -82,8 +82,7 @@ mheap_maybe_unlock (void *v)
if (--h->recursion_count == 0)
{
h->owner_cpu = ~0;
- CLIB_MEMORY_BARRIER ();
- h->lock = 0;
+ clib_atomic_release (&h->lock);
}
}
}