timing.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifndef __POWERPC_KVM_EXITTIMING_H__
  20. #define __POWERPC_KVM_EXITTIMING_H__
  21. #include <linux/kvm_host.h>
  22. #include <asm/kvm_host.h>
  23. #ifdef CONFIG_KVM_EXIT_TIMING
  24. void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu);
  25. void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu);
  26. void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id);
  27. void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu);
  28. static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type)
  29. {
  30. vcpu->arch.last_exit_type = type;
  31. }
  32. #else
  33. /* if exit timing is not configured there is no need to build the c file */
  34. static inline void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) {}
  35. static inline void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) {}
  36. static inline void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu,
  37. unsigned int id) {}
  38. static inline void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu) {}
  39. static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {}
  40. #endif /* CONFIG_KVM_EXIT_TIMING */
  41. /* account the exit in kvm_stats */
  42. static inline void kvmppc_account_exit_stat(struct kvm_vcpu *vcpu, int type)
  43. {
  44. /* type has to be known at build time for optimization */
  45. /* The BUILD_BUG_ON below breaks in funny ways, commented out
  46. * for now ... -BenH
  47. BUILD_BUG_ON(!__builtin_constant_p(type));
  48. */
  49. switch (type) {
  50. case EXT_INTR_EXITS:
  51. vcpu->stat.ext_intr_exits++;
  52. break;
  53. case DEC_EXITS:
  54. vcpu->stat.dec_exits++;
  55. break;
  56. case EMULATED_INST_EXITS:
  57. vcpu->stat.emulated_inst_exits++;
  58. break;
  59. case DSI_EXITS:
  60. vcpu->stat.dsi_exits++;
  61. break;
  62. case ISI_EXITS:
  63. vcpu->stat.isi_exits++;
  64. break;
  65. case SYSCALL_EXITS:
  66. vcpu->stat.syscall_exits++;
  67. break;
  68. case DTLB_REAL_MISS_EXITS:
  69. vcpu->stat.dtlb_real_miss_exits++;
  70. break;
  71. case DTLB_VIRT_MISS_EXITS:
  72. vcpu->stat.dtlb_virt_miss_exits++;
  73. break;
  74. case MMIO_EXITS:
  75. vcpu->stat.mmio_exits++;
  76. break;
  77. case ITLB_REAL_MISS_EXITS:
  78. vcpu->stat.itlb_real_miss_exits++;
  79. break;
  80. case ITLB_VIRT_MISS_EXITS:
  81. vcpu->stat.itlb_virt_miss_exits++;
  82. break;
  83. case SIGNAL_EXITS:
  84. vcpu->stat.signal_exits++;
  85. break;
  86. case DBELL_EXITS:
  87. vcpu->stat.dbell_exits++;
  88. break;
  89. case GDBELL_EXITS:
  90. vcpu->stat.gdbell_exits++;
  91. break;
  92. }
  93. }
  94. /* wrapper to set exit time and account for it in kvm_stats */
  95. static inline void kvmppc_account_exit(struct kvm_vcpu *vcpu, int type)
  96. {
  97. kvmppc_set_exit_type(vcpu, type);
  98. kvmppc_account_exit_stat(vcpu, type);
  99. }
  100. #endif /* __POWERPC_KVM_EXITTIMING_H__ */