2 * Copyright (c) 2003 The Regents of The University of Michigan
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;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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.
29 #ifndef __KERNEL_STATS_HH__
30 #define __KERNEL_STATS_HH__
37 #include "base/statistics.hh"
38 #include "sim/serialize.hh"
39 #include "targetarch/isa_traits.hh"
48 enum cpu_mode { kernel, user, idle, interrupt, cpu_mode_num };
49 extern const char *modestr[];
58 // lisa's binning stuff
61 Stats::MainBin *myBin;
68 std::stack<fnCall *> callStack;
71 std::map<const std::string, Stats::MainBin *> fnBins;
72 std::map<const Addr, SWContext *> swCtxMap;
74 std::multimap<const std::string, std::string> callerMap;
75 void populateMap(std::string caller, std::string callee);
77 std::vector<FnEvent *> fnEvents;
79 Stats::Scalar<> fnCalls;
81 Stats::MainBin *getBin(const std::string &name);
82 bool findCaller(std::string, std::string) const;
84 SWContext *findContext(Addr pcb);
85 bool addContext(Addr pcb, SWContext *ctx)
87 return (swCtxMap.insert(std::make_pair(pcb, ctx))).second;
90 void remContext(Addr pcb)
95 void dumpState() const;
98 std::vector<std::string> binned_fns;
101 Stats::MainBin *modeBin[cpu_mode_num];
108 void palSwapContext(ExecContext *xc);
109 void execute(ExecContext *xc, const StaticInstBase *inst);
110 void call(ExecContext *xc, Stats::MainBin *myBin);
111 void changeMode(cpu_mode mode);
114 Binning(System *sys);
117 const std::string name() const { return myname; }
118 void regStats(const std::string &name);
121 virtual void serialize(std::ostream &os);
122 virtual void unserialize(Checkpoint *cp, const std::string §ion);
125 class Statistics : public Serializable
127 friend class Binning;
138 void changeMode(cpu_mode newmode);
141 Stats::Scalar<> _arm;
142 Stats::Scalar<> _quiesce;
143 Stats::Scalar<> _ivlb;
144 Stats::Scalar<> _ivle;
145 Stats::Scalar<> _hwrei;
147 Stats::Vector<> _iplCount;
148 Stats::Vector<> _iplGood;
149 Stats::Vector<> _iplTicks;
150 Stats::Formula _iplUsed;
152 Stats::Vector<> _callpal;
153 Stats::Vector<> _syscall;
154 Stats::Vector<> _faults;
156 Stats::Vector<> _mode;
157 Stats::Vector<> _modeGood;
158 Stats::Formula _modeFraction;
159 Stats::Vector<> _modeTicks;
161 Stats::Scalar<> _swap_context;
168 Statistics(ExecContext *context);
170 const std::string name() const { return myname; }
171 void regStats(const std::string &name);
174 void arm() { _arm++; }
175 void quiesce() { _quiesce++; }
176 void ivlb() { _ivlb++; }
177 void ivle() { _ivle++; }
178 void hwrei() { _hwrei++; }
179 void fault(Fault fault) { _faults[fault]++; }
180 void swpipl(int ipl);
181 void mode(cpu_mode newmode);
182 void context(Addr oldpcbb, Addr newpcbb);
183 void callpal(int code);
185 void setIdleProcess(Addr idle);
188 virtual void serialize(std::ostream &os);
189 virtual void unserialize(Checkpoint *cp, const std::string §ion);
192 /* end namespace Kernel */ }
194 #endif // __KERNEL_STATS_HH__