root/arch/powerpc/kvm/timing.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. kvmppc_set_exit_type
  2. kvmppc_init_timing_stats
  3. kvmppc_update_timing_stats
  4. kvmppc_create_vcpu_debugfs
  5. kvmppc_remove_vcpu_debugfs
  6. kvmppc_set_exit_type
  7. kvmppc_account_exit_stat
  8. kvmppc_account_exit

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

/* [<][>][^][v][top][bottom][index][help] */