kvm: Separate host frequency from simulated CPU frequency
authorAndreas Sandberg <andreas@sandberg.pp.se>
Tue, 11 Jun 2013 07:24:55 +0000 (09:24 +0200)
committerAndreas Sandberg <andreas@sandberg.pp.se>
Tue, 11 Jun 2013 07:24:55 +0000 (09:24 +0200)
We used to use the KVM CPU's clock to specify the host frequency. This
was not ideal for several reasons. One of them being that the clock
parameter of a CPU determines the frequency of some of the components
connected to the CPU. This changeset adds a separate hostFreq
parameter that should be used to specify the host frequency until we
add code to autodetect it. The hostFactor should still be used to
specify the conversion factor between the host performance and that of
the simulated system.

src/cpu/kvm/BaseKvmCPU.py
src/cpu/kvm/base.cc
src/cpu/kvm/base.hh

index 796a7794b24c59537297f00e90261c77cbfe53ab..644ca3620a8042cbb63b8d0b9a801b68a5ce9bd9 100644 (file)
@@ -71,4 +71,6 @@ class BaseKvmCPU(BaseCPU):
     kvmVM = Param.KvmVM(Parent.any, 'KVM VM (i.e., shared memory domain)')
     useCoalescedMMIO = Param.Bool(False, "Use coalesced MMIO (EXPERIMENTAL)")
     usePerfOverflow = Param.Bool(False, "Use perf event overflow counters (EXPERIMENTAL)")
+
+    hostFreq = Param.Clock("2GHz", "Host clock frequency")
     hostFactor = Param.Float(1.0, "Cycle scale factor")
index 3bfe44cf43264f2594430f2c21c8f2e91d69c9fc..539790e527303c10a060261ef2dfa77ce885df54 100644 (file)
@@ -83,6 +83,7 @@ BaseKvmCPU::BaseKvmCPU(BaseKvmCPUParams *params)
       pageSize(sysconf(_SC_PAGE_SIZE)),
       tickEvent(*this),
       perfControlledByTimer(params->usePerfOverflow),
+      hostFreq(params->hostFreq),
       hostFactor(params->hostFactor),
       drainManager(NULL),
       ctrInsts(0)
@@ -103,11 +104,11 @@ BaseKvmCPU::BaseKvmCPU(BaseKvmCPUParams *params)
         runTimer.reset(new PerfKvmTimer(hwCycles,
                                         KVM_TIMER_SIGNAL,
                                         params->hostFactor,
-                                        params->clock));
+                                        params->hostFreq));
     else
         runTimer.reset(new PosixKvmTimer(KVM_TIMER_SIGNAL, CLOCK_MONOTONIC,
                                          params->hostFactor,
-                                         params->clock));
+                                         params->hostFreq));
 }
 
 BaseKvmCPU::~BaseKvmCPU()
@@ -410,8 +411,7 @@ BaseKvmCPU::activateContext(ThreadID thread_num, Cycles delay)
     assert(_status == Idle);
     assert(!tickEvent.scheduled());
 
-    numCycles += ticksToCycles(thread->lastActivate - thread->lastSuspend)
-        * hostFactor;
+    numCycles += ticksToCycles(thread->lastActivate - thread->lastSuspend);
 
     schedule(tickEvent, clockEdge(delay));
     _status = Running;
index 42a7eca2b7a40368f79f965d20d63f9be22d2fba..2e3ee551bc6ce0c48e33e01b72924cc2799b90d4 100644 (file)
@@ -670,6 +670,10 @@ class BaseKvmCPU : public BaseCPU
      */
     std::unique_ptr<BaseKvmTimer> runTimer;
 
+    /** Host frequency */
+    Tick hostFreq;
+
+    /** Host factor as specified in the configuration */
     float hostFactor;
 
     /**