Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 1 | /* |
| 2 | * This program is free software; you can redistribute it and/or modify |
| 3 | * it under the terms of the GNU General Public License, version 2, as |
| 4 | * published by the Free Software Foundation. |
| 5 | * |
| 6 | * This program is distributed in the hope that it will be useful, |
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 9 | * GNU General Public License for more details. |
| 10 | * |
| 11 | * You should have received a copy of the GNU General Public License |
| 12 | * along with this program; if not, write to the Free Software |
| 13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 14 | * |
| 15 | * Copyright IBM Corp. 2008 |
| 16 | * |
| 17 | * Authors: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> |
| 18 | */ |
| 19 | |
| 20 | #ifndef __POWERPC_KVM_EXITTIMING_H__ |
| 21 | #define __POWERPC_KVM_EXITTIMING_H__ |
| 22 | |
| 23 | #include <linux/kvm_host.h> |
| 24 | #include <asm/kvm_host.h> |
| 25 | |
| 26 | #ifdef CONFIG_KVM_EXIT_TIMING |
| 27 | void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu); |
| 28 | void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu); |
| 29 | void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id); |
| 30 | void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu); |
| 31 | |
| 32 | static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) |
| 33 | { |
| 34 | vcpu->arch.last_exit_type = type; |
| 35 | } |
| 36 | |
| 37 | #else |
| 38 | /* if exit timing is not configured there is no need to build the c file */ |
| 39 | static inline void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) {} |
| 40 | static inline void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) {} |
| 41 | static inline void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, |
| 42 | unsigned int id) {} |
| 43 | static inline void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu) {} |
| 44 | static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {} |
| 45 | #endif /* CONFIG_KVM_EXIT_TIMING */ |
| 46 | |
| 47 | /* account the exit in kvm_stats */ |
Hollis Blanchard | 7b70159 | 2008-12-02 15:51:58 -0600 | [diff] [blame] | 48 | static inline void kvmppc_account_exit_stat(struct kvm_vcpu *vcpu, int type) |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 49 | { |
| 50 | /* type has to be known at build time for optimization */ |
Benjamin Herrenschmidt | 38634e6 | 2009-11-05 17:10:34 +1100 | [diff] [blame] | 51 | |
| 52 | /* The BUILD_BUG_ON below breaks in funny ways, commented out |
| 53 | * for now ... -BenH |
Hollis Blanchard | c0a187e | 2009-10-23 00:35:30 +0000 | [diff] [blame] | 54 | BUILD_BUG_ON(!__builtin_constant_p(type)); |
Benjamin Herrenschmidt | 38634e6 | 2009-11-05 17:10:34 +1100 | [diff] [blame] | 55 | */ |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 56 | switch (type) { |
| 57 | case EXT_INTR_EXITS: |
| 58 | vcpu->stat.ext_intr_exits++; |
| 59 | break; |
| 60 | case DEC_EXITS: |
| 61 | vcpu->stat.dec_exits++; |
| 62 | break; |
| 63 | case EMULATED_INST_EXITS: |
| 64 | vcpu->stat.emulated_inst_exits++; |
| 65 | break; |
| 66 | case DCR_EXITS: |
| 67 | vcpu->stat.dcr_exits++; |
| 68 | break; |
| 69 | case DSI_EXITS: |
| 70 | vcpu->stat.dsi_exits++; |
| 71 | break; |
| 72 | case ISI_EXITS: |
| 73 | vcpu->stat.isi_exits++; |
| 74 | break; |
| 75 | case SYSCALL_EXITS: |
| 76 | vcpu->stat.syscall_exits++; |
| 77 | break; |
| 78 | case DTLB_REAL_MISS_EXITS: |
| 79 | vcpu->stat.dtlb_real_miss_exits++; |
| 80 | break; |
| 81 | case DTLB_VIRT_MISS_EXITS: |
| 82 | vcpu->stat.dtlb_virt_miss_exits++; |
| 83 | break; |
| 84 | case MMIO_EXITS: |
| 85 | vcpu->stat.mmio_exits++; |
| 86 | break; |
| 87 | case ITLB_REAL_MISS_EXITS: |
| 88 | vcpu->stat.itlb_real_miss_exits++; |
| 89 | break; |
| 90 | case ITLB_VIRT_MISS_EXITS: |
| 91 | vcpu->stat.itlb_virt_miss_exits++; |
| 92 | break; |
| 93 | case SIGNAL_EXITS: |
| 94 | vcpu->stat.signal_exits++; |
| 95 | break; |
Scott Wood | d30f6e4 | 2011-12-20 15:34:43 +0000 | [diff] [blame] | 96 | case DBELL_EXITS: |
| 97 | vcpu->stat.dbell_exits++; |
| 98 | break; |
| 99 | case GDBELL_EXITS: |
| 100 | vcpu->stat.gdbell_exits++; |
| 101 | break; |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 102 | } |
| 103 | } |
| 104 | |
| 105 | /* wrapper to set exit time and account for it in kvm_stats */ |
Hollis Blanchard | 7b70159 | 2008-12-02 15:51:58 -0600 | [diff] [blame] | 106 | static inline void kvmppc_account_exit(struct kvm_vcpu *vcpu, int type) |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 107 | { |
| 108 | kvmppc_set_exit_type(vcpu, type); |
Hollis Blanchard | 7b70159 | 2008-12-02 15:51:58 -0600 | [diff] [blame] | 109 | kvmppc_account_exit_stat(vcpu, type); |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | #endif /* __POWERPC_KVM_EXITTIMING_H__ */ |