false, Event::CPU_Tick_Pri),
activeInstPeriod(0),
perfControlledByTimer(params->usePerfOverflow),
- hostFactor(params->hostFactor),
+ hostFactor(params->hostFactor), stats(this),
ctrInsts(0)
{
if (pageSize == -1)
}
-void
-BaseKvmCPU::regStats()
+BaseKvmCPU::StatGroup::StatGroup(Stats::Group *parent)
+ : Stats::Group(parent),
+ ADD_STAT(committedInsts, "Number of instructions committed"),
+ ADD_STAT(numVMExits, "total number of KVM exits"),
+ ADD_STAT(numVMHalfEntries,
+ "number of KVM entries to finalize pending operations"),
+ ADD_STAT(numExitSignal, "exits due to signal delivery"),
+ ADD_STAT(numMMIO, "number of VM exits due to memory mapped IO"),
+ ADD_STAT(numCoalescedMMIO,
+ "number of coalesced memory mapped IO requests"),
+ ADD_STAT(numIO, "number of VM exits due to legacy IO"),
+ ADD_STAT(numHalt,
+ "number of VM exits due to wait for interrupt instructions"),
+ ADD_STAT(numInterrupts, "number of interrupts delivered"),
+ ADD_STAT(numHypercalls, "number of hypercalls")
{
- using namespace Stats;
-
- BaseCPU::regStats();
-
- numInsts
- .name(name() + ".committedInsts")
- .desc("Number of instructions committed")
- ;
-
- numVMExits
- .name(name() + ".numVMExits")
- .desc("total number of KVM exits")
- ;
-
- numVMHalfEntries
- .name(name() + ".numVMHalfEntries")
- .desc("number of KVM entries to finalize pending operations")
- ;
-
- numExitSignal
- .name(name() + ".numExitSignal")
- .desc("exits due to signal delivery")
- ;
-
- numMMIO
- .name(name() + ".numMMIO")
- .desc("number of VM exits due to memory mapped IO")
- ;
-
- numCoalescedMMIO
- .name(name() + ".numCoalescedMMIO")
- .desc("number of coalesced memory mapped IO requests")
- ;
-
- numIO
- .name(name() + ".numIO")
- .desc("number of VM exits due to legacy IO")
- ;
-
- numHalt
- .name(name() + ".numHalt")
- .desc("number of VM exits due to wait for interrupt instructions")
- ;
-
- numInterrupts
- .name(name() + ".numInterrupts")
- .desc("number of interrupts delivered")
- ;
-
- numHypercalls
- .name(name() + ".numHypercalls")
- .desc("number of hypercalls")
- ;
}
void
if (_kvmRun->exit_reason != KVM_EXIT_INTR) {
_status = RunningService;
} else {
- ++numExitSignal;
+ ++stats.numExitSignal;
_status = Running;
}
// then immediately exits.
DPRINTF(KvmRun, "KVM: Delivering IO without full guest entry\n");
- ++numVMHalfEntries;
+ ++stats.numVMHalfEntries;
// Send a KVM_KICK_SIGNAL to the vCPU thread (i.e., this
// thread). The KVM control signal is masked while executing
/* Update statistics */
numCycles += simCyclesExecuted;;
- numInsts += instsExecuted;
+ stats.committedInsts += instsExecuted;
ctrInsts += instsExecuted;
system->totalNumInsts += instsExecuted;
instsExecuted, hostCyclesExecuted, ticksExecuted, simCyclesExecuted);
}
- ++numVMExits;
+ ++stats.numVMExits;
return ticksExecuted + flushCoalescedMMIO();
}
void
BaseKvmCPU::kvmNonMaskableInterrupt()
{
- ++numInterrupts;
+ ++stats.numInterrupts;
if (ioctl(KVM_NMI) == -1)
panic("KVM: Failed to deliver NMI to virtual CPU\n");
}
void
BaseKvmCPU::kvmInterrupt(const struct kvm_interrupt &interrupt)
{
- ++numInterrupts;
+ ++stats.numInterrupts;
if (ioctl(KVM_INTERRUPT, (void *)&interrupt) == -1)
panic("KVM: Failed to deliver interrupt to virtual CPU\n");
}
case KVM_EXIT_IO:
{
- ++numIO;
+ ++stats.numIO;
Tick ticks = handleKvmExitIO();
_status = dataPort.nextIOState();
return ticks;
}
case KVM_EXIT_HYPERCALL:
- ++numHypercalls;
+ ++stats.numHypercalls;
return handleKvmExitHypercall();
case KVM_EXIT_HLT:
/* The guest has halted and is waiting for interrupts */
DPRINTF(Kvm, "handleKvmExitHalt\n");
- ++numHalt;
+ ++stats.numHalt;
// Suspend the thread until the next interrupt arrives
thread->suspend();
_kvmRun->mmio.is_write,
_kvmRun->mmio.phys_addr, _kvmRun->mmio.len);
- ++numMMIO;
+ ++stats.numMMIO;
Tick ticks = doMMIOAccess(_kvmRun->mmio.phys_addr, _kvmRun->mmio.data,
_kvmRun->mmio.len, _kvmRun->mmio.is_write);
// doMMIOAccess could have triggered a suspend, in which case we don't
DPRINTF(KvmIO, "KVM: Handling coalesced MMIO (addr: 0x%x, len: %u)\n",
ent.phys_addr, ent.len);
- ++numCoalescedMMIO;
+ ++stats.numCoalescedMMIO;
ticks += doMMIOAccess(ent.phys_addr, ent.data, ent.len, true);
mmioRing->first = (mmioRing->first + 1) % KVM_COALESCED_MMIO_MAX;
void init() override;
void startup() override;
- void regStats() override;
void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
public:
/* @{ */
- Stats::Scalar numInsts;
- Stats::Scalar numVMExits;
- Stats::Scalar numVMHalfEntries;
- Stats::Scalar numExitSignal;
- Stats::Scalar numMMIO;
- Stats::Scalar numCoalescedMMIO;
- Stats::Scalar numIO;
- Stats::Scalar numHalt;
- Stats::Scalar numInterrupts;
- Stats::Scalar numHypercalls;
+ struct StatGroup : public Stats::Group {
+ StatGroup(Stats::Group *parent);
+ Stats::Scalar committedInsts;
+ Stats::Scalar numVMExits;
+ Stats::Scalar numVMHalfEntries;
+ Stats::Scalar numExitSignal;
+ Stats::Scalar numMMIO;
+ Stats::Scalar numCoalescedMMIO;
+ Stats::Scalar numIO;
+ Stats::Scalar numHalt;
+ Stats::Scalar numInterrupts;
+ Stats::Scalar numHypercalls;
+ } stats;
/* @} */
/** Number of instructions executed by the CPU */