]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: PPC: Book3S HV: Decouple the debug timing from the P8 entry path
authorFabiano Rosas <farosas@linux.ibm.com>
Wed, 25 May 2022 13:05:52 +0000 (10:05 -0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 29 Jun 2022 09:21:21 +0000 (19:21 +1000)
We are currently doing the timing for debug purposes of the P9 entry
path using the accumulators and terminology defined by the old entry
path for P8 machines.

Not only the "real-mode" and "napping" mentions are out of place for
the P9 Radix entry path but also we cannot change them because the
timing code is coupled to the structures defined in struct
kvm_vcpu_arch.

Add a new CONFIG_KVM_BOOK3S_HV_P9_TIMING to enable the timing code for
the P9 entry path. For now, just add the new CONFIG and duplicate the
structures. A subsequent patch will add the P9 changes.

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220525130554.2614394-4-farosas@linux.ibm.com
arch/powerpc/include/asm/kvm_host.h
arch/powerpc/kvm/Kconfig
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/kvm/book3s_hv_p9_entry.c

index 2909a88acd163b3633626390e0eb36f0dcfd19f1..a0f44762a069a0714382bf176cbc66652a7ea54b 100644 (file)
@@ -830,11 +830,19 @@ struct kvm_vcpu_arch {
 #ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING
        struct kvmhv_tb_accumulator *cur_activity;      /* What we're timing */
        u64     cur_tb_start;                   /* when it started */
+#ifdef CONFIG_KVM_BOOK3S_HV_P9_TIMING
        struct kvmhv_tb_accumulator rm_entry;   /* real-mode entry code */
        struct kvmhv_tb_accumulator rm_intr;    /* real-mode intr handling */
        struct kvmhv_tb_accumulator rm_exit;    /* real-mode exit code */
        struct kvmhv_tb_accumulator guest_time; /* guest execution */
        struct kvmhv_tb_accumulator cede_time;  /* time napping inside guest */
+#else
+       struct kvmhv_tb_accumulator rm_entry;   /* real-mode entry code */
+       struct kvmhv_tb_accumulator rm_intr;    /* real-mode intr handling */
+       struct kvmhv_tb_accumulator rm_exit;    /* real-mode exit code */
+       struct kvmhv_tb_accumulator guest_time; /* guest execution */
+       struct kvmhv_tb_accumulator cede_time;  /* time napping inside guest */
+#endif
 #endif /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */
 };
 
index 73f8277df7d193648e4a4c85dd1cb3462908c32c..191347f44731116fea580bb3b04813cb71c6a024 100644 (file)
@@ -130,10 +130,22 @@ config KVM_BOOK3S_64_PR
 config KVM_BOOK3S_HV_EXIT_TIMING
        bool
 
+config KVM_BOOK3S_HV_P9_TIMING
+       bool "Detailed timing for the P9 entry point"
+       select KVM_BOOK3S_HV_EXIT_TIMING
+       depends on KVM_BOOK3S_HV_POSSIBLE && DEBUG_FS
+       help
+         Calculate time taken for each vcpu in various parts of the
+         code. The total, minimum and maximum times in nanoseconds
+         together with the number of executions are reported in debugfs in
+         kvm/vm#/vcpu#/timings.
+
+         If unsure, say N.
+
 config KVM_BOOK3S_HV_P8_TIMING
        bool "Detailed timing for hypervisor real-mode code (for POWER8)"
        select KVM_BOOK3S_HV_EXIT_TIMING
-       depends on KVM_BOOK3S_HV_POSSIBLE && DEBUG_FS
+       depends on KVM_BOOK3S_HV_POSSIBLE && DEBUG_FS && !KVM_BOOK3S_HV_P9_TIMING
        help
          Calculate time taken for each vcpu in the real-mode guest entry,
          exit, and interrupt handling code, plus time spent in the guest
index e08fb3124dcaa06ed3d2fe9bf93c7d06d613c909..108ee563f72ada3652a3065261fcffc8f3579708 100644 (file)
@@ -2660,11 +2660,19 @@ static struct debugfs_timings_element {
        const char *name;
        size_t offset;
 } timings[] = {
+#ifdef CONFIG_KVM_BOOK3S_HV_P9_TIMING
        {"rm_entry",    offsetof(struct kvm_vcpu, arch.rm_entry)},
        {"rm_intr",     offsetof(struct kvm_vcpu, arch.rm_intr)},
        {"rm_exit",     offsetof(struct kvm_vcpu, arch.rm_exit)},
        {"guest",       offsetof(struct kvm_vcpu, arch.guest_time)},
        {"cede",        offsetof(struct kvm_vcpu, arch.cede_time)},
+#else
+       {"rm_entry",    offsetof(struct kvm_vcpu, arch.rm_entry)},
+       {"rm_intr",     offsetof(struct kvm_vcpu, arch.rm_intr)},
+       {"rm_exit",     offsetof(struct kvm_vcpu, arch.rm_exit)},
+       {"guest",       offsetof(struct kvm_vcpu, arch.guest_time)},
+       {"cede",        offsetof(struct kvm_vcpu, arch.cede_time)},
+#endif
 };
 
 #define N_TIMINGS      (ARRAY_SIZE(timings))
@@ -2783,8 +2791,9 @@ static const struct file_operations debugfs_timings_ops = {
 /* Create a debugfs directory for the vcpu */
 static int kvmppc_arch_create_vcpu_debugfs_hv(struct kvm_vcpu *vcpu, struct dentry *debugfs_dentry)
 {
-       debugfs_create_file("timings", 0444, debugfs_dentry, vcpu,
-                           &debugfs_timings_ops);
+       if (cpu_has_feature(CPU_FTR_ARCH_300) == IS_ENABLED(CONFIG_KVM_BOOK3S_HV_P9_TIMING))
+               debugfs_create_file("timings", 0444, debugfs_dentry, vcpu,
+                                   &debugfs_timings_ops);
        return 0;
 }
 
index 7f88be386b27a88096120fbe14c58c4db6129626..8d8c0cf39bdf99a114a403049c7db6ff6a21a522 100644 (file)
@@ -437,7 +437,7 @@ void restore_p9_host_os_sprs(struct kvm_vcpu *vcpu,
 }
 EXPORT_SYMBOL_GPL(restore_p9_host_os_sprs);
 
-#ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING
+#ifdef CONFIG_KVM_BOOK3S_HV_P9_TIMING
 static void __accumulate_time(struct kvm_vcpu *vcpu, struct kvmhv_tb_accumulator *next)
 {
        struct kvmppc_vcore *vc = vcpu->arch.vcore;