timing.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. *
  4. * Copyright IBM Corp. 2008
  5. *
  6. * Authors: Christian Ehrhardt <[email protected]>
  7. */
  8. #ifndef __POWERPC_KVM_EXITTIMING_H__
  9. #define __POWERPC_KVM_EXITTIMING_H__
  10. #include <linux/kvm_host.h>
  11. #ifdef CONFIG_KVM_EXIT_TIMING
  12. void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu);
  13. void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu);
  14. int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
  15. struct dentry *debugfs_dentry);
  16. static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type)
  17. {
  18. vcpu->arch.last_exit_type = type;
  19. }
  20. #else
  21. /* if exit timing is not configured there is no need to build the c file */
  22. static inline void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) {}
  23. static inline void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) {}
  24. static inline int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
  25. struct dentry *debugfs_dentry)
  26. {
  27. return 0;
  28. }
  29. static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {}
  30. #endif /* CONFIG_KVM_EXIT_TIMING */
  31. /* account the exit in kvm_stats */
  32. static inline void kvmppc_account_exit_stat(struct kvm_vcpu *vcpu, int type)
  33. {
  34. /* type has to be known at build time for optimization */
  35. /* The BUILD_BUG_ON below breaks in funny ways, commented out
  36. * for now ... -BenH
  37. BUILD_BUG_ON(!__builtin_constant_p(type));
  38. */
  39. switch (type) {
  40. case EXT_INTR_EXITS:
  41. vcpu->stat.ext_intr_exits++;
  42. break;
  43. case DEC_EXITS:
  44. vcpu->stat.dec_exits++;
  45. break;
  46. case EMULATED_INST_EXITS:
  47. vcpu->stat.emulated_inst_exits++;
  48. break;
  49. case DSI_EXITS:
  50. vcpu->stat.dsi_exits++;
  51. break;
  52. case ISI_EXITS:
  53. vcpu->stat.isi_exits++;
  54. break;
  55. case SYSCALL_EXITS:
  56. vcpu->stat.syscall_exits++;
  57. break;
  58. case DTLB_REAL_MISS_EXITS:
  59. vcpu->stat.dtlb_real_miss_exits++;
  60. break;
  61. case DTLB_VIRT_MISS_EXITS:
  62. vcpu->stat.dtlb_virt_miss_exits++;
  63. break;
  64. case MMIO_EXITS:
  65. vcpu->stat.mmio_exits++;
  66. break;
  67. case ITLB_REAL_MISS_EXITS:
  68. vcpu->stat.itlb_real_miss_exits++;
  69. break;
  70. case ITLB_VIRT_MISS_EXITS:
  71. vcpu->stat.itlb_virt_miss_exits++;
  72. break;
  73. case SIGNAL_EXITS:
  74. vcpu->stat.signal_exits++;
  75. break;
  76. case DBELL_EXITS:
  77. vcpu->stat.dbell_exits++;
  78. break;
  79. case GDBELL_EXITS:
  80. vcpu->stat.gdbell_exits++;
  81. break;
  82. }
  83. }
  84. /* wrapper to set exit time and account for it in kvm_stats */
  85. static inline void kvmppc_account_exit(struct kvm_vcpu *vcpu, int type)
  86. {
  87. kvmppc_set_exit_type(vcpu, type);
  88. kvmppc_account_exit_stat(vcpu, type);
  89. }
  90. #endif /* __POWERPC_KVM_EXITTIMING_H__ */