Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,247
Issues
4,247
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
396
Merge Requests
396
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
96b986b6
Commit
96b986b6
authored
Aug 31, 2015
by
Ben Gamari
🐢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EventLog: Factor out ensureRoomFor*Event
parent
c60c462f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
83 deletions
+41
-83
rts/eventlog/EventLog.c
rts/eventlog/EventLog.c
+41
-83
No files found.
rts/eventlog/EventLog.c
View file @
96b986b6
...
...
@@ -133,6 +133,9 @@ static void closeBlockMarker(EventsBuf *ebuf);
static
StgBool
hasRoomForEvent
(
EventsBuf
*
eb
,
EventTypeNum
eNum
);
static
StgBool
hasRoomForVariableEvent
(
EventsBuf
*
eb
,
nat
payload_bytes
);
static
void
ensureRoomForEvent
(
EventsBuf
*
eb
,
EventTypeNum
tag
);
static
int
ensureRoomForVariableEvent
(
EventsBuf
*
eb
,
StgWord16
size
);
static
inline
void
postWord8
(
EventsBuf
*
eb
,
StgWord8
i
)
{
*
(
eb
->
pos
++
)
=
i
;
...
...
@@ -546,6 +549,7 @@ abortEventLogging(void)
fclose
(
event_log_file
);
}
}
/*
* Post an event message to the capability's eventlog buffer.
* If the buffer is full, prints out the buffer and clears it.
...
...
@@ -560,11 +564,7 @@ postSchedEvent (Capability *cap,
EventsBuf
*
eb
;
eb
=
&
capEventBuf
[
cap
->
no
];
if
(
!
hasRoomForEvent
(
eb
,
tag
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
eb
);
}
ensureRoomForEvent
(
eb
,
tag
);
postEventHeader
(
eb
,
tag
);
...
...
@@ -612,11 +612,7 @@ postSparkEvent (Capability *cap,
EventsBuf
*
eb
;
eb
=
&
capEventBuf
[
cap
->
no
];
if
(
!
hasRoomForEvent
(
eb
,
tag
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
eb
);
}
ensureRoomForEvent
(
eb
,
tag
);
postEventHeader
(
eb
,
tag
);
...
...
@@ -656,11 +652,7 @@ postSparkCountersEvent (Capability *cap,
EventsBuf
*
eb
;
eb
=
&
capEventBuf
[
cap
->
no
];
if
(
!
hasRoomForEvent
(
eb
,
EVENT_SPARK_COUNTERS
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
eb
);
}
ensureRoomForEvent
(
eb
,
EVENT_SPARK_COUNTERS
);
postEventHeader
(
eb
,
EVENT_SPARK_COUNTERS
);
/* EVENT_SPARK_COUNTERS (crt,dud,ovf,cnv,gcd,fiz,rem) */
...
...
@@ -678,11 +670,7 @@ postCapEvent (EventTypeNum tag,
EventCapNo
capno
)
{
ACQUIRE_LOCK
(
&
eventBufMutex
);
if
(
!
hasRoomForEvent
(
&
eventBuf
,
tag
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
&
eventBuf
);
}
ensureRoomForEvent
(
&
eventBuf
,
tag
);
postEventHeader
(
&
eventBuf
,
tag
);
...
...
@@ -708,11 +696,7 @@ void postCapsetEvent (EventTypeNum tag,
StgWord
info
)
{
ACQUIRE_LOCK
(
&
eventBufMutex
);
if
(
!
hasRoomForEvent
(
&
eventBuf
,
tag
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
&
eventBuf
);
}
ensureRoomForEvent
(
&
eventBuf
,
tag
);
postEventHeader
(
&
eventBuf
,
tag
);
postCapsetID
(
&
eventBuf
,
capset
);
...
...
@@ -838,11 +822,7 @@ void postWallClockTime (EventCapsetID capset)
getUnixEpochTime
(
&
sec
,
&
nsec
);
/* Get the wall clock time */
ts
=
time_ns
();
/* Get the eventlog timestamp */
if
(
!
hasRoomForEvent
(
&
eventBuf
,
EVENT_WALL_CLOCK_TIME
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
&
eventBuf
);
}
ensureRoomForEvent
(
&
eventBuf
,
EVENT_WALL_CLOCK_TIME
);
/* Normally we'd call postEventHeader(), but that generates its own
timestamp, so we go one level lower so we can write out the
...
...
@@ -869,11 +849,7 @@ void postHeapEvent (Capability *cap,
EventsBuf
*
eb
;
eb
=
&
capEventBuf
[
cap
->
no
];
if
(
!
hasRoomForEvent
(
eb
,
tag
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
eb
);
}
ensureRoomForEvent
(
eb
,
tag
);
postEventHeader
(
eb
,
tag
);
...
...
@@ -900,11 +876,7 @@ void postEventHeapInfo (EventCapsetID heap_capset,
W_
blockSize
)
{
ACQUIRE_LOCK
(
&
eventBufMutex
);
if
(
!
hasRoomForEvent
(
&
eventBuf
,
EVENT_HEAP_INFO_GHC
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
&
eventBuf
);
}
ensureRoomForEvent
(
&
eventBuf
,
EVENT_HEAP_INFO_GHC
);
postEventHeader
(
&
eventBuf
,
EVENT_HEAP_INFO_GHC
);
/* EVENT_HEAP_INFO_GHC (heap_capset, n_generations,
...
...
@@ -933,11 +905,7 @@ void postEventGcStats (Capability *cap,
EventsBuf
*
eb
;
eb
=
&
capEventBuf
[
cap
->
no
];
if
(
!
hasRoomForEvent
(
eb
,
EVENT_GC_STATS_GHC
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
eb
);
}
ensureRoomForEvent
(
eb
,
EVENT_GC_STATS_GHC
);
postEventHeader
(
eb
,
EVENT_GC_STATS_GHC
);
/* EVENT_GC_STATS_GHC (heap_capset, generation,
...
...
@@ -958,11 +926,7 @@ void postTaskCreateEvent (EventTaskId taskId,
EventKernelThreadId
tid
)
{
ACQUIRE_LOCK
(
&
eventBufMutex
);
if
(
!
hasRoomForEvent
(
&
eventBuf
,
EVENT_TASK_CREATE
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
&
eventBuf
);
}
ensureRoomForEvent
(
&
eventBuf
,
EVENT_TASK_CREATE
);
postEventHeader
(
&
eventBuf
,
EVENT_TASK_CREATE
);
/* EVENT_TASK_CREATE (taskID, cap, tid) */
...
...
@@ -978,11 +942,7 @@ void postTaskMigrateEvent (EventTaskId taskId,
EventCapNo
new_capno
)
{
ACQUIRE_LOCK
(
&
eventBufMutex
);
if
(
!
hasRoomForEvent
(
&
eventBuf
,
EVENT_TASK_MIGRATE
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
&
eventBuf
);
}
ensureRoomForEvent
(
&
eventBuf
,
EVENT_TASK_MIGRATE
);
postEventHeader
(
&
eventBuf
,
EVENT_TASK_MIGRATE
);
/* EVENT_TASK_MIGRATE (taskID, cap, new_cap) */
...
...
@@ -996,11 +956,7 @@ void postTaskMigrateEvent (EventTaskId taskId,
void
postTaskDeleteEvent
(
EventTaskId
taskId
)
{
ACQUIRE_LOCK
(
&
eventBufMutex
);
if
(
!
hasRoomForEvent
(
&
eventBuf
,
EVENT_TASK_DELETE
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
&
eventBuf
);
}
ensureRoomForEvent
(
&
eventBuf
,
EVENT_TASK_DELETE
);
postEventHeader
(
&
eventBuf
,
EVENT_TASK_DELETE
);
/* EVENT_TASK_DELETE (taskID) */
...
...
@@ -1015,12 +971,7 @@ postEvent (Capability *cap, EventTypeNum tag)
EventsBuf
*
eb
;
eb
=
&
capEventBuf
[
cap
->
no
];
if
(
!
hasRoomForEvent
(
eb
,
tag
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
eb
);
}
ensureRoomForEvent
(
eb
,
tag
);
postEventHeader
(
eb
,
tag
);
}
...
...
@@ -1030,11 +981,7 @@ postEventAtTimestamp (Capability *cap, EventTimestamp ts, EventTypeNum tag)
EventsBuf
*
eb
;
eb
=
&
capEventBuf
[
cap
->
no
];
if
(
!
hasRoomForEvent
(
eb
,
tag
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
eb
);
}
ensureRoomForEvent
(
eb
,
tag
);
/* Normally we'd call postEventHeader(), but that generates its own
timestamp, so we go one level lower so we can write out
...
...
@@ -1056,10 +1003,7 @@ void postLogMsg(EventsBuf *eb, EventTypeNum type, char *msg, va_list ap)
size
=
BUF
;
}
if
(
!
hasRoomForVariableEvent
(
eb
,
size
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
eb
);
}
ensureRoomForVariableEvent
(
eb
,
size
);
postEventHeader
(
eb
,
type
);
postPayloadSize
(
eb
,
size
);
...
...
@@ -1081,11 +1025,7 @@ void postCapMsg(Capability *cap, char *msg, va_list 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
);
}
ensureRoomForEvent
(
&
eventBuf
,
EVENT_STARTUP
);
// Post a STARTUP event with the number of capabilities
postEventHeader
(
&
eventBuf
,
EVENT_STARTUP
);
...
...
@@ -1161,9 +1101,7 @@ void closeBlockMarker (EventsBuf *ebuf)
void
postBlockMarker
(
EventsBuf
*
eb
)
{
if
(
!
hasRoomForEvent
(
eb
,
EVENT_BLOCK_MARKER
))
{
printAndClearEventBuf
(
eb
);
}
ensureRoomForEvent
(
eb
,
EVENT_BLOCK_MARKER
);
closeBlockMarker
(
eb
);
...
...
@@ -1240,6 +1178,26 @@ StgBool hasRoomForVariableEvent(EventsBuf *eb, nat payload_bytes)
}
}
void
ensureRoomForEvent
(
EventsBuf
*
eb
,
EventTypeNum
tag
)
{
if
(
!
hasRoomForEvent
(
eb
,
tag
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
eb
);
}
}
int
ensureRoomForVariableEvent
(
EventsBuf
*
eb
,
StgWord16
size
)
{
if
(
!
hasRoomForVariableEvent
(
eb
,
size
))
{
// Flush event buffer to make room for new event.
printAndClearEventBuf
(
eb
);
if
(
!
hasRoomForVariableEvent
(
eb
,
size
))
return
1
;
// Not enough space
}
return
0
;
}
void
postEventType
(
EventsBuf
*
eb
,
EventType
*
et
)
{
StgWord8
d
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment