diff options
author | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-04-22 13:20:32 -0400 |
---|---|---|
committer | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-04-22 13:20:32 -0400 |
commit | 2607efded8ea856d632f017e93b40f1780046db1 (patch) | |
tree | 1d9c6072a2cc3189db43a39017fddec0af45691f /src/cpu/kvm/base.hh | |
parent | f485ad190830ab61d58ecdb8eb48621ffeb3008f (diff) | |
download | gem5-2607efded8ea856d632f017e93b40f1780046db1.tar.xz |
kvm: Avoid synchronizing the TC on every KVM exit
Reduce the number of KVM->TC synchronizations by overloading the
getContext() method and only request an update when the TC is
requested as opposed to every time KVM returns to gem5.
Diffstat (limited to 'src/cpu/kvm/base.hh')
-rw-r--r-- | src/cpu/kvm/base.hh | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/cpu/kvm/base.hh b/src/cpu/kvm/base.hh index 1424038a9..90ebae644 100644 --- a/src/cpu/kvm/base.hh +++ b/src/cpu/kvm/base.hh @@ -102,13 +102,27 @@ class BaseKvmCPU : public BaseCPU void deallocateContext(ThreadID thread_num); void haltContext(ThreadID thread_num); + ThreadContext *getContext(int tn); + Counter totalInsts() const; Counter totalOps() const; /** Dump the internal state to the terminal. */ virtual void dump(); - /** SimpleThread object, provides all the architectural state. */ + /** + * A cached copy of a thread's state in the form of a SimpleThread + * object. + * + * Normally the actual thread state is stored in the KVM vCPU. If KVM has + * been running this copy is will be out of date. If we recently handled + * some events within gem5 that required state to be updated this could be + * the most up-to-date copy. When getContext() or updateThreadContext() is + * called this copy gets updated. The method syncThreadContext can + * be used within a KVM CPU to update the thread context if the + * KVM state is dirty (i.e., the vCPU has been run since the last + * update). + */ SimpleThread *thread; /** ThreadContext object, provides an interface for external @@ -272,6 +286,17 @@ class BaseKvmCPU : public BaseCPU * and update gem5's thread state. */ virtual void updateThreadContext() = 0; + + /** + * Update a thread context if the KVM state is dirty with respect + * to the cached thread context. + */ + void syncThreadContext(); + + /** + * Update the KVM if the thread context is dirty. + */ + void syncKvmState(); /** @} */ /** @{ */ @@ -391,7 +416,13 @@ class BaseKvmCPU : public BaseCPU * Is the gem5 context dirty? Set to true to force an update of * the KVM vCPU state upon the next call to kvmRun(). */ - bool contextDirty; + bool threadContextDirty; + + /** + * Is the KVM state dirty? Set to true to force an update of + * the KVM vCPU state upon the next call to kvmRun(). + */ + bool kvmStateDirty; /** KVM internal ID of the vCPU */ const long vcpuID; |