diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2015-09-15 12:27:57 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-09-16 06:17:00 -0400 |
commit | 62bea5bff486644ecf363fe8a1a2f6f32c614a49 (patch) | |
tree | 774180da187dabef4995896aec803248b075a36d | |
parent | 8f4216c7d28976f7ec1b2bcbfa0a9f787133c45e (diff) |
KVM: add halt_attempted_poll to VCPU stats
This new statistic can help diagnosing VCPUs that, for any reason,
trigger bad behavior of halt_poll_ns autotuning.
For example, say halt_poll_ns = 480000, and wakeups are spaced exactly
like 479us, 481us, 479us, 481us. Then KVM always fails polling and wastes
10+20+40+80+160+320+480 = 1110 microseconds out of every
479+481+479+481+479+481+479 = 3359 microseconds. The VCPU then
is consuming about 30% more CPU than it would use without
polling. This would show as an abnormally high number of
attempted polling compared to the successful polls.
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com<
Reviewed-by: David Matlack <dmatlack@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | arch/arm/include/asm/kvm_host.h | 1 | ||||
-rw-r--r-- | arch/arm64/include/asm/kvm_host.h | 1 | ||||
-rw-r--r-- | arch/mips/include/asm/kvm_host.h | 1 | ||||
-rw-r--r-- | arch/mips/kvm/mips.c | 1 | ||||
-rw-r--r-- | arch/powerpc/include/asm/kvm_host.h | 1 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s.c | 1 | ||||
-rw-r--r-- | arch/powerpc/kvm/booke.c | 1 | ||||
-rw-r--r-- | arch/s390/include/asm/kvm_host.h | 1 | ||||
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 1 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 1 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 1 |
12 files changed, 12 insertions, 0 deletions
diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index dcba0fa5176e..687ddeba3611 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h | |||
@@ -148,6 +148,7 @@ struct kvm_vm_stat { | |||
148 | 148 | ||
149 | struct kvm_vcpu_stat { | 149 | struct kvm_vcpu_stat { |
150 | u32 halt_successful_poll; | 150 | u32 halt_successful_poll; |
151 | u32 halt_attempted_poll; | ||
151 | u32 halt_wakeup; | 152 | u32 halt_wakeup; |
152 | }; | 153 | }; |
153 | 154 | ||
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 415938dc45cf..486594583cc6 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h | |||
@@ -195,6 +195,7 @@ struct kvm_vm_stat { | |||
195 | 195 | ||
196 | struct kvm_vcpu_stat { | 196 | struct kvm_vcpu_stat { |
197 | u32 halt_successful_poll; | 197 | u32 halt_successful_poll; |
198 | u32 halt_attempted_poll; | ||
198 | u32 halt_wakeup; | 199 | u32 halt_wakeup; |
199 | }; | 200 | }; |
200 | 201 | ||
diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h index e8c8d9d0c45f..3a54dbca9f7e 100644 --- a/arch/mips/include/asm/kvm_host.h +++ b/arch/mips/include/asm/kvm_host.h | |||
@@ -128,6 +128,7 @@ struct kvm_vcpu_stat { | |||
128 | u32 msa_disabled_exits; | 128 | u32 msa_disabled_exits; |
129 | u32 flush_dcache_exits; | 129 | u32 flush_dcache_exits; |
130 | u32 halt_successful_poll; | 130 | u32 halt_successful_poll; |
131 | u32 halt_attempted_poll; | ||
131 | u32 halt_wakeup; | 132 | u32 halt_wakeup; |
132 | }; | 133 | }; |
133 | 134 | ||
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index cd4c129ce743..49ff3bfc007e 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c | |||
@@ -55,6 +55,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { | |||
55 | { "msa_disabled", VCPU_STAT(msa_disabled_exits), KVM_STAT_VCPU }, | 55 | { "msa_disabled", VCPU_STAT(msa_disabled_exits), KVM_STAT_VCPU }, |
56 | { "flush_dcache", VCPU_STAT(flush_dcache_exits), KVM_STAT_VCPU }, | 56 | { "flush_dcache", VCPU_STAT(flush_dcache_exits), KVM_STAT_VCPU }, |
57 | { "halt_successful_poll", VCPU_STAT(halt_successful_poll), KVM_STAT_VCPU }, | 57 | { "halt_successful_poll", VCPU_STAT(halt_successful_poll), KVM_STAT_VCPU }, |
58 | { "halt_attempted_poll", VCPU_STAT(halt_attempted_poll), KVM_STAT_VCPU }, | ||
58 | { "halt_wakeup", VCPU_STAT(halt_wakeup), KVM_STAT_VCPU }, | 59 | { "halt_wakeup", VCPU_STAT(halt_wakeup), KVM_STAT_VCPU }, |
59 | {NULL} | 60 | {NULL} |
60 | }; | 61 | }; |
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 98eebbf66340..195886a583ba 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h | |||
@@ -108,6 +108,7 @@ struct kvm_vcpu_stat { | |||
108 | u32 dec_exits; | 108 | u32 dec_exits; |
109 | u32 ext_intr_exits; | 109 | u32 ext_intr_exits; |
110 | u32 halt_successful_poll; | 110 | u32 halt_successful_poll; |
111 | u32 halt_attempted_poll; | ||
111 | u32 halt_wakeup; | 112 | u32 halt_wakeup; |
112 | u32 dbell_exits; | 113 | u32 dbell_exits; |
113 | u32 gdbell_exits; | 114 | u32 gdbell_exits; |
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index d75bf325f54a..cf009167d208 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c | |||
@@ -53,6 +53,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { | |||
53 | { "ext_intr", VCPU_STAT(ext_intr_exits) }, | 53 | { "ext_intr", VCPU_STAT(ext_intr_exits) }, |
54 | { "queue_intr", VCPU_STAT(queue_intr) }, | 54 | { "queue_intr", VCPU_STAT(queue_intr) }, |
55 | { "halt_successful_poll", VCPU_STAT(halt_successful_poll), }, | 55 | { "halt_successful_poll", VCPU_STAT(halt_successful_poll), }, |
56 | { "halt_attempted_poll", VCPU_STAT(halt_attempted_poll), }, | ||
56 | { "halt_wakeup", VCPU_STAT(halt_wakeup) }, | 57 | { "halt_wakeup", VCPU_STAT(halt_wakeup) }, |
57 | { "pf_storage", VCPU_STAT(pf_storage) }, | 58 | { "pf_storage", VCPU_STAT(pf_storage) }, |
58 | { "sp_storage", VCPU_STAT(sp_storage) }, | 59 | { "sp_storage", VCPU_STAT(sp_storage) }, |
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index ae458f0fd061..fd5875179e5c 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c | |||
@@ -63,6 +63,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { | |||
63 | { "dec", VCPU_STAT(dec_exits) }, | 63 | { "dec", VCPU_STAT(dec_exits) }, |
64 | { "ext_intr", VCPU_STAT(ext_intr_exits) }, | 64 | { "ext_intr", VCPU_STAT(ext_intr_exits) }, |
65 | { "halt_successful_poll", VCPU_STAT(halt_successful_poll) }, | 65 | { "halt_successful_poll", VCPU_STAT(halt_successful_poll) }, |
66 | { "halt_attempted_poll", VCPU_STAT(halt_attempted_poll) }, | ||
66 | { "halt_wakeup", VCPU_STAT(halt_wakeup) }, | 67 | { "halt_wakeup", VCPU_STAT(halt_wakeup) }, |
67 | { "doorbell", VCPU_STAT(dbell_exits) }, | 68 | { "doorbell", VCPU_STAT(dbell_exits) }, |
68 | { "guest doorbell", VCPU_STAT(gdbell_exits) }, | 69 | { "guest doorbell", VCPU_STAT(gdbell_exits) }, |
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h index 3d012e071647..6ce4a0b7e8da 100644 --- a/arch/s390/include/asm/kvm_host.h +++ b/arch/s390/include/asm/kvm_host.h | |||
@@ -210,6 +210,7 @@ struct kvm_vcpu_stat { | |||
210 | u32 exit_validity; | 210 | u32 exit_validity; |
211 | u32 exit_instruction; | 211 | u32 exit_instruction; |
212 | u32 halt_successful_poll; | 212 | u32 halt_successful_poll; |
213 | u32 halt_attempted_poll; | ||
213 | u32 halt_wakeup; | 214 | u32 halt_wakeup; |
214 | u32 instruction_lctl; | 215 | u32 instruction_lctl; |
215 | u32 instruction_lctlg; | 216 | u32 instruction_lctlg; |
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index c91eb941b444..2f807ab1725e 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -63,6 +63,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { | |||
63 | { "exit_program_interruption", VCPU_STAT(exit_program_interruption) }, | 63 | { "exit_program_interruption", VCPU_STAT(exit_program_interruption) }, |
64 | { "exit_instr_and_program_int", VCPU_STAT(exit_instr_and_program) }, | 64 | { "exit_instr_and_program_int", VCPU_STAT(exit_instr_and_program) }, |
65 | { "halt_successful_poll", VCPU_STAT(halt_successful_poll) }, | 65 | { "halt_successful_poll", VCPU_STAT(halt_successful_poll) }, |
66 | { "halt_attempted_poll", VCPU_STAT(halt_attempted_poll) }, | ||
66 | { "halt_wakeup", VCPU_STAT(halt_wakeup) }, | 67 | { "halt_wakeup", VCPU_STAT(halt_wakeup) }, |
67 | { "instruction_lctlg", VCPU_STAT(instruction_lctlg) }, | 68 | { "instruction_lctlg", VCPU_STAT(instruction_lctlg) }, |
68 | { "instruction_lctl", VCPU_STAT(instruction_lctl) }, | 69 | { "instruction_lctl", VCPU_STAT(instruction_lctl) }, |
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index c12e845f59e6..349f80a82b82 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -711,6 +711,7 @@ struct kvm_vcpu_stat { | |||
711 | u32 nmi_window_exits; | 711 | u32 nmi_window_exits; |
712 | u32 halt_exits; | 712 | u32 halt_exits; |
713 | u32 halt_successful_poll; | 713 | u32 halt_successful_poll; |
714 | u32 halt_attempted_poll; | ||
714 | u32 halt_wakeup; | 715 | u32 halt_wakeup; |
715 | u32 request_irq_exits; | 716 | u32 request_irq_exits; |
716 | u32 irq_exits; | 717 | u32 irq_exits; |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a60bdbccff51..6bbb0dfb99d0 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -149,6 +149,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { | |||
149 | { "nmi_window", VCPU_STAT(nmi_window_exits) }, | 149 | { "nmi_window", VCPU_STAT(nmi_window_exits) }, |
150 | { "halt_exits", VCPU_STAT(halt_exits) }, | 150 | { "halt_exits", VCPU_STAT(halt_exits) }, |
151 | { "halt_successful_poll", VCPU_STAT(halt_successful_poll) }, | 151 | { "halt_successful_poll", VCPU_STAT(halt_successful_poll) }, |
152 | { "halt_attempted_poll", VCPU_STAT(halt_attempted_poll) }, | ||
152 | { "halt_wakeup", VCPU_STAT(halt_wakeup) }, | 153 | { "halt_wakeup", VCPU_STAT(halt_wakeup) }, |
153 | { "hypercalls", VCPU_STAT(hypercalls) }, | 154 | { "hypercalls", VCPU_STAT(hypercalls) }, |
154 | { "request_irq", VCPU_STAT(request_irq_exits) }, | 155 | { "request_irq", VCPU_STAT(request_irq_exits) }, |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 9af68db73c6a..04146a2e1d81 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -2004,6 +2004,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) | |||
2004 | if (vcpu->halt_poll_ns) { | 2004 | if (vcpu->halt_poll_ns) { |
2005 | ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns); | 2005 | ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns); |
2006 | 2006 | ||
2007 | ++vcpu->stat.halt_attempted_poll; | ||
2007 | do { | 2008 | do { |
2008 | /* | 2009 | /* |
2009 | * This sets KVM_REQ_UNHALT if an interrupt | 2010 | * This sets KVM_REQ_UNHALT if an interrupt |