kernel_stats.cc (3546:c4074658f1e1) | kernel_stats.cc (3565:6ad587fb7dfd) |
---|---|
1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 15 unchanged lines hidden (view full) --- 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Lisa Hsu 29 * Nathan Binkert 30 */ 31 | 1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 15 unchanged lines hidden (view full) --- 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Lisa Hsu 29 * Nathan Binkert 30 */ 31 |
32#include <map> 33#include <stack> | |
34#include <string> 35 | 32#include <string> 33 |
36#include "arch/alpha/osfpal.hh" | |
37#include "base/trace.hh" 38#include "cpu/thread_context.hh" 39#include "kern/kernel_stats.hh" 40#include "kern/tru64/tru64_syscalls.hh" 41#include "sim/system.hh" 42 43using namespace std; 44using namespace Stats; 45 46namespace Kernel { 47 | 34#include "base/trace.hh" 35#include "cpu/thread_context.hh" 36#include "kern/kernel_stats.hh" 37#include "kern/tru64/tru64_syscalls.hh" 38#include "sim/system.hh" 39 40using namespace std; 41using namespace Stats; 42 43namespace Kernel { 44 |
48const char *modestr[] = { "kernel", "user", "idle" }; 49 | |
50Statistics::Statistics(System *system) | 45Statistics::Statistics(System *system) |
51 : idleProcess((Addr)-1), themode(kernel), lastModeTick(0), 52 iplLast(0), iplLastTick(0) | 46 : iplLast(0), iplLastTick(0) |
53{ 54} 55 56void 57Statistics::regStats(const string &_name) 58{ 59 myname = _name; 60 61 _arm 62 .name(name() + ".inst.arm") 63 .desc("number of arm instructions executed") 64 ; 65 66 _quiesce 67 .name(name() + ".inst.quiesce") 68 .desc("number of quiesce instructions executed") 69 ; 70 | 47{ 48} 49 50void 51Statistics::regStats(const string &_name) 52{ 53 myname = _name; 54 55 _arm 56 .name(name() + ".inst.arm") 57 .desc("number of arm instructions executed") 58 ; 59 60 _quiesce 61 .name(name() + ".inst.quiesce") 62 .desc("number of quiesce instructions executed") 63 ; 64 |
71 _hwrei 72 .name(name() + ".inst.hwrei") 73 .desc("number of hwrei instructions executed") 74 ; 75 | |
76 _iplCount 77 .init(32) 78 .name(name() + ".ipl_count") 79 .desc("number of times we switched to this ipl") 80 .flags(total | pdf | nozero | nonan) 81 ; 82 83 _iplGood --- 13 unchanged lines hidden (view full) --- 97 _iplUsed 98 .name(name() + ".ipl_used") 99 .desc("fraction of swpipl calls that actually changed the ipl") 100 .flags(total | nozero | nonan) 101 ; 102 103 _iplUsed = _iplGood / _iplCount; 104 | 65 _iplCount 66 .init(32) 67 .name(name() + ".ipl_count") 68 .desc("number of times we switched to this ipl") 69 .flags(total | pdf | nozero | nonan) 70 ; 71 72 _iplGood --- 13 unchanged lines hidden (view full) --- 86 _iplUsed 87 .name(name() + ".ipl_used") 88 .desc("fraction of swpipl calls that actually changed the ipl") 89 .flags(total | nozero | nonan) 90 ; 91 92 _iplUsed = _iplGood / _iplCount; 93 |
105 _callpal 106 .init(256) 107 .name(name() + ".callpal") 108 .desc("number of callpals executed") 109 .flags(total | pdf | nozero | nonan) 110 ; 111 112 for (int i = 0; i < PAL::NumCodes; ++i) { 113 const char *str = PAL::name(i); 114 if (str) 115 _callpal.subname(i, str); 116 } 117 | |
118 _syscall 119 .init(SystemCalls<Tru64>::Number) 120 .name(name() + ".syscall") 121 .desc("number of syscalls executed") 122 .flags(total | pdf | nozero | nonan) 123 ; 124 | 94 _syscall 95 .init(SystemCalls<Tru64>::Number) 96 .name(name() + ".syscall") 97 .desc("number of syscalls executed") 98 .flags(total | pdf | nozero | nonan) 99 ; 100 |
101 //@todo This needs to get the names of syscalls from an appropriate place. 102#if 0 |
|
125 for (int i = 0; i < SystemCalls<Tru64>::Number; ++i) { 126 const char *str = SystemCalls<Tru64>::name(i); 127 if (str) { 128 _syscall.subname(i, str); 129 } 130 } | 103 for (int i = 0; i < SystemCalls<Tru64>::Number; ++i) { 104 const char *str = SystemCalls<Tru64>::name(i); 105 if (str) { 106 _syscall.subname(i, str); 107 } 108 } |
131 132 _mode 133 .init(cpu_mode_num) 134 .name(name() + ".mode_switch") 135 .desc("number of protection mode switches") 136 ; 137 138 for (int i = 0; i < cpu_mode_num; ++i) 139 _mode.subname(i, modestr[i]); 140 141 _modeGood 142 .init(cpu_mode_num) 143 .name(name() + ".mode_good") 144 ; 145 146 for (int i = 0; i < cpu_mode_num; ++i) 147 _modeGood.subname(i, modestr[i]); 148 149 _modeFraction 150 .name(name() + ".mode_switch_good") 151 .desc("fraction of useful protection mode switches") 152 .flags(total) 153 ; 154 155 for (int i = 0; i < cpu_mode_num; ++i) 156 _modeFraction.subname(i, modestr[i]); 157 158 _modeFraction = _modeGood / _mode; 159 160 _modeTicks 161 .init(cpu_mode_num) 162 .name(name() + ".mode_ticks") 163 .desc("number of ticks spent at the given mode") 164 .flags(pdf) 165 ; 166 for (int i = 0; i < cpu_mode_num; ++i) 167 _modeTicks.subname(i, modestr[i]); 168 169 _swap_context 170 .name(name() + ".swap_context") 171 .desc("number of times the context was actually changed") 172 ; | 109#endif |
173} 174 175void | 110} 111 112void |
176Statistics::setIdleProcess(Addr idlepcbb, ThreadContext *tc) 177{ 178 assert(themode == kernel); 179 idleProcess = idlepcbb; 180 themode = idle; 181 changeMode(themode, tc); 182} 183 184void 185Statistics::changeMode(cpu_mode newmode, ThreadContext *tc) 186{ 187 _mode[newmode]++; 188 189 if (newmode == themode) 190 return; 191 192 DPRINTF(Context, "old mode=%-8s new mode=%-8s\n", 193 modestr[themode], modestr[newmode]); 194 195 _modeGood[newmode]++; 196 _modeTicks[themode] += curTick - lastModeTick; 197 198 lastModeTick = curTick; 199 themode = newmode; 200} 201 202void | |
203Statistics::swpipl(int ipl) 204{ 205 assert(ipl >= 0 && ipl <= 0x1f && "invalid IPL\n"); 206 207 _iplCount[ipl]++; 208 209 if (ipl == iplLast) 210 return; 211 212 _iplGood[ipl]++; 213 _iplTicks[iplLast] += curTick - iplLastTick; 214 iplLastTick = curTick; 215 iplLast = ipl; 216} 217 218void | 113Statistics::swpipl(int ipl) 114{ 115 assert(ipl >= 0 && ipl <= 0x1f && "invalid IPL\n"); 116 117 _iplCount[ipl]++; 118 119 if (ipl == iplLast) 120 return; 121 122 _iplGood[ipl]++; 123 _iplTicks[iplLast] += curTick - iplLastTick; 124 iplLastTick = curTick; 125 iplLast = ipl; 126} 127 128void |
219Statistics::mode(cpu_mode newmode, ThreadContext *tc) 220{ 221 Addr pcbb = tc->readMiscReg(AlphaISA::IPR_PALtemp23); 222 223 if (newmode == kernel && pcbb == idleProcess) 224 newmode = idle; 225 226 changeMode(newmode, tc); 227} 228 229void 230Statistics::context(Addr oldpcbb, Addr newpcbb, ThreadContext *tc) 231{ 232 assert(themode != user); 233 234 _swap_context++; 235 changeMode(newpcbb == idleProcess ? idle : kernel, tc); 236} 237 238void 239Statistics::callpal(int code, ThreadContext *tc) 240{ 241 if (!PAL::name(code)) 242 return; 243 244 _callpal[code]++; 245 246 switch (code) { 247 case PAL::callsys: { 248 int number = tc->readIntReg(0); 249 if (SystemCalls<Tru64>::validSyscallNumber(number)) { 250 int cvtnum = SystemCalls<Tru64>::convert(number); 251 _syscall[cvtnum]++; 252 } 253 } break; 254 } 255} 256 257void | |
258Statistics::serialize(ostream &os) 259{ | 129Statistics::serialize(ostream &os) 130{ |
260 int exemode = themode; 261 SERIALIZE_SCALAR(exemode); 262 SERIALIZE_SCALAR(idleProcess); | |
263 SERIALIZE_SCALAR(iplLast); 264 SERIALIZE_SCALAR(iplLastTick); | 131 SERIALIZE_SCALAR(iplLast); 132 SERIALIZE_SCALAR(iplLastTick); |
265 SERIALIZE_SCALAR(lastModeTick); | |
266} 267 268void 269Statistics::unserialize(Checkpoint *cp, const string §ion) 270{ | 133} 134 135void 136Statistics::unserialize(Checkpoint *cp, const string §ion) 137{ |
271 int exemode; 272 UNSERIALIZE_SCALAR(exemode); 273 UNSERIALIZE_SCALAR(idleProcess); | |
274 UNSERIALIZE_SCALAR(iplLast); 275 UNSERIALIZE_SCALAR(iplLastTick); | 138 UNSERIALIZE_SCALAR(iplLast); 139 UNSERIALIZE_SCALAR(iplLastTick); |
276 UNSERIALIZE_SCALAR(lastModeTick); 277 themode = (cpu_mode)exemode; | |
278} 279 280/* end namespace Kernel */ } | 140} 141 142/* end namespace Kernel */ } |