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

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