rts: Label all threads created by the RTS
authorBen Gamari <bgamari.foss@gmail.com>
Mon, 16 Oct 2017 19:28:02 +0000 (15:28 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 16 Oct 2017 21:24:49 +0000 (17:24 -0400)
Reviewers: austin, erikd, simonmar

Reviewed By: simonmar

Subscribers: pacak, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4068

rts/Sparks.c
rts/Weak.c
rts/posix/Signals.c
rts/win32/ConsoleHandler.c

index ecd3c38..a31a5df 100644 (file)
@@ -14,6 +14,7 @@
 #include "Trace.h"
 #include "Prelude.h"
 #include "Sparks.h"
+#include "ThreadLabels.h"
 #include "sm/HeapAlloc.h"
 
 #if defined(THREADED_RTS)
@@ -43,7 +44,7 @@ createSparkThread (Capability *cap)
 
     tso = createIOThread (cap, RtsFlags.GcFlags.initialStkSize,
                           (StgClosure *)runSparks_closure);
-
+    labelThread(cap, tso, "spark evaluator");
     traceEventCreateSparkThread(cap, tso->id);
 
     appendToRunQueue(cap,tso);
index f3e91fb..577d1cd 100644 (file)
@@ -14,6 +14,7 @@
 #include "Weak.h"
 #include "Schedule.h"
 #include "Prelude.h"
+#include "ThreadLabels.h"
 #include "Trace.h"
 
 void
@@ -151,5 +152,7 @@ scheduleFinalizers(Capability *cap, StgWeak *list)
                                rts_mkInt(cap,n)),
                            (StgClosure *)arr)
         );
+
     scheduleThread(cap,t);
+    labelThread(cap, t, "weak finalizer thread");
 }
index e75f99d..cf45019 100644 (file)
@@ -16,6 +16,7 @@
 #include "Prelude.h"
 #include "Ticker.h"
 #include "Stable.h"
+#include "ThreadLabels.h"
 #include "Libdw.h"
 
 #if defined(alpha_HOST_ARCH)
@@ -471,14 +472,16 @@ startSignalHandlers(Capability *cap)
            // freed by runHandler
     memcpy(info, next_pending_handler, sizeof(siginfo_t));
 
-    scheduleThread(cap,
+    StgTSO *t =
         createIOThread(cap,
-          RtsFlags.GcFlags.initialStkSize,
-              rts_apply(cap,
-                  rts_apply(cap,
-                      &base_GHCziConcziSignal_runHandlersPtr_closure,
-                      rts_mkPtr(cap, info)),
-                  rts_mkInt(cap, info->si_signo))));
+                       RtsFlags.GcFlags.initialStkSize,
+                       rts_apply(cap,
+                                 rts_apply(cap,
+                                           &base_GHCziConcziSignal_runHandlersPtr_closure,
+                                           rts_mkPtr(cap, info)),
+                                 rts_mkInt(cap, info->si_signo)));
+    scheduleThread(cap, t);
+    labelThread(cap, t, "signal handler thread");
   }
 
   unblockUserSignals();
index 3d283b0..88c4a61 100644 (file)
@@ -183,13 +183,15 @@ void startSignalHandlers(Capability *cap)
     handler = deRefStablePtr((StgStablePtr)console_handler);
     while (stg_pending_events > 0) {
         stg_pending_events--;
-        scheduleThread(cap,
+        StgTSO *t =
             createIOThread(cap,
-                RtsFlags.GcFlags.initialStkSize,
-                rts_apply(cap,
-                    (StgClosure *)handler,
-                    rts_mkInt(cap,
-                        stg_pending_buf[stg_pending_events]))));
+                           RtsFlags.GcFlags.initialStkSize,
+                           rts_apply(cap,
+                                     (StgClosure *)handler,
+                                     rts_mkInt(cap,
+                                               stg_pending_buf[stg_pending_events])));
+        scheduleThread(cap, t);
+        labelThread(cap, t, "signal handler thread");
     }
 
     RELEASE_LOCK(&sched_mutex);