Commit c4f9b989 authored by Duncan Coutts's avatar Duncan Coutts

Make the tracing of the startup event more regular

Rather than doing it differently for the eventlog and Dtrace cases.
parent 68b76e0e
......@@ -144,9 +144,9 @@ hs_init(int *argc, char **argv[])
#ifdef TRACING
initTracing();
#endif
/* Dtrace events are always enabled
/* Trace the startup event
*/
dtraceEventStartup();
traceEventStartup();
/* initialise scheduler data structures (needs to be done before
* initStorage()).
......
......@@ -359,6 +359,12 @@ void traceThreadStatus_ (StgTSO *tso USED_IF_DEBUG)
}
}
void traceEventStartup_(int nocaps)
{
if (eventlog_enabled) {
postEventStartup(nocaps);
}
}
#ifdef DEBUG
void traceBegin (const char *str, ...)
......
......@@ -160,6 +160,8 @@ void traceUserMsg(Capability *cap, char *msg);
void traceThreadStatus_ (StgTSO *tso);
void traceEventStartup_ (int n_caps);
#else /* !TRACING */
#define traceSchedEvent(cap, tag, tso, other) /* nothing */
......@@ -170,6 +172,7 @@ void traceThreadStatus_ (StgTSO *tso);
#define debugTrace(class, str, ...) /* nothing */
#define debugTraceCap(class, cap, str, ...) /* nothing */
#define traceThreadStatus(class, tso) /* nothing */
#define traceEventStartup_(n_caps) /* nothing */
#endif /* TRACING */
......@@ -374,17 +377,18 @@ INLINE_HEADER void traceEventCreateSparkThread(Capability *cap STG_UNUSED,
dtraceCreateSparkThread((EventCapNo)cap->no, (EventThreadID)spark_tid);
}
// This applies only to dtrace as EVENT_STARTUP in the logging framework is
// handled specially in 'EventLog.c'.
//
INLINE_HEADER void dtraceEventStartup(void)
INLINE_HEADER void traceEventStartup(void)
{
int n_caps;
#ifdef THREADED_RTS
// XXX n_capabilities hasn't been initislised yet
dtraceStartup(RtsFlags.ParFlags.nNodes);
n_caps = RtsFlags.ParFlags.nNodes;
#else
dtraceStartup(1);
n_caps = 1;
#endif
traceEventStartup_(n_caps);
dtraceStartup(n_caps);
}
INLINE_HEADER void traceEventGcIdle(Capability *cap STG_UNUSED)
......
......@@ -296,10 +296,6 @@ initEventLogging(void)
// Prepare event buffer for events (data).
postInt32(&eventBuf, EVENT_DATA_BEGIN);
// Post a STARTUP event with the number of capabilities
postEventHeader(&eventBuf, EVENT_STARTUP);
postCapNo(&eventBuf, n_caps);
// Flush capEventBuf with header.
/*
......@@ -498,6 +494,22 @@ void postUserMsg(Capability *cap, char *msg, va_list ap)
postLogMsg(&capEventBuf[cap->no], EVENT_USER_MSG, msg, ap);
}
void postEventStartup(EventCapNo n_caps)
{
ACQUIRE_LOCK(&eventBufMutex);
if (!hasRoomForEvent(&eventBuf, EVENT_STARTUP)) {
// Flush event buffer to make room for new event.
printAndClearEventBuf(&eventBuf);
}
// Post a STARTUP event with the number of capabilities
postEventHeader(&eventBuf, EVENT_STARTUP);
postCapNo(&eventBuf, n_caps);
RELEASE_LOCK(&eventBufMutex);
}
void closeBlockMarker (EventsBuf *ebuf)
{
StgInt8* save_pos;
......
......@@ -45,6 +45,8 @@ void postUserMsg(Capability *cap, char *msg, va_list ap);
void postCapMsg(Capability *cap, char *msg, va_list ap);
void postEventStartup(EventCapNo n_caps);
#else /* !TRACING */
INLINE_HEADER void postSchedEvent (Capability *cap STG_UNUSED,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment