Skip to content

Commit d9703f3

Browse files
committed
dtrace: Add option to periodically print per vCPU EPT faults
Signed-off-by: Rolf Neugebauer <[email protected]>
1 parent acd2186 commit d9703f3

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

dtrace/eptfault.d

+32
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
*
55
* USAGE: sudo eptfault.d -p <pid of hyperkit>
66
* sudo eptfault.d -D TOTAL -p <pid of hyperkit>
7+
* sudo eptfault.d -D INTERVAL=1 -p <pid of hyperkit>
8+
*
9+
* If '-D INTERVAL=<seconds>' is specified periodically print a
10+
* summary of EPT Faults per vCPU.
711
*
812
* It seems that tracing starts before the end of dtrace:::BEGIN, i.e.
913
* before the 'lapic_map' array is fully initialised. This results in
@@ -91,6 +95,12 @@ dtrace:::BEGIN
9195
lapic_map[0x3F0] = "SELF_IPI";
9296

9397
printf("Tracing... Hit Ctrl-C to end.\n");
98+
99+
#ifdef INTERVAL
100+
secs = INTERVAL;
101+
printf("\n\n");
102+
printf("Per CPU VM Exits\n");
103+
#endif
94104
}
95105

96106
hyperkit$target:::vmx-ept-fault
@@ -108,9 +118,31 @@ hyperkit$target:::vmx-ept-fault
108118

109119
hyperkit$target:::vmx-ept-fault
110120
{
121+
#ifdef INTERVAL
122+
/* Per vCPU count for periodic reporting */
123+
@total[arg0] = count();
124+
#endif
125+
111126
@all_faults[arg1, arg0] = count();
112127
}
113128

129+
#ifdef INTERVAL
130+
/* timer */
131+
profile:::tick-1sec
132+
{
133+
secs--;
134+
}
135+
136+
/* Periodically print per vCPU VM Exits */
137+
profile:::tick-1sec
138+
/secs == 0/
139+
{
140+
printa(@total);
141+
clear(@total);
142+
secs = INTERVAL;
143+
}
144+
#endif
145+
114146
dtrace:::END
115147
{
116148
#ifdef TOTAL

0 commit comments

Comments
 (0)