[commit: ghc] master: [rts] Adjust whitehole_spin (180ca65)

git at git.haskell.org git at git.haskell.org
Mon Jan 22 01:39:50 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/180ca65ff6d1b4f3f4cdadc569fd4de107be14db/ghc

>---------------------------------------------------------------

commit 180ca65ff6d1b4f3f4cdadc569fd4de107be14db
Author: Douglas Wilson <douglas.wilson at gmail.com>
Date:   Sun Jan 21 12:08:19 2018 -0500

    [rts] Adjust whitehole_spin
    
    Rename to whitehole_gc_spin, in preparation for adding stats for the
    whitehole busy-loop in SMPClosureOps.
    
    Make whitehole_gc_spin volatile, and move it to be defined and
    statically initialised in GC.c. This saves some #ifs, and I'm pretty
    sure it should be volatile.
    
    Test Plan: ./validate
    
    Reviewers: bgamari, erikd, simonmar
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D4300


>---------------------------------------------------------------

180ca65ff6d1b4f3f4cdadc569fd4de107be14db
 rts/Stats.c      | 5 +++--
 rts/sm/Evac.c    | 7 ++-----
 rts/sm/GC.c      | 4 ++++
 rts/sm/GC.h      | 2 +-
 rts/sm/Storage.c | 4 ----
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/rts/Stats.c b/rts/Stats.c
index fa85878..26bdac0 100644
--- a/rts/Stats.c
+++ b/rts/Stats.c
@@ -16,7 +16,7 @@
 #include "Profiling.h"
 #include "GetTime.h"
 #include "sm/Storage.h"
-#include "sm/GC.h" // gc_alloc_block_sync, whitehole_spin
+#include "sm/GC.h" // gc_alloc_block_sync, whitehole_gc_spin
 #include "sm/GCThread.h"
 #include "sm/BlockAlloc.h"
 
@@ -769,7 +769,8 @@ stat_exit (void)
                 uint32_t g;
 
                 statsPrintf("gc_alloc_block_sync: %"FMT_Word64"\n", gc_alloc_block_sync.spin);
-                statsPrintf("whitehole_spin: %"FMT_Word64"\n", whitehole_spin);
+                statsPrintf("whitehole_gc_spin: %"FMT_Word64"\n"
+                            , whitehole_gc_spin);
                 for (g = 0; g < RtsFlags.GcFlags.generations; g++) {
                     statsPrintf("gen[%d].sync: %"FMT_Word64"\n", g, generations[g].sync.spin);
                 }
diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c
index 526f063..738e3e4 100644
--- a/rts/sm/Evac.c
+++ b/rts/sm/Evac.c
@@ -28,10 +28,6 @@
 #include "CNF.h"
 #include "Scav.h"
 
-#if defined(PROF_SPIN) && defined(THREADED_RTS) && defined(PARALLEL_GC)
-StgWord64 whitehole_spin = 0;
-#endif
-
 #if defined(THREADED_RTS) && !defined(PARALLEL_GC)
 #define evacuate(p) evacuate1(p)
 #define evacuate_BLACKHOLE(p) evacuate_BLACKHOLE1(p)
@@ -197,8 +193,9 @@ spin:
         info = xchg((StgPtr)&src->header.info, (W_)&stg_WHITEHOLE_info);
         if (info == (W_)&stg_WHITEHOLE_info) {
 #if defined(PROF_SPIN)
-            whitehole_spin++;
+            whitehole_gc_spin++;
 #endif
+            busy_wait_nop();
             goto spin;
         }
     if (IS_FORWARDING_PTR(info)) {
diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index 4dbc5e0..c5ab7a8 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -133,6 +133,10 @@ uint32_t n_gc_threads;
 // For stats:
 static long copied;        // *words* copied & scavenged during this GC
 
+#if defined(PROF_SPIN) && defined(THREADED_RTS)
+volatile StgWord64 whitehole_gc_spin = 0;
+#endif
+
 bool work_stealing;
 
 uint32_t static_flag = STATIC_FLAG_B;
diff --git a/rts/sm/GC.h b/rts/sm/GC.h
index c6b0c13..78f0549 100644
--- a/rts/sm/GC.h
+++ b/rts/sm/GC.h
@@ -46,7 +46,7 @@ extern uint32_t mutlist_MUTVARS, mutlist_MUTARRS, mutlist_MVARS, mutlist_OTHERS,
 #endif
 
 #if defined(PROF_SPIN) && defined(THREADED_RTS)
-extern StgWord64 whitehole_spin;
+extern volatile StgWord64 whitehole_gc_spin;
 #endif
 
 void gcWorkerThread (Capability *cap);
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index e801c34..c4dbdc2 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -197,11 +197,7 @@ initStorage (void)
 
 #if defined(THREADED_RTS)
   initSpinLock(&gc_alloc_block_sync);
-#if defined(PROF_SPIN)
-  whitehole_spin = 0;
 #endif
-#endif
-
   N = 0;
 
   for (n = 0; n < n_numa_nodes; n++) {



More information about the ghc-commits mailing list