[commit: ghc] master: Some assertions and comments in scheduler (6677235)

git at git.haskell.org git at git.haskell.org
Sat Nov 17 05:36:04 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/6677235181ea94311ae2133a7ef8a7decdbf0bb9/ghc

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

commit 6677235181ea94311ae2133a7ef8a7decdbf0bb9
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Sat Nov 17 07:59:15 2018 +0300

    Some assertions and comments in scheduler
    
    Test Plan:
    I can't validate this because of existing errors with the debug runtime. I'll
    see if this introduces any new failures.
    
    Reviewers: simonmar, bgamari, erikd
    
    Reviewed By: simonmar
    
    Subscribers: rwbarton, carter
    
    Differential Revision: https://phabricator.haskell.org/D5337


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

6677235181ea94311ae2133a7ef8a7decdbf0bb9
 rts/Capability.h | 5 ++++-
 rts/Schedule.c   | 7 +++++--
 rts/Schedule.h   | 1 +
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/rts/Capability.h b/rts/Capability.h
index 250ec22..05a827c 100644
--- a/rts/Capability.h
+++ b/rts/Capability.h
@@ -264,7 +264,10 @@ typedef enum {
 //
 typedef struct {
     SyncType type;              // The kind of synchronisation
-    bool *idle;
+    bool *idle;                 // Array of size n_capabilities. idle[i] is true
+                                // if capability i will be idle during this GC
+                                // cycle. Only available when doing GC (when
+                                // type is SYNC_GC_*).
     Task *task;                 // The Task performing the sync
 } PendingSync;
 
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 0444f0c..d104cfd 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -668,8 +668,10 @@ scheduleYield (Capability **pcap, Task *task)
     // otherwise yield (sleep), and keep yielding if necessary.
     do {
         if (doIdleGCWork(cap, false)) {
+            // there's more idle GC work to do
             didGcLast = false;
         } else {
+            // no more idle GC work to do
             didGcLast = yieldCapability(&cap,task, !didGcLast);
         }
     }
@@ -1876,7 +1878,7 @@ delete_threads_and_gc:
         releaseGCThreads(cap, idle_cap);
     }
 #endif
-    if (heap_overflow && sched_state < SCHED_INTERRUPTING) {
+    if (heap_overflow && sched_state == SCHED_RUNNING) {
         // GC set the heap_overflow flag.  We should throw an exception if we
         // can, or shut down otherwise.
 
@@ -2660,7 +2662,7 @@ exitScheduler (bool wait_foreign USED_IF_THREADS)
         ASSERT(task->incall->tso == NULL);
         releaseCapability(cap);
     }
-    sched_state = SCHED_SHUTTING_DOWN;
+    ASSERT(sched_state == SCHED_SHUTTING_DOWN);
 
     shutdownCapabilities(task, wait_foreign);
 
@@ -2749,6 +2751,7 @@ performMajorGC(void)
 void
 interruptStgRts(void)
 {
+    ASSERT(sched_state != SCHED_SHUTTING_DOWN);
     sched_state = SCHED_INTERRUPTING;
     interruptAllCapabilities();
 #if defined(THREADED_RTS)
diff --git a/rts/Schedule.h b/rts/Schedule.h
index 49e094b..66cf839 100644
--- a/rts/Schedule.h
+++ b/rts/Schedule.h
@@ -167,6 +167,7 @@ pushOnRunQueue (Capability *cap, StgTSO *tso)
 INLINE_HEADER StgTSO *
 popRunQueue (Capability *cap)
 {
+    ASSERT(cap->n_run_queue != 0);
     StgTSO *t = cap->run_queue_hd;
     ASSERT(t != END_TSO_QUEUE);
     cap->run_queue_hd = t->_link;



More information about the ghc-commits mailing list