KVM: PPC: Book3S HV: Report stolen time to guest through dispatch trace log
authorPaul Mackerras <paulus@samba.org>
Fri, 3 Feb 2012 00:56:21 +0000 (00:56 +0000)
committerAvi Kivity <avi@redhat.com>
Sun, 8 Apr 2012 11:01:29 +0000 (14:01 +0300)
commit0456ec4ff2b832ab9ff476ed687fea704500f1cd
treecfc0113c6f910fb51fd5b35c90653e7d17a321e1
parent2e25aa5f64b18a97f35266e51c71ff4dc644db0c
KVM: PPC: Book3S HV: Report stolen time to guest through dispatch trace log

This adds code to measure "stolen" time per virtual core in units of
timebase ticks, and to report the stolen time to the guest using the
dispatch trace log (DTL).  The guest can register an area of memory
for the DTL for a given vcpu.  The DTL is a ring buffer where KVM
fills in one entry every time it enters the guest for that vcpu.

Stolen time is measured as time when the virtual core is not running,
either because the vcore is not runnable (e.g. some of its vcpus are
executing elsewhere in the kernel or in userspace), or when the vcpu
thread that is running the vcore is preempted.  This includes time
when all the vcpus are idle (i.e. have executed the H_CEDE hypercall),
which is OK because the guest accounts stolen time while idle as idle
time.

Each vcpu keeps a record of how much stolen time has been reported to
the guest for that vcpu so far.  When we are about to enter the guest,
we create a new DTL entry (if the guest vcpu has a DTL) and report the
difference between total stolen time for the vcore and stolen time
reported so far for the vcpu as the "enqueue to dispatch" time in the
DTL entry.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/powerpc/include/asm/kvm_host.h
arch/powerpc/kvm/book3s_hv.c