summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas@sandberg.pp.se>2013-06-11 09:24:40 +0200
committerAndreas Sandberg <andreas@sandberg.pp.se>2013-06-11 09:24:40 +0200
commitdf059f45a0cbd230ad00f6da24cfc5d228430e16 (patch)
tree38af3de7250ce34e7d9ed39eb07cddabb9bbc0c4 /src/cpu
parent0b4a8b40866a1ed44bacbccc788ce3001eab8b20 (diff)
downloadgem5-df059f45a0cbd230ad00f6da24cfc5d228430e16.tar.xz
kvm: Maintain a local instruction counter and update totalNumInsts
Update the system's totalNumInst counter when exiting from KVM and maintain an internal absolute instruction count instead of relying on the one from perf.
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/kvm/base.cc9
-rw-r--r--src/cpu/kvm/base.hh3
2 files changed, 9 insertions, 3 deletions
diff --git a/src/cpu/kvm/base.cc b/src/cpu/kvm/base.cc
index a0aa511ea..6ffad82d7 100644
--- a/src/cpu/kvm/base.cc
+++ b/src/cpu/kvm/base.cc
@@ -80,7 +80,8 @@ BaseKvmCPU::BaseKvmCPU(BaseKvmCPUParams *params)
pageSize(sysconf(_SC_PAGE_SIZE)),
tickEvent(*this),
perfControlledByTimer(params->usePerfOverflow),
- hostFactor(params->hostFactor)
+ hostFactor(params->hostFactor),
+ ctrInsts(0)
{
if (pageSize == -1)
panic("KVM: Failed to determine host page size (%i)\n",
@@ -416,14 +417,14 @@ BaseKvmCPU::getContext(int tn)
Counter
BaseKvmCPU::totalInsts() const
{
- return hwInstructions.read();
+ return ctrInsts;
}
Counter
BaseKvmCPU::totalOps() const
{
hack_once("Pretending totalOps is equivalent to totalInsts()\n");
- return hwInstructions.read();
+ return ctrInsts;
}
void
@@ -522,6 +523,8 @@ BaseKvmCPU::kvmRun(Tick ticks)
numCycles += simCyclesExecuted;;
++numVMExits;
numInsts += instsExecuted;
+ ctrInsts += instsExecuted;
+ system->totalNumInsts += instsExecuted;
DPRINTF(KvmRun, "KVM: Executed %i instructions in %i cycles (%i ticks, sim cycles: %i).\n",
instsExecuted, hostCyclesExecuted, ticksExecuted, simCyclesExecuted);
diff --git a/src/cpu/kvm/base.hh b/src/cpu/kvm/base.hh
index c53f715e3..81b24a378 100644
--- a/src/cpu/kvm/base.hh
+++ b/src/cpu/kvm/base.hh
@@ -561,6 +561,9 @@ class BaseKvmCPU : public BaseCPU
Stats::Scalar numInterrupts;
Stats::Scalar numHypercalls;
/* @} */
+
+ /** Number of instructions executed by the CPU */
+ Counter ctrInsts;
};
#endif