summaryrefslogtreecommitdiff
path: root/rts/eventlog
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2012-02-03 12:20:36 +0000
committerDuncan Coutts <duncan@well-typed.com>2012-04-04 19:10:44 +0100
commitf9c2e8543cabd6661eec17d5be31469455a64e05 (patch)
tree3275bbb0e2bbcd4d8bd003584d478c0ad1e4c107 /rts/eventlog
parent4caef1c42dd5b6e4982e7f07162c9a7edc5a1b0b (diff)
downloadhaskell-f9c2e8543cabd6661eec17d5be31469455a64e05.tar.gz
Add eventlog/trace stuff for capabilities: create/delete/enable/disable
Now that we can adjust the number of capabilities on the fly, we need this reflected in the eventlog. Previously the eventlog had a single startup event that declared a static number of capabilities. Obviously that's no good anymore. For compatability we're keeping the EVENT_STARTUP but adding new EVENT_CAP_CREATE/DELETE. The EVENT_CAP_DELETE is actually just the old EVENT_SHUTDOWN but renamed and extended (using the existing mechanism to extend eventlog events in a compatible way). So we now emit both EVENT_STARTUP and EVENT_CAP_CREATE. One day we will drop EVENT_STARTUP. Since reducing the number of capabilities at runtime does not really delete them, it just disables them, then we also have new events for disable/enable. The old EVENT_SHUTDOWN was in the scheduler class of events. The new EVENT_CAP_* events are in the unconditional class, along with the EVENT_CAPSET_* ones. Knowing when capabilities are created and deleted is crucial to making sense of eventlogs, you always want those events. In any case, they're extremely low volume.
Diffstat (limited to 'rts/eventlog')
-rw-r--r--rts/eventlog/EventLog.c49
-rw-r--r--rts/eventlog/EventLog.h6
2 files changed, 46 insertions, 9 deletions
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c
index af87492876..8009a38938 100644
--- a/rts/eventlog/EventLog.c
+++ b/rts/eventlog/EventLog.c
@@ -60,9 +60,13 @@ char *EventDesc[] = {
[EVENT_STOP_THREAD] = "Stop thread",
[EVENT_THREAD_RUNNABLE] = "Thread runnable",
[EVENT_MIGRATE_THREAD] = "Migrate thread",
- [EVENT_SHUTDOWN] = "Shutdown",
[EVENT_THREAD_WAKEUP] = "Wakeup thread",
[EVENT_THREAD_LABEL] = "Thread label",
+ [EVENT_STARTUP] = "Create capabilities",
+ [EVENT_CAP_CREATE] = "Create capability",
+ [EVENT_CAP_DELETE] = "Delete capability",
+ [EVENT_CAP_DISABLE] = "Disable capability",
+ [EVENT_CAP_ENABLE] = "Enable capability",
[EVENT_GC_START] = "Starting GC",
[EVENT_GC_END] = "Finished GC",
[EVENT_REQUEST_SEQ_GC] = "Request sequential GC",
@@ -70,7 +74,6 @@ char *EventDesc[] = {
[EVENT_CREATE_SPARK_THREAD] = "Create spark thread",
[EVENT_LOG_MSG] = "Log message",
[EVENT_USER_MSG] = "User message",
- [EVENT_STARTUP] = "Startup",
[EVENT_GC_IDLE] = "GC idle",
[EVENT_GC_WORK] = "GC working",
[EVENT_GC_DONE] = "GC done",
@@ -287,7 +290,11 @@ initEventLogging(void)
sizeof(EventThreadID) + sizeof(StgWord16) + sizeof(EventThreadID);
break;
- case EVENT_STARTUP: // (cap count)
+ case EVENT_STARTUP: // (cap_count)
+ case EVENT_CAP_CREATE: // (cap)
+ case EVENT_CAP_DELETE: // (cap)
+ case EVENT_CAP_ENABLE: // (cap)
+ case EVENT_CAP_DISABLE: // (cap)
eventTypes[t].size = sizeof(EventCapNo);
break;
@@ -322,7 +329,6 @@ initEventLogging(void)
sizeof(EventCapNo);
break;
- case EVENT_SHUTDOWN: // (cap)
case EVENT_REQUEST_SEQ_GC: // (cap)
case EVENT_REQUEST_PAR_GC: // (cap)
case EVENT_GC_START: // (cap)
@@ -519,11 +525,6 @@ postSchedEvent (Capability *cap,
break;
}
- case EVENT_SHUTDOWN: // (cap)
- {
- break;
- }
-
default:
barf("postSchedEvent: unknown event tag %d", tag);
}
@@ -597,6 +598,36 @@ postSparkCountersEvent (Capability *cap,
postWord64(eb,remaining);
}
+void
+postCapEvent (EventTypeNum tag,
+ EventCapNo capno)
+{
+ ACQUIRE_LOCK(&eventBufMutex);
+
+ if (!hasRoomForEvent(&eventBuf, tag)) {
+ // Flush event buffer to make room for new event.
+ printAndClearEventBuf(&eventBuf);
+ }
+
+ postEventHeader(&eventBuf, tag);
+
+ switch (tag) {
+ case EVENT_CAP_CREATE: // (cap)
+ case EVENT_CAP_DELETE: // (cap)
+ case EVENT_CAP_ENABLE: // (cap)
+ case EVENT_CAP_DISABLE: // (cap)
+ {
+ postCapNo(&eventBuf,capno);
+ break;
+ }
+
+ default:
+ barf("postCapEvent: unknown event tag %d", tag);
+ }
+
+ RELEASE_LOCK(&eventBufMutex);
+}
+
void postCapsetEvent (EventTypeNum tag,
EventCapsetID capset,
StgWord info)
diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h
index 1858be8ecd..6a3b32dad3 100644
--- a/rts/eventlog/EventLog.h
+++ b/rts/eventlog/EventLog.h
@@ -49,6 +49,12 @@ void postCapMsg(Capability *cap, char *msg, va_list ap);
void postEventStartup(EventCapNo n_caps);
/*
+ * Post an event relating to a capability itself (create/delete/etc)
+ */
+void postCapEvent (EventTypeNum tag,
+ EventCapNo capno);
+
+/*
* Post an event that is associated with a capability set
*/
void postCapsetEvent (EventTypeNum tag,