summaryrefslogtreecommitdiff
path: root/rts/eventlog
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-12-06 15:12:07 +0000
committerSimon Marlow <marlowsd@gmail.com>2011-12-06 16:00:27 +0000
commit92e7d6c92fdd14de424524564376d3522f2a40cc (patch)
tree5715d44012b452f5020ca14331a1fe50d5fd9600 /rts/eventlog
parent8b75acd3ca25165536f18976c8d80cb62ad613e4 (diff)
downloadhaskell-92e7d6c92fdd14de424524564376d3522f2a40cc.tar.gz
Allow the number of capabilities to be increased at runtime (#3729)
At present the number of capabilities can only be *increased*, not decreased. The latter presents a few more challenges!
Diffstat (limited to 'rts/eventlog')
-rw-r--r--rts/eventlog/EventLog.c27
-rw-r--r--rts/eventlog/EventLog.h1
2 files changed, 22 insertions, 6 deletions
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c
index 88fc64010d..af87492876 100644
--- a/rts/eventlog/EventLog.c
+++ b/rts/eventlog/EventLog.c
@@ -254,12 +254,8 @@ initEventLogging(void)
#else
n_caps = 1;
#endif
- capEventBuf = stgMallocBytes(n_caps * sizeof(EventsBuf),"initEventLogging");
+ moreCapEventBufs(0,n_caps);
- for (c = 0; c < n_caps; ++c) {
- // Init buffer for events.
- initEventsBuf(&capEventBuf[c], EVENT_LOG_SIZE, c);
- }
initEventsBuf(&eventBuf, EVENT_LOG_SIZE, (EventCapNo)(-1));
// Write in buffer: the header begin marker.
@@ -417,7 +413,26 @@ endEventLogging(void)
}
}
-void
+void
+moreCapEventBufs (nat from, nat to)
+{
+ nat c;
+
+ if (from > 0) {
+ capEventBuf = stgReallocBytes(capEventBuf, to * sizeof(EventsBuf),
+ "moreCapEventBufs");
+ } else {
+ capEventBuf = stgMallocBytes(to * sizeof(EventsBuf),
+ "moreCapEventBufs");
+ }
+
+ for (c = from; c < to; ++c) {
+ initEventsBuf(&capEventBuf[c], EVENT_LOG_SIZE, c);
+ }
+}
+
+
+void
freeEventLogging(void)
{
StgWord8 c;
diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h
index 667f34867d..1858be8ecd 100644
--- a/rts/eventlog/EventLog.h
+++ b/rts/eventlog/EventLog.h
@@ -26,6 +26,7 @@ void endEventLogging(void);
void freeEventLogging(void);
void abortEventLogging(void); // #4512 - after fork child needs to abort
void flushEventLog(void); // event log inherited from parent
+void moreCapEventBufs (nat from, nat to);
/*
* Post a scheduler event to the capability's event buffer (an event