[Git][ghc/ghc][wip/tsan/all] 5 commits: Fix ordering of SET_HDR and add SET_HDR_RELEASE

Ben Gamari gitlab at gitlab.haskell.org
Sun Oct 25 00:05:16 UTC 2020



Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC


Commits:
7d1fa38e by Ben Gamari at 2020-10-24T11:02:46-04:00
Fix ordering of SET_HDR and add SET_HDR_RELEASE

- - - - -
088e8cb5 by Ben Gamari at 2020-10-24T11:03:00-04:00
lockCAF

- - - - -
9a810bab by Ben Gamari at 2020-10-24T11:12:11-04:00
TSANUtils: Ensure that C11 atomics are supported

- - - - -
aa15b37e by Ben Gamari at 2020-10-24T19:51:15-04:00
rts: Move stat_exit until after exitHeapProfiling

Since the latter wants to call getRTSStats.

- - - - -
eb195518 by Ben Gamari at 2020-10-24T19:56:01-04:00
WSDeque tweak

- - - - -


5 changed files:

- includes/rts/TSANUtils.h
- includes/rts/storage/ClosureMacros.h
- rts/RtsStartup.c
- rts/WSDeque.c
- rts/sm/Storage.c


Changes:

=====================================
includes/rts/TSANUtils.h
=====================================
@@ -40,6 +40,10 @@
 #endif
 
 #if defined(TSAN_ENABLED)
+#if !defined(HAVE_C11_ATOMICS)
+#error TSAN cannot be enabled without C11 atomics suppoort.
+#endif
+
 #define TSAN_ANNOTATE_HAPPENS_BEFORE(addr)                              \
     AnnotateHappensBefore(__FILE__, __LINE__, (void*)(addr))
 #define TSAN_ANNOTATE_HAPPENS_AFTER(addr)                               \


=====================================
includes/rts/storage/ClosureMacros.h
=====================================
@@ -140,13 +140,19 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con)
 
 #define SET_HDR(c,_info,ccs)                            \
    {                                                    \
+        SET_PROF_HDR((StgClosure *)(c),ccs);            \
         RELAXED_STORE(&(c)->header.info, _info);        \
+   }
+
+#define SET_HDR_RELEASE(c,_info,ccs)                    \
+   {                                                    \
         SET_PROF_HDR((StgClosure *)(c),ccs);            \
+        RELEASE_STORE(&(c)->header.info, _info);        \
    }
 
 #define SET_ARR_HDR(c,info,costCentreStack,n_bytes)     \
-   SET_HDR(c,info,costCentreStack);                     \
-   (c)->bytes = n_bytes;
+   (c)->bytes = n_bytes;                                \
+   SET_HDR(c,info,costCentreStack);
 
 // Use when changing a closure from one kind to another
 #define OVERWRITE_INFO(c, new_info)                             \


=====================================
rts/RtsStartup.c
=====================================
@@ -574,6 +574,10 @@ hs_exit_(bool wait_foreign)
    if (is_io_mng_native_p())
       hs_restoreConsoleCP();
 #endif
+
+    /* Print the final runtime stats */
+    stat_exit();
+
     /* free hash table storage */
     exitHashTable();
 


=====================================
rts/WSDeque.c
=====================================
@@ -52,6 +52,7 @@
 #include "RtsUtils.h"
 #include "WSDeque.h"
 
+// Returns true on success.
 static inline bool
 cas_top(WSDeque *q, StgInt old, StgInt new)
 {
@@ -211,13 +212,13 @@ pushWSDeque (WSDeque* q, void * elem)
     }
 
     RELAXED_STORE(&q->elements[b & q->moduloSize], elem);
-    RELEASE_FENCE();
 #if defined(TSAN_ENABLED)
     // ThreadSanizer doesn't know about release fences, so we need to
     // strengthen this to a release store lest we get spurious data race
     // reports.
     RELEASE_STORE(&q->bottom, b+1);
 #else
+    RELEASE_FENCE();
     RELAXED_STORE(&q->bottom, b+1);
 #endif
     return true;


=====================================
rts/sm/Storage.c
=====================================
@@ -302,7 +302,6 @@ exitStorage (void)
 {
     nonmovingExit();
     updateNurseriesStats();
-    stat_exit();
 }
 
 void
@@ -500,11 +499,11 @@ lockCAF (StgRegTable *reg, StgIndStatic *caf)
         bh = (StgInd *)allocate(cap, sizeofW(*bh));
     }
     bh->indirectee = (StgClosure *)cap->r.rCurrentTSO;
-    SET_HDR(bh, &stg_CAF_BLACKHOLE_info, caf->header.prof.ccs);
+    SET_HDR_RELEASE(bh, &stg_CAF_BLACKHOLE_info, caf->header.prof.ccs);
 
     // RELEASE ordering to ensure that above writes are visible before we
     // introduce reference as CAF indirectee.
-    RELEASE_STORE(&caf->indirectee, (StgClosure *) bh);
+    RELAXED_STORE(&caf->indirectee, (StgClosure *) bh);
     SET_INFO_RELEASE((StgClosure*)caf, &stg_IND_STATIC_info);
 
     return bh;



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47c904e9946951d43f9950acef35c1f16d890bf5...eb195518f11b9cc28c051388484d867124f390dd

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47c904e9946951d43f9950acef35c1f16d890bf5...eb195518f11b9cc28c051388484d867124f390dd
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20201024/df412ed7/attachment-0001.html>


More information about the ghc-commits mailing list