kernel_stats.cc revision 8229
1754SN/A/*
21762SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan
3754SN/A * All rights reserved.
4754SN/A *
5754SN/A * Redistribution and use in source and binary forms, with or without
6754SN/A * modification, are permitted provided that the following conditions are
7754SN/A * met: redistributions of source code must retain the above copyright
8754SN/A * notice, this list of conditions and the following disclaimer;
9754SN/A * redistributions in binary form must reproduce the above copyright
10754SN/A * notice, this list of conditions and the following disclaimer in the
11754SN/A * documentation and/or other materials provided with the distribution;
12754SN/A * neither the name of the copyright holders nor the names of its
13754SN/A * contributors may be used to endorse or promote products derived from
14754SN/A * this software without specific prior written permission.
15754SN/A *
16754SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17754SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18754SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19754SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20754SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21754SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22754SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23754SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24754SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25754SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26754SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Lisa Hsu
292665Ssaidi@eecs.umich.edu *          Nathan Binkert
30754SN/A */
31754SN/A
32754SN/A#include <string>
33754SN/A
341070SN/A#include "base/trace.hh"
352680Sktlim@umich.edu#include "cpu/thread_context.hh"
368229Snate@binkert.org#include "kern/tru64/tru64_syscalls.hh"
373565Sgblack@eecs.umich.edu#include "kern/kernel_stats.hh"
382235SN/A#include "sim/system.hh"
39754SN/A
40754SN/Ausing namespace std;
41754SN/Ausing namespace Stats;
42754SN/A
431070SN/Anamespace Kernel {
441070SN/A
452190SN/AStatistics::Statistics(System *system)
463548SN/A    : iplLast(0), iplLastTick(0)
47754SN/A{
481070SN/A}
49754SN/A
50754SN/Avoid
511070SN/AStatistics::regStats(const string &_name)
52754SN/A{
531070SN/A    myname = _name;
54754SN/A
55754SN/A    _arm
561070SN/A        .name(name() + ".inst.arm")
57754SN/A        .desc("number of arm instructions executed")
58754SN/A        ;
59754SN/A
60754SN/A    _quiesce
611070SN/A        .name(name() + ".inst.quiesce")
62754SN/A        .desc("number of quiesce instructions executed")
63754SN/A        ;
64754SN/A
65754SN/A    _iplCount
66754SN/A        .init(32)
671070SN/A        .name(name() + ".ipl_count")
68754SN/A        .desc("number of times we switched to this ipl")
69754SN/A        .flags(total | pdf | nozero | nonan)
70754SN/A        ;
71754SN/A
72754SN/A    _iplGood
73754SN/A        .init(32)
741070SN/A        .name(name() + ".ipl_good")
75754SN/A        .desc("number of times we switched to this ipl from a different ipl")
76754SN/A        .flags(total | pdf | nozero | nonan)
77754SN/A        ;
78754SN/A
79754SN/A    _iplTicks
80754SN/A        .init(32)
811070SN/A        .name(name() + ".ipl_ticks")
82754SN/A        .desc("number of cycles we spent at this ipl")
83754SN/A        .flags(total | pdf | nozero | nonan)
84754SN/A        ;
85754SN/A
86754SN/A    _iplUsed
871070SN/A        .name(name() + ".ipl_used")
88754SN/A        .desc("fraction of swpipl calls that actually changed the ipl")
89754SN/A        .flags(total | nozero | nonan)
90754SN/A        ;
91754SN/A
92754SN/A    _iplUsed = _iplGood / _iplCount;
93754SN/A
94754SN/A    _syscall
95754SN/A        .init(SystemCalls<Tru64>::Number)
961070SN/A        .name(name() + ".syscall")
97754SN/A        .desc("number of syscalls executed")
98754SN/A        .flags(total | pdf | nozero | nonan)
99754SN/A        ;
100754SN/A
1013563SN/A    //@todo This needs to get the names of syscalls from an appropriate place.
1023563SN/A#if 0
103754SN/A    for (int i = 0; i < SystemCalls<Tru64>::Number; ++i) {
1043563SN/A        const char *str = SystemCalls<Tru64>::name(i);
105754SN/A        if (str) {
106754SN/A            _syscall.subname(i, str);
107754SN/A        }
108754SN/A    }
1093563SN/A#endif
1101070SN/A}
111754SN/A
112754SN/Avoid
1131070SN/AStatistics::swpipl(int ipl)
114754SN/A{
115754SN/A    assert(ipl >= 0 && ipl <= 0x1f && "invalid IPL\n");
116754SN/A
117754SN/A    _iplCount[ipl]++;
118754SN/A
119754SN/A    if (ipl == iplLast)
120754SN/A        return;
121754SN/A
122754SN/A    _iplGood[ipl]++;
1237823Ssteve.reinhardt@amd.com    _iplTicks[iplLast] += curTick() - iplLastTick;
1247823Ssteve.reinhardt@amd.com    iplLastTick = curTick();
125754SN/A    iplLast = ipl;
126754SN/A}
127754SN/A
128754SN/Avoid
1291070SN/AStatistics::serialize(ostream &os)
1301070SN/A{
1311097SN/A    SERIALIZE_SCALAR(iplLast);
1321097SN/A    SERIALIZE_SCALAR(iplLastTick);
1331070SN/A}
134754SN/A
1351070SN/Avoid
1361070SN/AStatistics::unserialize(Checkpoint *cp, const string &section)
1371070SN/A{
1381097SN/A    UNSERIALIZE_SCALAR(iplLast);
1391097SN/A    UNSERIALIZE_SCALAR(iplLastTick);
1401070SN/A}
141754SN/A
1427811Ssteve.reinhardt@amd.com} // namespace Kernel
143