diff options
author | Paul Mackerras <paulus@samba.org> | 2015-03-27 23:21:02 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2015-04-21 09:21:31 -0400 |
commit | b6c295df3131c6fa25f8f29625ee0609506150ad (patch) | |
tree | bb9a89ae934bcefcb16f62de9f432493852b480a /arch/powerpc/kernel | |
parent | e23a808b1681d398a983ebc51179efc51c4a1eaf (diff) |
KVM: PPC: Book3S HV: Accumulate timing information for real-mode code
This reads the timebase at various points in the real-mode guest
entry/exit code and uses that to accumulate total, minimum and
maximum time spent in those parts of the code. Currently these
times are accumulated per vcpu in 5 parts of the code:
* rm_entry - time taken from the start of kvmppc_hv_entry() until
just before entering the guest.
* rm_intr - time from when we take a hypervisor interrupt in the
guest until we either re-enter the guest or decide to exit to the
host. This includes time spent handling hcalls in real mode.
* rm_exit - time from when we decide to exit the guest until the
return from kvmppc_hv_entry().
* guest - time spend in the guest
* cede - time spent napping in real mode due to an H_CEDE hcall
while other threads in the same vcore are active.
These times are exposed in debugfs in a directory per vcpu that
contains a file called "timings". This file contains one line for
each of the 5 timings above, with the name followed by a colon and
4 numbers, which are the count (number of times the code has been
executed), the total time, the minimum time, and the maximum time,
all in nanoseconds.
The overhead of the extra code amounts to about 30ns for an hcall that
is handled in real mode (e.g. H_SET_DABR), which is about 25%. Since
production environments may not wish to incur this overhead, the new
code is conditional on a new config symbol,
CONFIG_KVM_BOOK3S_HV_EXIT_TIMING.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r-- | arch/powerpc/kernel/asm-offsets.c | 13 | ||||
-rw-r--r-- | arch/powerpc/kernel/time.c | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 4717859fdd04..3fea721f0da5 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c | |||
@@ -459,6 +459,19 @@ int main(void) | |||
459 | DEFINE(VCPU_SPRG2, offsetof(struct kvm_vcpu, arch.shregs.sprg2)); | 459 | DEFINE(VCPU_SPRG2, offsetof(struct kvm_vcpu, arch.shregs.sprg2)); |
460 | DEFINE(VCPU_SPRG3, offsetof(struct kvm_vcpu, arch.shregs.sprg3)); | 460 | DEFINE(VCPU_SPRG3, offsetof(struct kvm_vcpu, arch.shregs.sprg3)); |
461 | #endif | 461 | #endif |
462 | #ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING | ||
463 | DEFINE(VCPU_TB_RMENTRY, offsetof(struct kvm_vcpu, arch.rm_entry)); | ||
464 | DEFINE(VCPU_TB_RMINTR, offsetof(struct kvm_vcpu, arch.rm_intr)); | ||
465 | DEFINE(VCPU_TB_RMEXIT, offsetof(struct kvm_vcpu, arch.rm_exit)); | ||
466 | DEFINE(VCPU_TB_GUEST, offsetof(struct kvm_vcpu, arch.guest_time)); | ||
467 | DEFINE(VCPU_TB_CEDE, offsetof(struct kvm_vcpu, arch.cede_time)); | ||
468 | DEFINE(VCPU_CUR_ACTIVITY, offsetof(struct kvm_vcpu, arch.cur_activity)); | ||
469 | DEFINE(VCPU_ACTIVITY_START, offsetof(struct kvm_vcpu, arch.cur_tb_start)); | ||
470 | DEFINE(TAS_SEQCOUNT, offsetof(struct kvmhv_tb_accumulator, seqcount)); | ||
471 | DEFINE(TAS_TOTAL, offsetof(struct kvmhv_tb_accumulator, tb_total)); | ||
472 | DEFINE(TAS_MIN, offsetof(struct kvmhv_tb_accumulator, tb_min)); | ||
473 | DEFINE(TAS_MAX, offsetof(struct kvmhv_tb_accumulator, tb_max)); | ||
474 | #endif | ||
462 | DEFINE(VCPU_SHARED_SPRG3, offsetof(struct kvm_vcpu_arch_shared, sprg3)); | 475 | DEFINE(VCPU_SHARED_SPRG3, offsetof(struct kvm_vcpu_arch_shared, sprg3)); |
463 | DEFINE(VCPU_SHARED_SPRG4, offsetof(struct kvm_vcpu_arch_shared, sprg4)); | 476 | DEFINE(VCPU_SHARED_SPRG4, offsetof(struct kvm_vcpu_arch_shared, sprg4)); |
464 | DEFINE(VCPU_SHARED_SPRG5, offsetof(struct kvm_vcpu_arch_shared, sprg5)); | 477 | DEFINE(VCPU_SHARED_SPRG5, offsetof(struct kvm_vcpu_arch_shared, sprg5)); |
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 2d7b33fab953..56f44848b044 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -608,6 +608,12 @@ void arch_suspend_enable_irqs(void) | |||
608 | } | 608 | } |
609 | #endif | 609 | #endif |
610 | 610 | ||
611 | unsigned long long tb_to_ns(unsigned long long ticks) | ||
612 | { | ||
613 | return mulhdu(ticks, tb_to_ns_scale) << tb_to_ns_shift; | ||
614 | } | ||
615 | EXPORT_SYMBOL_GPL(tb_to_ns); | ||
616 | |||
611 | /* | 617 | /* |
612 | * Scheduler clock - returns current time in nanosec units. | 618 | * Scheduler clock - returns current time in nanosec units. |
613 | * | 619 | * |