sync_stats.tcl
3.36 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
#
# 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.
#
####
#### sync_stats.tcl
####
##
## module init
##
proc syncStatsDump {} {
global ssLock
log "SYNCSTATS: start\n"
foreach lock [array names ssLock] {
set l [symbol find kernel [lindex $lock 0]]
set r [symbol find kernel [lindex $lock 1]]
if [string match "end+*" $l] {
set l [lindex $lock 0]
}
log "SYNCSTATS: lock $l,$r "
log "[statistics list ssLockWait([lindex $lock 0],[lindex $lock 1])] "
log "[statistics list ssLockHeld([lindex $lock 0],[lindex $lock 1])]\n"
}
log "SYNCSTATS: end\n"
}
annotation set simos exit {
syncStatsDump
}
annotation set simos sigusr {
syncStatsDump
}
##
## helper routines
##
proc syncStatsWait {lock} {
global CPU CYCLES ra ssLockStart ssLock
set lock [hex [expr $lock & 0xfffffffc]]
set ssLockStart($lock,$CPU) $CYCLES
if ![info exists "ssLock($lock $ra)"] {
set "ssLock($lock $ra)" 1
statistics create ssLockWait($lock,$ra)
statistics create ssLockHeld($lock,$ra)
}
}
proc syncStatsFailed {lock} {
global CPU CYCLES ra ssLockStart
set lock [hex [expr $lock & 0xfffffffc]]
if [info exists ssLockStart($lock,$CPU)] {
statistics entry ssLockWait($lock,$ra) [expr $CYCLES-$ssLockStart($lock,$CPU)]
}
}
proc syncStatsAcquire {lock} {
global CPU CYCLES ra ssLockStart ssLockRA
set lock [hex [expr $lock & 0xfffffffc]]
if [info exists ssLockStart($lock,$CPU)] {
statistics entry ssLockWait($lock,$ra) [expr $CYCLES-$ssLockStart($lock,$CPU)]
set ssLockStart($lock,$CPU) $CYCLES
set ssLockRA($lock,$CPU) $ra
}
}
proc syncStatsRealease {lock} {
global CPU CYCLES ssLockStart ssLockRA
set lock [hex [expr $lock & 0xfffffffc]]
if [info exists ssLockRA($lock,$CPU)] {
set ra $ssLockRA($lock,$CPU)
statistics entry ssLockHeld($lock,$ra) [expr $CYCLES-$ssLockStart($lock,$CPU)]
}
}
##
## the annotations
##
annotation set pre-pc kernel::io_splock:START {
syncStatsWait $a0
}
if [catch {symbol read kernel::io_splock:ann_splock_gotit}] {
annotation set pc kernel::io_splock:END {
syncStatsAcquire $a0
}
} else {
annotation set pc kernel::io_splock:ann_splock_gotit {
syncStatsAcquire $a0
}
}
annotation set pre-pc kernel::spsemahi:START {
syncStatsWait $a0
}
annotation set pc kernel::spsemahi:ann_spsemahi_gotit {
syncStatsAcquire $a0
}
annotation set pc kernel::io_splockspl:START {
syncStatsWait $a0
}
annotation set pre-pc kernel::io_splockspl:ann_splockspl_gotit {
syncStatsAcquire $s0
}
annotation set pc kernel::spsema:START {
syncStatsWait $a0
}
annotation set pc kernel::spsema:END {
syncStatsAcquire $a0
}
annotation set pc kernel::_trylock:START {
console "Bogus _trylock\n"
syncStatsWait $a0
}
annotation set pc kernel::_trylock:ann_trylock_gotit {
if {$v0 == 0} {
syncStatsFailed $a0
} else {
syncStatsAcquire $a0
}
}
annotation set pre-pc kernel::io_spunlockspl:START {
syncStatsRealease $a0
}
annotation set pre-pc kernel::svsema:START {
syncStatsRealease $a0
}
annotation set pre-pc kernel::svsemax:START {
syncStatsRealease $a0
}