aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2015-03-27 23:21:02 -0400
committerAlexander Graf <agraf@suse.de>2015-04-21 09:21:31 -0400
commitb6c295df3131c6fa25f8f29625ee0609506150ad (patch)
treebb9a89ae934bcefcb16f62de9f432493852b480a /arch/powerpc/include
parente23a808b1681d398a983ebc51179efc51c4a1eaf (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/include')
-rw-r--r--arch/powerpc/include/asm/kvm_host.h21
-rw-r--r--arch/powerpc/include/asm/time.h3
2 files changed, 24 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index f1d0bbc0f079..d2068bba9059 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -369,6 +369,14 @@ struct kvmppc_slb {
369 u8 base_page_size; /* MMU_PAGE_xxx */ 369 u8 base_page_size; /* MMU_PAGE_xxx */
370}; 370};
371 371
372/* Struct used to accumulate timing information in HV real mode code */
373struct kvmhv_tb_accumulator {
374 u64 seqcount; /* used to synchronize access, also count * 2 */
375 u64 tb_total; /* total time in timebase ticks */
376 u64 tb_min; /* min time */
377 u64 tb_max; /* max time */
378};
379
372# ifdef CONFIG_PPC_FSL_BOOK3E 380# ifdef CONFIG_PPC_FSL_BOOK3E
373#define KVMPPC_BOOKE_IAC_NUM 2 381#define KVMPPC_BOOKE_IAC_NUM 2
374#define KVMPPC_BOOKE_DAC_NUM 2 382#define KVMPPC_BOOKE_DAC_NUM 2
@@ -657,6 +665,19 @@ struct kvm_vcpu_arch {
657 665
658 u32 emul_inst; 666 u32 emul_inst;
659#endif 667#endif
668
669#ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING
670 struct kvmhv_tb_accumulator *cur_activity; /* What we're timing */
671 u64 cur_tb_start; /* when it started */
672 struct kvmhv_tb_accumulator rm_entry; /* real-mode entry code */
673 struct kvmhv_tb_accumulator rm_intr; /* real-mode intr handling */
674 struct kvmhv_tb_accumulator rm_exit; /* real-mode exit code */
675 struct kvmhv_tb_accumulator guest_time; /* guest execution */
676 struct kvmhv_tb_accumulator cede_time; /* time napping inside guest */
677
678 struct dentry *debugfs_dir;
679 struct dentry *debugfs_timings;
680#endif /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */
660}; 681};
661 682
662#define VCPU_FPR(vcpu, i) (vcpu)->arch.fp.fpr[i][TS_FPROFFSET] 683#define VCPU_FPR(vcpu, i) (vcpu)->arch.fp.fpr[i][TS_FPROFFSET]
diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h
index 03cbada59d3a..10fc784a2ad4 100644
--- a/arch/powerpc/include/asm/time.h
+++ b/arch/powerpc/include/asm/time.h
@@ -211,5 +211,8 @@ extern void secondary_cpu_time_init(void);
211 211
212DECLARE_PER_CPU(u64, decrementers_next_tb); 212DECLARE_PER_CPU(u64, decrementers_next_tb);
213 213
214/* Convert timebase ticks to nanoseconds */
215unsigned long long tb_to_ns(unsigned long long tb_ticks);
216
214#endif /* __KERNEL__ */ 217#endif /* __KERNEL__ */
215#endif /* __POWERPC_TIME_H */ 218#endif /* __POWERPC_TIME_H */