kernel_stats.cc (7811:a8fc35183c10) kernel_stats.cc (7823:dac01f14f20f)
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;
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.
15 *
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.
27 *
28 * Authors: Lisa Hsu
29 * Nathan Binkert
30 */
31
32#include <string>
33
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
45Statistics::Statistics(System *system)
46 : iplLast(0), iplLastTick(0)
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
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
73 .init(32)
74 .name(name() + ".ipl_good")
75 .desc("number of times we switched to this ipl from a different ipl")
76 .flags(total | pdf | nozero | nonan)
77 ;
78
79 _iplTicks
80 .init(32)
81 .name(name() + ".ipl_ticks")
82 .desc("number of cycles we spent at this ipl")
83 .flags(total | pdf | nozero | nonan)
84 ;
85
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
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
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 }
109#endif
110}
111
112void
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]++;
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;
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.
15 *
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.
27 *
28 * Authors: Lisa Hsu
29 * Nathan Binkert
30 */
31
32#include <string>
33
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
45Statistics::Statistics(System *system)
46 : iplLast(0), iplLastTick(0)
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
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
73 .init(32)
74 .name(name() + ".ipl_good")
75 .desc("number of times we switched to this ipl from a different ipl")
76 .flags(total | pdf | nozero | nonan)
77 ;
78
79 _iplTicks
80 .init(32)
81 .name(name() + ".ipl_ticks")
82 .desc("number of cycles we spent at this ipl")
83 .flags(total | pdf | nozero | nonan)
84 ;
85
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
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
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 }
109#endif
110}
111
112void
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;
123 _iplTicks[iplLast] += curTick() - iplLastTick;
124 iplLastTick = curTick();
125 iplLast = ipl;
126}
127
128void
129Statistics::serialize(ostream &os)
130{
131 SERIALIZE_SCALAR(iplLast);
132 SERIALIZE_SCALAR(iplLastTick);
133}
134
135void
136Statistics::unserialize(Checkpoint *cp, const string &section)
137{
138 UNSERIALIZE_SCALAR(iplLast);
139 UNSERIALIZE_SCALAR(iplLastTick);
140}
141
142} // namespace Kernel
125 iplLast = ipl;
126}
127
128void
129Statistics::serialize(ostream &os)
130{
131 SERIALIZE_SCALAR(iplLast);
132 SERIALIZE_SCALAR(iplLastTick);
133}
134
135void
136Statistics::unserialize(Checkpoint *cp, const string &section)
137{
138 UNSERIALIZE_SCALAR(iplLast);
139 UNSERIALIZE_SCALAR(iplLastTick);
140}
141
142} // namespace Kernel