andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0000-Ticket-49164-Change-NS-to-acq-rel-semantics-for-atom.patch

b69e47
From 70230bf894d9c0150dca8dc6fccc2712187f7b86 Mon Sep 17 00:00:00 2001
b69e47
From: William Brown <firstyear@redhat.com>
b69e47
Date: Mon, 13 Mar 2017 13:29:43 +1000
b69e47
Subject: [PATCH 1/5] Ticket 49164 - Change NS to acq-rel semantics for atomics
b69e47
b69e47
Bug Description:  We were using seq_cst to guarantee our operations
b69e47
as a poc. Changing to acq/rel allows us the same guarantees, but
b69e47
with less overheads.
b69e47
b69e47
Fix Description:  Change the barrier type.
b69e47
b69e47
https://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync
b69e47
b69e47
https://pagure.io/389-ds-base/issue/49164
b69e47
b69e47
Author: wibrown
b69e47
b69e47
Review by: mreynolds (Thanks!)
b69e47
b69e47
(cherry picked from commit b1b0574d2cdb012ab206999ed51f08d3340386ce)
b69e47
---
b69e47
 src/nunc-stans/ns/ns_thrpool.c | 8 ++++----
b69e47
 1 file changed, 4 insertions(+), 4 deletions(-)
b69e47
b69e47
diff --git a/src/nunc-stans/ns/ns_thrpool.c b/src/nunc-stans/ns/ns_thrpool.c
b69e47
index 744749b..a867b39 100644
b69e47
--- a/src/nunc-stans/ns/ns_thrpool.c
b69e47
+++ b/src/nunc-stans/ns/ns_thrpool.c
b69e47
@@ -167,7 +167,7 @@ ns_thrpool_is_shutdown(struct ns_thrpool_t *tp)
b69e47
 {
b69e47
     /* We need to barrier this somehow? */
b69e47
     int32_t result = 0;
b69e47
-    __atomic_load(&(tp->shutdown), &result, __ATOMIC_SEQ_CST);
b69e47
+    __atomic_load(&(tp->shutdown), &result, __ATOMIC_ACQUIRE);
b69e47
     return result;
b69e47
 }
b69e47
 
b69e47
@@ -176,7 +176,7 @@ ns_thrpool_is_event_shutdown(struct ns_thrpool_t *tp)
b69e47
 {
b69e47
     /* We need to barrier this somehow? */
b69e47
     int32_t result = 0;
b69e47
-    __atomic_load(&(tp->shutdown_event_loop), &result, __ATOMIC_SEQ_CST);
b69e47
+    __atomic_load(&(tp->shutdown_event_loop), &result, __ATOMIC_ACQUIRE);
b69e47
     return result;
b69e47
 }
b69e47
 
b69e47
@@ -1402,7 +1402,7 @@ ns_thrpool_destroy(struct ns_thrpool_t *tp)
b69e47
 #endif
b69e47
     if (tp) {
b69e47
         /* Set the flag to shutdown the event loop. */
b69e47
-        __atomic_add_fetch(&(tp->shutdown_event_loop), 1, __ATOMIC_SEQ_CST);
b69e47
+        __atomic_add_fetch(&(tp->shutdown_event_loop), 1, __ATOMIC_RELEASE);
b69e47
 
b69e47
         /* Finish the event queue wakeup job.  This has the
b69e47
          * side effect of waking up the event loop thread, which
b69e47
@@ -1491,7 +1491,7 @@ ns_thrpool_shutdown(struct ns_thrpool_t *tp)
b69e47
     }
b69e47
     /* Set the shutdown flag.  This will cause the worker
b69e47
      * threads to exit after they finish all remaining work. */
b69e47
-    __atomic_add_fetch(&(tp->shutdown), 1, __ATOMIC_SEQ_CST);
b69e47
+    __atomic_add_fetch(&(tp->shutdown), 1, __ATOMIC_RELEASE);
b69e47
 
b69e47
     /* Wake up the idle worker threads so they can exit. */
b69e47
     pthread_mutex_lock(&(tp->work_q_lock));
b69e47
-- 
b69e47
2.9.3
b69e47