diff options
-rw-r--r-- | arch/powerpc/include/asm/kvm_host.h | 8 | ||||
-rw-r--r-- | arch/powerpc/kvm/44x_emulate.c | 4 | ||||
-rw-r--r-- | arch/powerpc/kvm/booke.c | 30 | ||||
-rw-r--r-- | arch/powerpc/kvm/timing.c | 109 | ||||
-rw-r--r-- | arch/powerpc/kvm/timing.h | 6 |
5 files changed, 66 insertions, 91 deletions
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 2f5b49f2a98e..c1e436fe7738 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h | |||
@@ -102,9 +102,8 @@ enum kvm_exit_types { | |||
102 | __NUMBER_OF_KVM_EXIT_TYPES | 102 | __NUMBER_OF_KVM_EXIT_TYPES |
103 | }; | 103 | }; |
104 | 104 | ||
105 | #ifdef CONFIG_KVM_EXIT_TIMING | ||
106 | /* allow access to big endian 32bit upper/lower parts and 64bit var */ | 105 | /* allow access to big endian 32bit upper/lower parts and 64bit var */ |
107 | struct exit_timing { | 106 | struct kvmppc_exit_timing { |
108 | union { | 107 | union { |
109 | u64 tv64; | 108 | u64 tv64; |
110 | struct { | 109 | struct { |
@@ -112,7 +111,6 @@ struct exit_timing { | |||
112 | } tv32; | 111 | } tv32; |
113 | }; | 112 | }; |
114 | }; | 113 | }; |
115 | #endif | ||
116 | 114 | ||
117 | struct kvm_arch { | 115 | struct kvm_arch { |
118 | }; | 116 | }; |
@@ -174,8 +172,8 @@ struct kvm_vcpu_arch { | |||
174 | u32 dbcr1; | 172 | u32 dbcr1; |
175 | 173 | ||
176 | #ifdef CONFIG_KVM_EXIT_TIMING | 174 | #ifdef CONFIG_KVM_EXIT_TIMING |
177 | struct exit_timing timing_exit; | 175 | struct kvmppc_exit_timing timing_exit; |
178 | struct exit_timing timing_last_enter; | 176 | struct kvmppc_exit_timing timing_last_enter; |
179 | u32 last_exit_type; | 177 | u32 last_exit_type; |
180 | u32 timing_count_type[__NUMBER_OF_KVM_EXIT_TYPES]; | 178 | u32 timing_count_type[__NUMBER_OF_KVM_EXIT_TYPES]; |
181 | u64 timing_sum_duration[__NUMBER_OF_KVM_EXIT_TYPES]; | 179 | u64 timing_sum_duration[__NUMBER_OF_KVM_EXIT_TYPES]; |
diff --git a/arch/powerpc/kvm/44x_emulate.c b/arch/powerpc/kvm/44x_emulate.c index 69f88d53c428..82489a743a6f 100644 --- a/arch/powerpc/kvm/44x_emulate.c +++ b/arch/powerpc/kvm/44x_emulate.c | |||
@@ -132,7 +132,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
132 | run->dcr.is_write = 0; | 132 | run->dcr.is_write = 0; |
133 | vcpu->arch.io_gpr = rt; | 133 | vcpu->arch.io_gpr = rt; |
134 | vcpu->arch.dcr_needed = 1; | 134 | vcpu->arch.dcr_needed = 1; |
135 | account_exit(vcpu, DCR_EXITS); | 135 | kvmppc_account_exit(vcpu, DCR_EXITS); |
136 | emulated = EMULATE_DO_DCR; | 136 | emulated = EMULATE_DO_DCR; |
137 | } | 137 | } |
138 | 138 | ||
@@ -152,7 +152,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
152 | run->dcr.data = vcpu->arch.gpr[rs]; | 152 | run->dcr.data = vcpu->arch.gpr[rs]; |
153 | run->dcr.is_write = 1; | 153 | run->dcr.is_write = 1; |
154 | vcpu->arch.dcr_needed = 1; | 154 | vcpu->arch.dcr_needed = 1; |
155 | account_exit(vcpu, DCR_EXITS); | 155 | kvmppc_account_exit(vcpu, DCR_EXITS); |
156 | emulated = EMULATE_DO_DCR; | 156 | emulated = EMULATE_DO_DCR; |
157 | } | 157 | } |
158 | 158 | ||
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 0f171248e450..35485dd6927e 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c | |||
@@ -202,7 +202,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
202 | break; | 202 | break; |
203 | 203 | ||
204 | case BOOKE_INTERRUPT_EXTERNAL: | 204 | case BOOKE_INTERRUPT_EXTERNAL: |
205 | account_exit(vcpu, EXT_INTR_EXITS); | 205 | kvmppc_account_exit(vcpu, EXT_INTR_EXITS); |
206 | if (need_resched()) | 206 | if (need_resched()) |
207 | cond_resched(); | 207 | cond_resched(); |
208 | r = RESUME_GUEST; | 208 | r = RESUME_GUEST; |
@@ -212,7 +212,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
212 | /* Since we switched IVPR back to the host's value, the host | 212 | /* Since we switched IVPR back to the host's value, the host |
213 | * handled this interrupt the moment we enabled interrupts. | 213 | * handled this interrupt the moment we enabled interrupts. |
214 | * Now we just offer it a chance to reschedule the guest. */ | 214 | * Now we just offer it a chance to reschedule the guest. */ |
215 | account_exit(vcpu, DEC_EXITS); | 215 | kvmppc_account_exit(vcpu, DEC_EXITS); |
216 | if (need_resched()) | 216 | if (need_resched()) |
217 | cond_resched(); | 217 | cond_resched(); |
218 | r = RESUME_GUEST; | 218 | r = RESUME_GUEST; |
@@ -225,7 +225,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
225 | vcpu->arch.esr = vcpu->arch.fault_esr; | 225 | vcpu->arch.esr = vcpu->arch.fault_esr; |
226 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_PROGRAM); | 226 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_PROGRAM); |
227 | r = RESUME_GUEST; | 227 | r = RESUME_GUEST; |
228 | account_exit(vcpu, USR_PR_INST); | 228 | kvmppc_account_exit(vcpu, USR_PR_INST); |
229 | break; | 229 | break; |
230 | } | 230 | } |
231 | 231 | ||
@@ -233,7 +233,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
233 | switch (er) { | 233 | switch (er) { |
234 | case EMULATE_DONE: | 234 | case EMULATE_DONE: |
235 | /* don't overwrite subtypes, just account kvm_stats */ | 235 | /* don't overwrite subtypes, just account kvm_stats */ |
236 | account_exit_stat(vcpu, EMULATED_INST_EXITS); | 236 | kvmppc_account_exit_stat(vcpu, EMULATED_INST_EXITS); |
237 | /* Future optimization: only reload non-volatiles if | 237 | /* Future optimization: only reload non-volatiles if |
238 | * they were actually modified by emulation. */ | 238 | * they were actually modified by emulation. */ |
239 | r = RESUME_GUEST_NV; | 239 | r = RESUME_GUEST_NV; |
@@ -259,7 +259,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
259 | 259 | ||
260 | case BOOKE_INTERRUPT_FP_UNAVAIL: | 260 | case BOOKE_INTERRUPT_FP_UNAVAIL: |
261 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_FP_UNAVAIL); | 261 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_FP_UNAVAIL); |
262 | account_exit(vcpu, FP_UNAVAIL); | 262 | kvmppc_account_exit(vcpu, FP_UNAVAIL); |
263 | r = RESUME_GUEST; | 263 | r = RESUME_GUEST; |
264 | break; | 264 | break; |
265 | 265 | ||
@@ -267,20 +267,20 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
267 | vcpu->arch.dear = vcpu->arch.fault_dear; | 267 | vcpu->arch.dear = vcpu->arch.fault_dear; |
268 | vcpu->arch.esr = vcpu->arch.fault_esr; | 268 | vcpu->arch.esr = vcpu->arch.fault_esr; |
269 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DATA_STORAGE); | 269 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DATA_STORAGE); |
270 | account_exit(vcpu, DSI_EXITS); | 270 | kvmppc_account_exit(vcpu, DSI_EXITS); |
271 | r = RESUME_GUEST; | 271 | r = RESUME_GUEST; |
272 | break; | 272 | break; |
273 | 273 | ||
274 | case BOOKE_INTERRUPT_INST_STORAGE: | 274 | case BOOKE_INTERRUPT_INST_STORAGE: |
275 | vcpu->arch.esr = vcpu->arch.fault_esr; | 275 | vcpu->arch.esr = vcpu->arch.fault_esr; |
276 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_INST_STORAGE); | 276 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_INST_STORAGE); |
277 | account_exit(vcpu, ISI_EXITS); | 277 | kvmppc_account_exit(vcpu, ISI_EXITS); |
278 | r = RESUME_GUEST; | 278 | r = RESUME_GUEST; |
279 | break; | 279 | break; |
280 | 280 | ||
281 | case BOOKE_INTERRUPT_SYSCALL: | 281 | case BOOKE_INTERRUPT_SYSCALL: |
282 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_SYSCALL); | 282 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_SYSCALL); |
283 | account_exit(vcpu, SYSCALL_EXITS); | 283 | kvmppc_account_exit(vcpu, SYSCALL_EXITS); |
284 | r = RESUME_GUEST; | 284 | r = RESUME_GUEST; |
285 | break; | 285 | break; |
286 | 286 | ||
@@ -299,7 +299,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
299 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DTLB_MISS); | 299 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DTLB_MISS); |
300 | vcpu->arch.dear = vcpu->arch.fault_dear; | 300 | vcpu->arch.dear = vcpu->arch.fault_dear; |
301 | vcpu->arch.esr = vcpu->arch.fault_esr; | 301 | vcpu->arch.esr = vcpu->arch.fault_esr; |
302 | account_exit(vcpu, DTLB_REAL_MISS_EXITS); | 302 | kvmppc_account_exit(vcpu, DTLB_REAL_MISS_EXITS); |
303 | r = RESUME_GUEST; | 303 | r = RESUME_GUEST; |
304 | break; | 304 | break; |
305 | } | 305 | } |
@@ -317,13 +317,13 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
317 | * invoking the guest. */ | 317 | * invoking the guest. */ |
318 | kvmppc_mmu_map(vcpu, eaddr, vcpu->arch.paddr_accessed, gtlbe->tid, | 318 | kvmppc_mmu_map(vcpu, eaddr, vcpu->arch.paddr_accessed, gtlbe->tid, |
319 | gtlbe->word2, get_tlb_bytes(gtlbe), gtlb_index); | 319 | gtlbe->word2, get_tlb_bytes(gtlbe), gtlb_index); |
320 | account_exit(vcpu, DTLB_VIRT_MISS_EXITS); | 320 | kvmppc_account_exit(vcpu, DTLB_VIRT_MISS_EXITS); |
321 | r = RESUME_GUEST; | 321 | r = RESUME_GUEST; |
322 | } else { | 322 | } else { |
323 | /* Guest has mapped and accessed a page which is not | 323 | /* Guest has mapped and accessed a page which is not |
324 | * actually RAM. */ | 324 | * actually RAM. */ |
325 | r = kvmppc_emulate_mmio(run, vcpu); | 325 | r = kvmppc_emulate_mmio(run, vcpu); |
326 | account_exit(vcpu, MMIO_EXITS); | 326 | kvmppc_account_exit(vcpu, MMIO_EXITS); |
327 | } | 327 | } |
328 | 328 | ||
329 | break; | 329 | break; |
@@ -345,11 +345,11 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
345 | if (gtlb_index < 0) { | 345 | if (gtlb_index < 0) { |
346 | /* The guest didn't have a mapping for it. */ | 346 | /* The guest didn't have a mapping for it. */ |
347 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_ITLB_MISS); | 347 | kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_ITLB_MISS); |
348 | account_exit(vcpu, ITLB_REAL_MISS_EXITS); | 348 | kvmppc_account_exit(vcpu, ITLB_REAL_MISS_EXITS); |
349 | break; | 349 | break; |
350 | } | 350 | } |
351 | 351 | ||
352 | account_exit(vcpu, ITLB_VIRT_MISS_EXITS); | 352 | kvmppc_account_exit(vcpu, ITLB_VIRT_MISS_EXITS); |
353 | 353 | ||
354 | gtlbe = &vcpu_44x->guest_tlb[gtlb_index]; | 354 | gtlbe = &vcpu_44x->guest_tlb[gtlb_index]; |
355 | gpaddr = tlb_xlate(gtlbe, eaddr); | 355 | gpaddr = tlb_xlate(gtlbe, eaddr); |
@@ -383,7 +383,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
383 | mtspr(SPRN_DBSR, dbsr); | 383 | mtspr(SPRN_DBSR, dbsr); |
384 | 384 | ||
385 | run->exit_reason = KVM_EXIT_DEBUG; | 385 | run->exit_reason = KVM_EXIT_DEBUG; |
386 | account_exit(vcpu, DEBUG_EXITS); | 386 | kvmppc_account_exit(vcpu, DEBUG_EXITS); |
387 | r = RESUME_HOST; | 387 | r = RESUME_HOST; |
388 | break; | 388 | break; |
389 | } | 389 | } |
@@ -404,7 +404,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
404 | if (signal_pending(current)) { | 404 | if (signal_pending(current)) { |
405 | run->exit_reason = KVM_EXIT_INTR; | 405 | run->exit_reason = KVM_EXIT_INTR; |
406 | r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV); | 406 | r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV); |
407 | account_exit(vcpu, SIGNAL_EXITS); | 407 | kvmppc_account_exit(vcpu, SIGNAL_EXITS); |
408 | } | 408 | } |
409 | } | 409 | } |
410 | 410 | ||
diff --git a/arch/powerpc/kvm/timing.c b/arch/powerpc/kvm/timing.c index f42d2728a6a5..47ee603f558e 100644 --- a/arch/powerpc/kvm/timing.c +++ b/arch/powerpc/kvm/timing.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * along with this program; if not, write to the Free Software | 12 | * along with this program; if not, write to the Free Software |
13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
14 | * | 14 | * |
15 | * Copyright IBM Corp. 2007 | 15 | * Copyright IBM Corp. 2008 |
16 | * | 16 | * |
17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> | 17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> |
18 | * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> | 18 | * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> |
@@ -24,10 +24,11 @@ | |||
24 | #include <linux/debugfs.h> | 24 | #include <linux/debugfs.h> |
25 | #include <linux/uaccess.h> | 25 | #include <linux/uaccess.h> |
26 | 26 | ||
27 | #include "timing.h" | ||
28 | #include <asm/time.h> | 27 | #include <asm/time.h> |
29 | #include <asm-generic/div64.h> | 28 | #include <asm-generic/div64.h> |
30 | 29 | ||
30 | #include "timing.h" | ||
31 | |||
31 | void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) | 32 | void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) |
32 | { | 33 | { |
33 | int i; | 34 | int i; |
@@ -52,8 +53,7 @@ void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) | |||
52 | local_irq_enable(); | 53 | local_irq_enable(); |
53 | } | 54 | } |
54 | 55 | ||
55 | static void add_exit_timing(struct kvm_vcpu *vcpu, | 56 | static void add_exit_timing(struct kvm_vcpu *vcpu, u64 duration, int type) |
56 | u64 duration, int type) | ||
57 | { | 57 | { |
58 | u64 old; | 58 | u64 old; |
59 | 59 | ||
@@ -115,54 +115,46 @@ void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) | |||
115 | } | 115 | } |
116 | 116 | ||
117 | static const char *kvm_exit_names[__NUMBER_OF_KVM_EXIT_TYPES] = { | 117 | static const char *kvm_exit_names[__NUMBER_OF_KVM_EXIT_TYPES] = { |
118 | [MMIO_EXITS] = "MMIO", | 118 | [MMIO_EXITS] = "MMIO", |
119 | [DCR_EXITS] = "DCR", | 119 | [DCR_EXITS] = "DCR", |
120 | [SIGNAL_EXITS] = "SIGNAL", | 120 | [SIGNAL_EXITS] = "SIGNAL", |
121 | [ITLB_REAL_MISS_EXITS] = "ITLBREAL", | 121 | [ITLB_REAL_MISS_EXITS] = "ITLBREAL", |
122 | [ITLB_VIRT_MISS_EXITS] = "ITLBVIRT", | 122 | [ITLB_VIRT_MISS_EXITS] = "ITLBVIRT", |
123 | [DTLB_REAL_MISS_EXITS] = "DTLBREAL", | 123 | [DTLB_REAL_MISS_EXITS] = "DTLBREAL", |
124 | [DTLB_VIRT_MISS_EXITS] = "DTLBVIRT", | 124 | [DTLB_VIRT_MISS_EXITS] = "DTLBVIRT", |
125 | [SYSCALL_EXITS] = "SYSCALL", | 125 | [SYSCALL_EXITS] = "SYSCALL", |
126 | [ISI_EXITS] = "ISI", | 126 | [ISI_EXITS] = "ISI", |
127 | [DSI_EXITS] = "DSI", | 127 | [DSI_EXITS] = "DSI", |
128 | [EMULATED_INST_EXITS] = "EMULINST", | 128 | [EMULATED_INST_EXITS] = "EMULINST", |
129 | [EMULATED_MTMSRWE_EXITS] = "EMUL_WAIT", | 129 | [EMULATED_MTMSRWE_EXITS] = "EMUL_WAIT", |
130 | [EMULATED_WRTEE_EXITS] = "EMUL_WRTEE", | 130 | [EMULATED_WRTEE_EXITS] = "EMUL_WRTEE", |
131 | [EMULATED_MTSPR_EXITS] = "EMUL_MTSPR", | 131 | [EMULATED_MTSPR_EXITS] = "EMUL_MTSPR", |
132 | [EMULATED_MFSPR_EXITS] = "EMUL_MFSPR", | 132 | [EMULATED_MFSPR_EXITS] = "EMUL_MFSPR", |
133 | [EMULATED_MTMSR_EXITS] = "EMUL_MTMSR", | 133 | [EMULATED_MTMSR_EXITS] = "EMUL_MTMSR", |
134 | [EMULATED_MFMSR_EXITS] = "EMUL_MFMSR", | 134 | [EMULATED_MFMSR_EXITS] = "EMUL_MFMSR", |
135 | [EMULATED_TLBSX_EXITS] = "EMUL_TLBSX", | 135 | [EMULATED_TLBSX_EXITS] = "EMUL_TLBSX", |
136 | [EMULATED_TLBWE_EXITS] = "EMUL_TLBWE", | 136 | [EMULATED_TLBWE_EXITS] = "EMUL_TLBWE", |
137 | [EMULATED_RFI_EXITS] = "EMUL_RFI", | 137 | [EMULATED_RFI_EXITS] = "EMUL_RFI", |
138 | [DEC_EXITS] = "DEC", | 138 | [DEC_EXITS] = "DEC", |
139 | [EXT_INTR_EXITS] = "EXTINT", | 139 | [EXT_INTR_EXITS] = "EXTINT", |
140 | [HALT_WAKEUP] = "HALT", | 140 | [HALT_WAKEUP] = "HALT", |
141 | [USR_PR_INST] = "USR_PR_INST", | 141 | [USR_PR_INST] = "USR_PR_INST", |
142 | [FP_UNAVAIL] = "FP_UNAVAIL", | 142 | [FP_UNAVAIL] = "FP_UNAVAIL", |
143 | [DEBUG_EXITS] = "DEBUG", | 143 | [DEBUG_EXITS] = "DEBUG", |
144 | [TIMEINGUEST] = "TIMEINGUEST" | 144 | [TIMEINGUEST] = "TIMEINGUEST" |
145 | }; | 145 | }; |
146 | 146 | ||
147 | static int kvmppc_exit_timing_show(struct seq_file *m, void *private) | 147 | static int kvmppc_exit_timing_show(struct seq_file *m, void *private) |
148 | { | 148 | { |
149 | struct kvm_vcpu *vcpu = m->private; | 149 | struct kvm_vcpu *vcpu = m->private; |
150 | int i; | 150 | int i; |
151 | u64 min, max; | 151 | |
152 | seq_printf(m, "%s", "type count min max sum sum_squared\n"); | ||
152 | 153 | ||
153 | for (i = 0; i < __NUMBER_OF_KVM_EXIT_TYPES; i++) { | 154 | for (i = 0; i < __NUMBER_OF_KVM_EXIT_TYPES; i++) { |
154 | if (vcpu->arch.timing_min_duration[i] == 0xFFFFFFFF) | 155 | seq_printf(m, "%12s %10d %10lld %10lld %20lld %20lld\n", |
155 | min = 0; | 156 | kvm_exit_names[i], |
156 | else | 157 | vcpu->arch.timing_count_type[i], |
157 | min = vcpu->arch.timing_min_duration[i]; | ||
158 | if (vcpu->arch.timing_max_duration[i] == 0) | ||
159 | max = 0; | ||
160 | else | ||
161 | max = vcpu->arch.timing_max_duration[i]; | ||
162 | |||
163 | seq_printf(m, "%12s: count %10d min %10lld " | ||
164 | "max %10lld sum %20lld sum_quad %20lld\n", | ||
165 | kvm_exit_names[i], vcpu->arch.timing_count_type[i], | ||
166 | vcpu->arch.timing_min_duration[i], | 158 | vcpu->arch.timing_min_duration[i], |
167 | vcpu->arch.timing_max_duration[i], | 159 | vcpu->arch.timing_max_duration[i], |
168 | vcpu->arch.timing_sum_duration[i], | 160 | vcpu->arch.timing_sum_duration[i], |
@@ -171,31 +163,19 @@ static int kvmppc_exit_timing_show(struct seq_file *m, void *private) | |||
171 | return 0; | 163 | return 0; |
172 | } | 164 | } |
173 | 165 | ||
166 | /* Write 'c' to clear the timing statistics. */ | ||
174 | static ssize_t kvmppc_exit_timing_write(struct file *file, | 167 | static ssize_t kvmppc_exit_timing_write(struct file *file, |
175 | const char __user *user_buf, | 168 | const char __user *user_buf, |
176 | size_t count, loff_t *ppos) | 169 | size_t count, loff_t *ppos) |
177 | { | 170 | { |
178 | size_t len; | 171 | int err = -EINVAL; |
179 | int err; | ||
180 | const char __user *p; | ||
181 | char c; | 172 | char c; |
182 | 173 | ||
183 | len = 0; | 174 | if (count > 1) { |
184 | p = user_buf; | ||
185 | while (len < count) { | ||
186 | if (get_user(c, p++)) | ||
187 | err = -EFAULT; | ||
188 | if (c == 0 || c == '\n') | ||
189 | break; | ||
190 | len++; | ||
191 | } | ||
192 | |||
193 | if (len > 1) { | ||
194 | err = -EINVAL; | ||
195 | goto done; | 175 | goto done; |
196 | } | 176 | } |
197 | 177 | ||
198 | if (copy_from_user(&c, user_buf, sizeof(c))) { | 178 | if (get_user(c, user_buf)) { |
199 | err = -EFAULT; | 179 | err = -EFAULT; |
200 | goto done; | 180 | goto done; |
201 | } | 181 | } |
@@ -203,16 +183,13 @@ static ssize_t kvmppc_exit_timing_write(struct file *file, | |||
203 | if (c == 'c') { | 183 | if (c == 'c') { |
204 | struct seq_file *seqf = (struct seq_file *)file->private_data; | 184 | struct seq_file *seqf = (struct seq_file *)file->private_data; |
205 | struct kvm_vcpu *vcpu = seqf->private; | 185 | struct kvm_vcpu *vcpu = seqf->private; |
206 | /* write does not affect out buffers previsously generated with | 186 | /* Write does not affect our buffers previously generated with |
207 | * show. Seq file is locked here to prevent races of init with | 187 | * show. seq_file is locked here to prevent races of init with |
208 | * a show call */ | 188 | * a show call */ |
209 | mutex_lock(&seqf->lock); | 189 | mutex_lock(&seqf->lock); |
210 | kvmppc_init_timing_stats(vcpu); | 190 | kvmppc_init_timing_stats(vcpu); |
211 | mutex_unlock(&seqf->lock); | 191 | mutex_unlock(&seqf->lock); |
212 | err = count; | 192 | err = count; |
213 | } else { | ||
214 | err = -EINVAL; | ||
215 | goto done; | ||
216 | } | 193 | } |
217 | 194 | ||
218 | done: | 195 | done: |
@@ -238,7 +215,7 @@ void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id) | |||
238 | static char dbg_fname[50]; | 215 | static char dbg_fname[50]; |
239 | struct dentry *debugfs_file; | 216 | struct dentry *debugfs_file; |
240 | 217 | ||
241 | snprintf(dbg_fname, sizeof(dbg_fname), "vm%u_vcpu%03u_timing", | 218 | snprintf(dbg_fname, sizeof(dbg_fname), "vm%u_vcpu%u_timing", |
242 | current->pid, id); | 219 | current->pid, id); |
243 | debugfs_file = debugfs_create_file(dbg_fname, 0666, | 220 | debugfs_file = debugfs_create_file(dbg_fname, 0666, |
244 | kvm_debugfs_dir, vcpu, | 221 | kvm_debugfs_dir, vcpu, |
diff --git a/arch/powerpc/kvm/timing.h b/arch/powerpc/kvm/timing.h index 1af7181fa2b5..bb13b1f3cd5a 100644 --- a/arch/powerpc/kvm/timing.h +++ b/arch/powerpc/kvm/timing.h | |||
@@ -45,7 +45,7 @@ static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {} | |||
45 | #endif /* CONFIG_KVM_EXIT_TIMING */ | 45 | #endif /* CONFIG_KVM_EXIT_TIMING */ |
46 | 46 | ||
47 | /* account the exit in kvm_stats */ | 47 | /* account the exit in kvm_stats */ |
48 | static inline void account_exit_stat(struct kvm_vcpu *vcpu, int type) | 48 | static inline void kvmppc_account_exit_stat(struct kvm_vcpu *vcpu, int type) |
49 | { | 49 | { |
50 | /* type has to be known at build time for optimization */ | 50 | /* type has to be known at build time for optimization */ |
51 | BUILD_BUG_ON(__builtin_constant_p(type)); | 51 | BUILD_BUG_ON(__builtin_constant_p(type)); |
@@ -93,10 +93,10 @@ static inline void account_exit_stat(struct kvm_vcpu *vcpu, int type) | |||
93 | } | 93 | } |
94 | 94 | ||
95 | /* wrapper to set exit time and account for it in kvm_stats */ | 95 | /* wrapper to set exit time and account for it in kvm_stats */ |
96 | static inline void account_exit(struct kvm_vcpu *vcpu, int type) | 96 | static inline void kvmppc_account_exit(struct kvm_vcpu *vcpu, int type) |
97 | { | 97 | { |
98 | kvmppc_set_exit_type(vcpu, type); | 98 | kvmppc_set_exit_type(vcpu, type); |
99 | account_exit_stat(vcpu, type); | 99 | kvmppc_account_exit_stat(vcpu, type); |
100 | } | 100 | } |
101 | 101 | ||
102 | #endif /* __POWERPC_KVM_EXITTIMING_H__ */ | 102 | #endif /* __POWERPC_KVM_EXITTIMING_H__ */ |