From: eavivi Date: Mon, 31 Aug 2020 20:45:53 +0000 (-0700) Subject: cpu-kvm: convert kvm base to new style stats X-Git-Tag: v20.1.0.0~155 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=13cd5b215be009de27b709117afac54753e29ed6;p=gem5.git cpu-kvm: convert kvm base to new style stats Change-Id: Iab2e99720cf9ac58edfcbdcedc944264eb12b7e1 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33796 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/cpu/kvm/base.cc b/src/cpu/kvm/base.cc index 0afab1e84..5e3ffd723 100644 --- a/src/cpu/kvm/base.cc +++ b/src/cpu/kvm/base.cc @@ -75,7 +75,7 @@ BaseKvmCPU::BaseKvmCPU(BaseKvmCPUParams *params) false, Event::CPU_Tick_Pri), activeInstPeriod(0), perfControlledByTimer(params->usePerfOverflow), - hostFactor(params->hostFactor), + hostFactor(params->hostFactor), stats(this), ctrInsts(0) { if (pageSize == -1) @@ -258,62 +258,22 @@ BaseKvmCPU::startupThread() } -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 @@ -672,7 +632,7 @@ BaseKvmCPU::tick() if (_kvmRun->exit_reason != KVM_EXIT_INTR) { _status = RunningService; } else { - ++numExitSignal; + ++stats.numExitSignal; _status = Running; } @@ -735,7 +695,7 @@ BaseKvmCPU::kvmRun(Tick ticks) // 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 @@ -803,7 +763,7 @@ BaseKvmCPU::kvmRun(Tick ticks) /* Update statistics */ numCycles += simCyclesExecuted;; - numInsts += instsExecuted; + stats.committedInsts += instsExecuted; ctrInsts += instsExecuted; system->totalNumInsts += instsExecuted; @@ -813,7 +773,7 @@ BaseKvmCPU::kvmRun(Tick ticks) instsExecuted, hostCyclesExecuted, ticksExecuted, simCyclesExecuted); } - ++numVMExits; + ++stats.numVMExits; return ticksExecuted + flushCoalescedMMIO(); } @@ -821,7 +781,7 @@ BaseKvmCPU::kvmRun(Tick ticks) void BaseKvmCPU::kvmNonMaskableInterrupt() { - ++numInterrupts; + ++stats.numInterrupts; if (ioctl(KVM_NMI) == -1) panic("KVM: Failed to deliver NMI to virtual CPU\n"); } @@ -829,7 +789,7 @@ BaseKvmCPU::kvmNonMaskableInterrupt() 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"); } @@ -1000,20 +960,20 @@ BaseKvmCPU::handleKvmExit() 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(); @@ -1028,7 +988,7 @@ BaseKvmCPU::handleKvmExit() _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 @@ -1195,7 +1155,7 @@ BaseKvmCPU::flushCoalescedMMIO() 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; diff --git a/src/cpu/kvm/base.hh b/src/cpu/kvm/base.hh index e999499ca..73465af37 100644 --- a/src/cpu/kvm/base.hh +++ b/src/cpu/kvm/base.hh @@ -82,7 +82,6 @@ class BaseKvmCPU : public BaseCPU void init() override; void startup() override; - void regStats() override; void serializeThread(CheckpointOut &cp, ThreadID tid) const override; void unserializeThread(CheckpointIn &cp, ThreadID tid) override; @@ -782,16 +781,19 @@ class BaseKvmCPU : public BaseCPU 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 */