kernel_stats-irix6.x.tcl
7.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#
# Copyright (C) 1996-1998 by the Board of Trustees
# of Leland Stanford Junior University.
#
# This file is part of the SimOS distribution.
# See LICENSE file for terms of the license.
#
##
## kernel_stats.tcl
##
## Breakdown of operating system activity by kernel thread.
##
timing create kstats
log [timing fields]
###
### thread tracking
###
proc kstatsSwitch args {
global PROCESS PID KTID CPU M R PARAM
# Concat process name and kernel thread id
set args [linsert $args 0 $PROCESS($CPU)-$PID($CPU)]
if { $PARAM(MACHINE.Count) == 1 } {
eval timing switch kstats $PID($CPU) $args
} else {
eval timing switch kstats $M($CPU)_$PID($CPU) machine$M($CPU) $args
}
if ![info exists kstatsThreadState([ktname])] {
set kstatsThreadState([ktname]) "runq"
} else {
timing end kstats $kstatsThreadState([ktname])
}
}
annotation set simos enter {
if {$PROCESS($CPU) == "idle"} {
kstatsSwitch kernel idle
} elseif {$PROCESS($CPU) == "boot"} {
kstatsSwitch kernel
} else {
set kstatsThreadState([ktname]) "startup"
kstatsSwitch
}
}
if { $PARAM(MACHINE.Count) == 1 } {
proc ktname {} {
global PID KTID CPU
return $KTID($CPU)
}
} else {
proc ktname {} {
global M KTID CPU
return $M($CPU)_$KTID($CPU)
}
}
proc kstatsState {id} {
if [info exists kstatsThreadState($id)] {
return $kstatsThreadState($id)
} else {
# return fork
return foo
}
}
annotation set osEvent procexit {
# timing terminate kstats [ktname]
# unset kstatsThreadState([ktname])
}
##### WATCH OUT FOR EXEC NOT HAVING A PID
annotation set osEvent switchIn {
if {$PROCESS($CPU) == "idle"} {
kstatsSwitch idleproc
} elseif {$PROCESS($CPU) == "runq"} {
kstatsSwitch runqproc
} else {
kstatsSwitch [kstatsState [ktname]]
}
}
annotation set osEvent procexit {
console "PROCEXIT on $CPU - $PID($CPU)\n"
if { $PARAM(MACHINE.Count) == 1 } {
timing terminate kstats $PID($CPU)
} else {
timing terminate kstats $M($CPU)_$PID($CPU)
}
}
###
### kernel services
###
annotation set utlb {
timing start kstats utlb
}
annotation set exc {
if {[timing current kstats] == "utlb"} {
timing end kstats utlb
}
set exc [expr ($cause >> 2) & 0x1F]
if {$exc == 0} {
timing start? kstats intrdisp
} elseif {$exc == 8} {
timing start kstats syscall([expr $v0])
} else {
timing start? kstats exc($exc)
}
}
annotation set inst rfe {
set current [timing current kstats]
if {$current != "ROOT"} {
timing end kstats $current
} else {
console "KSTATS: CPU $CPU CYCLE $CYCLES: bad rfe pid $PID($CPU) ktid $KTID($CPU) $current\n"
}
}
annotation set osEvent startIdle {
timing start kstats idle
}
annotation set osEvent endIdle {
timing end kstats idle
}
annotation set osEvent startSync {
timing start kstats sync
}
annotation set osEvent endSync {
timing end kstats sync
}
##
## page faults
##
annotation set pc kernel::pfault:START {
timing vector kstats pfault
}
annotation set pc kernel::page_copy:START {
if {[timing current kstats] == "pfault"} {
timing vector kstats COW_fault
}
}
annotation set pc kernel::vfault:START {
timing vector kstats vfault
}
annotation set pc kernel::page_zero:START {
if {[timing current kstats] == "vfault"} {
timing vector kstats demand_zero
}
}
##
## Interrupts
##
# simscsi_intr, if_etintr, and du_poll all share the interrupt
# dispatch path. There are two ways to charge the overhead to
# routines. 1) We can treat the routines as interrupt handlers in the
# normal way. This leads to simscsi_intr getting charged all the
# dispatch overhead and du_poll getting charged all the return
# overhead. This is what is currently done. 2) We could have a
# level3_intr, do normal start, ends on simscsi_intr, if_etintr, and
# du_poll, and then divide the overhead of level3_intr among the 3 as
# a post processing step. Fortunately the overhead is small enough
# where we do not really care.
#set intr(timein) 1
#set intr(netintr) 2
#set intr(simscsi_intr) 3
#set intr(if_etintr) 3
#set intr(du_poll) 3
#set intr(level4_intr) 4
#set intr(clock) 5
#set intr(cpuintr) 6
#set intr(ackkgclock) 7
#set intr(buserror_intr) 8
#foreach i [array names intr] {
# annotation set pc kernel:SIMMP.c:$i:START "dointr $i"
#}
#proc dointr {name} {
# global intr CPU CYCLES
# set current [timing current kstats]
# if {$current == "intrdisp"} {
# timing vector kstats $name
# } elseif [info exists intr($current)] {
# timing end kstats $current
# timing start kstats $name
# } else {
# console "KSTATS: CPU $CPU CYCLE $CYCLES: bad intr: $name current: $current\n"
# }
#}
################################################################
################################################################
annotation set pc kernel:sema.c:semarmproc:START {
set ktid [symbol read "kernel::(*(kthread_t*)$a1).k_id"]
console "KSTATS: semarmproc $ktid\n"
if {[info exists kstatsThreadState($ktid)] && ($ktid != $KTID($CPU))} {
if {[timing current kstats $ktid] == $kstatsThread($ktid)} {
timing end kstats $kstatsThread($ktid) $ktid
timing start kstats runq $ktid
} else {
log "$CYCLES semarmproc special case: thread $ktid\n"
timing dumpstack kstats $ktid
log "State after desched will be \"runq\" rather than \"$kstatsThreadState($ktid)\"\n"
}
set kstatsThreadState($ktid) "runq"
}
}
annotation set pc kernel:sema.c:semaaddproc:START {
set ktid [symbol read "kernel::(*(kthread_t*)$a1).k_id"]
console "KSTATS: Sema wait $ktid\n"
if {$kstatsThreadState([ktname]) == "runq" } {
set kstatsThreadState([ktname]) "semawait"
}
}
annotation set pc kernel:sema.c:semadq:END {
set ktid [symbol read "kernel::(*(kthread_t*)$v0).k_id"]
console "KSTATS: Sema signal $ktid\n"
if {[info exists kstatsThreadState($ktid)] && ($ktid != $KTID($CPU))} {
if {[timing current kstats $ktid] == $kstatsThreadState($ktid)} {
timing end kstats $kstatsThreadState($ktid) $ktid
timing start kstats runq $ktid
} else {
log "$CYCLES semarmproc special case: thread $ktid\n"
timing dumpstack kstats $ktid
# log "State after desched will be \"runq\" rather than \"$kstatsThreadState($ktid)\"\n"
}
set kstatsThreadState($ktid) "runq"
}
}
###
### Revise the reason why we're going to be descheduled
###
annotation set pc kernel::ql_entry:START {
# console "DISK COMMAND!\n"
set kstatsThreadState([ktname]) diskIO
}
annotation set pc kernel:if_sim.c:ef_transmit:START {
# console "EF TRANSMIT\n"
set kstatsThreadState([ktname]) efSend
}
###
### statistics logging
###
annotation set simos exit {
timing exit kstats
log [timing dump kstats]
}
annotation set simos sigusr {
log [timing dump kstats]
}