[Git][ghc/ghc][wip/tsan/fixes-2] 2 commits: warnings

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Mon Jun 26 21:46:25 UTC 2023



Ben Gamari pushed to branch wip/tsan/fixes-2 at Glasgow Haskell Compiler / GHC


Commits:
e8030d79 by Ben Gamari at 2023-06-26T17:45:50-04:00
warnings

- - - - -
757ac787 by Ben Gamari at 2023-06-26T17:46:02-04:00
rts: Fixes profiling timer races

- - - - -


4 changed files:

- rts/Proftimer.c
- rts/Schedule.c
- rts/include/stg/SMP.h
- rts/sm/GC.c


Changes:

=====================================
rts/Proftimer.c
=====================================
@@ -101,7 +101,7 @@ requestHeapCensus( void ){
 void
 initProfTimer( void )
 {
-    performHeapProfile = false;
+    RELAXED_STORE_ALWAYS(&performHeapProfile = false);
 
     ticks_to_heap_profile = RtsFlags.ProfFlags.heapProfileIntervalTicks;
 
@@ -136,7 +136,7 @@ handleProfTick(void)
         ticks_to_ticky_sample--;
         if (ticks_to_ticky_sample <= 0) {
             ticks_to_ticky_sample = RtsFlags.ProfFlags.heapProfileIntervalTicks;
-            performTickySample = true;
+            RELAXED_STORE_ALWAYS(&performTickySample, true);
         }
     }
 #endif
@@ -145,7 +145,7 @@ handleProfTick(void)
         ticks_to_heap_profile--;
         if (ticks_to_heap_profile <= 0) {
             ticks_to_heap_profile = RtsFlags.ProfFlags.heapProfileIntervalTicks;
-            performHeapProfile = true;
+            RELAXED_STORE_ALWAYS(&performHeapProfile, true);
         }
     }
 }


=====================================
rts/Schedule.c
=====================================
@@ -1382,7 +1382,7 @@ scheduleNeedHeapProfile( bool ready_to_gc )
 {
     // When we have +RTS -i0 and we're heap profiling, do a census at
     // every GC.  This lets us get repeatable runs for debugging.
-    if (performHeapProfile ||
+    if (RELAXED_LOAD(&performHeapProfile) ||
         (RtsFlags.ProfFlags.heapProfileInterval==0 &&
          RtsFlags.ProfFlags.doHeapProfile && ready_to_gc)) {
         return true;
@@ -1943,7 +1943,7 @@ delete_threads_and_gc:
 
     // The heap census itself is done during GarbageCollect().
     if (heap_census) {
-        performHeapProfile = false;
+        RELAXED_STORE(&performHeapProfile, false);
     }
 
 #if defined(THREADED_RTS)


=====================================
rts/include/stg/SMP.h
=====================================
@@ -585,9 +585,12 @@ busy_wait_nop(void)
 
 #define ACQUIRE_FENCE() __atomic_thread_fence(__ATOMIC_ACQUIRE)
 #define RELEASE_FENCE() __atomic_thread_fence(__ATOMIC_RELEASE)
-#define SEQ_CST_FENCE() NO_WARN(-Wtsan, __atomic_thread_fence(__ATOMIC_SEQ_CST);)
+#define SEQ_CST_FENCE() __atomic_thread_fence(__ATOMIC_SEQ_CST)
 
 #if defined(TSAN_ENABLED)
+#define ACQUIRE_FENCE() NO_WARN(-Wtsan, __atomic_thread_fence(__ATOMIC_ACQUIRE);)
+#define RELEASE_FENCE() NO_WARN(-Wtsan, __atomic_thread_fence(__ATOMIC_RELEASE);)
+#define SEQ_CST_FENCE() NO_WARN(-Wtsan, __atomic_thread_fence(__ATOMIC_SEQ_CST);)
 #define ACQUIRE_FENCE_ON(x) (void)ACQUIRE_LOAD(x)
 #else
 #define ACQUIRE_FENCE_ON(x) __atomic_thread_fence(__ATOMIC_ACQUIRE)


=====================================
rts/sm/GC.c
=====================================
@@ -977,9 +977,9 @@ GarbageCollect (struct GcConfig config,
   // Post ticky counter sample.
   // We do this at the end of execution since tickers are registered in the
   // course of program execution.
-  if (performTickySample) {
+  if (RELAXED_LOAD(&performTickySample)) {
       emitTickyCounterSamples();
-      performTickySample = false;
+      RELAXED_STORE(&performTickySample, false);
   }
 #endif
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1b868666f1213f74badd3ebbb323ab126f3f44d3...757ac787b39c30cb97e6cd28e3231909bd146adf

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1b868666f1213f74badd3ebbb323ab126f3f44d3...757ac787b39c30cb97e6cd28e3231909bd146adf
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/20230626/2b748342/attachment-0001.html>


More information about the ghc-commits mailing list