Allow vmm stats to be specific to the underlying hardware assist technology.
This can be done by using the new macros VMM_STAT_INTEL() and VMM_STAT_AMD(). Statistic counters that are common across the two are defined using VMM_STAT(). Suggested by: Anish Gupta Discussed with: grehan Obtained from: NetApp
This commit is contained in:
parent
99f23359a5
commit
61592433eb
@ -153,10 +153,7 @@ static int cap_unrestricted_guest;
|
||||
static int cap_monitor_trap;
|
||||
|
||||
/* statistics */
|
||||
static VMM_STAT_DEFINE(VCPU_MIGRATIONS, "vcpu migration across host cpus");
|
||||
static VMM_STAT_DEFINE(VMEXIT_EXTINT, "vm exits due to external interrupt");
|
||||
static VMM_STAT_DEFINE(VMEXIT_HLT_IGNORED, "number of times hlt was ignored");
|
||||
static VMM_STAT_DEFINE(VMEXIT_HLT, "number of times hlt was intercepted");
|
||||
static VMM_STAT_INTEL(VMEXIT_HLT_IGNORED, "number of times hlt was ignored");
|
||||
|
||||
#ifdef KTR
|
||||
static const char *
|
||||
@ -1216,6 +1213,8 @@ vmx_exit_process(struct vmx *vmx, int vcpu, struct vm_exit *vmexit)
|
||||
qual = vmexit->u.vmx.exit_qualification;
|
||||
vmexit->exitcode = VM_EXITCODE_BOGUS;
|
||||
|
||||
vmm_stat_incr(vmx->vm, vcpu, VMEXIT_COUNT, 1);
|
||||
|
||||
switch (vmexit->u.vmx.exit_reason) {
|
||||
case EXIT_REASON_CR_ACCESS:
|
||||
handled = vmx_emulate_cr_access(vmx, vcpu, qual);
|
||||
|
@ -139,7 +139,7 @@ static MALLOC_DEFINE(M_VM, "vm", "vm");
|
||||
CTASSERT(VMM_MSR_NUM <= 64); /* msr_mask can keep track of up to 64 msrs */
|
||||
|
||||
/* statistics */
|
||||
static VMM_STAT_DEFINE(VCPU_TOTAL_RUNTIME, "vcpu total runtime");
|
||||
static VMM_STAT(VCPU_TOTAL_RUNTIME, "vcpu total runtime");
|
||||
|
||||
static void
|
||||
vcpu_cleanup(struct vcpu *vcpu)
|
||||
@ -612,7 +612,7 @@ save_guest_fpustate(struct vcpu *vcpu)
|
||||
fpu_start_emulating();
|
||||
}
|
||||
|
||||
static VMM_STAT_DEFINE(VCPU_IDLE_TICKS, "number of ticks vcpu was idle");
|
||||
static VMM_STAT(VCPU_IDLE_TICKS, "number of ticks vcpu was idle");
|
||||
|
||||
int
|
||||
vm_run(struct vm *vm, struct vm_run *vmrun)
|
||||
@ -717,7 +717,7 @@ vm_inject_event(struct vm *vm, int vcpuid, int type,
|
||||
return (VMINJECT(vm->cookie, vcpuid, type, vector, code, code_valid));
|
||||
}
|
||||
|
||||
static VMM_STAT_DEFINE(VCPU_NMI_COUNT, "number of NMIs delivered to vcpu");
|
||||
static VMM_STAT(VCPU_NMI_COUNT, "number of NMIs delivered to vcpu");
|
||||
|
||||
int
|
||||
vm_inject_nmi(struct vm *vm, int vcpuid)
|
||||
|
@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/smp.h>
|
||||
|
||||
#include <machine/vmm.h>
|
||||
#include "vmm_util.h"
|
||||
#include "vmm_stat.h"
|
||||
|
||||
static int vstnum;
|
||||
@ -52,6 +53,12 @@ vmm_stat_init(void *arg)
|
||||
if (vst->desc == NULL)
|
||||
return;
|
||||
|
||||
if (vst->scope == VMM_STAT_SCOPE_INTEL && !vmm_is_intel())
|
||||
return;
|
||||
|
||||
if (vst->scope == VMM_STAT_SCOPE_AMD && !vmm_is_amd())
|
||||
return;
|
||||
|
||||
if (vstnum >= MAX_VMM_STAT_TYPES) {
|
||||
printf("Cannot accomodate vmm stat type \"%s\"!\n", vst->desc);
|
||||
return;
|
||||
@ -102,3 +109,9 @@ vmm_stat_desc(int index)
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* global statistics */
|
||||
VMM_STAT(VCPU_MIGRATIONS, "vcpu migration across host cpus");
|
||||
VMM_STAT(VMEXIT_COUNT, "total number of vm exits");
|
||||
VMM_STAT(VMEXIT_EXTINT, "vm exits due to external interrupt");
|
||||
VMM_STAT(VMEXIT_HLT, "number of times hlt was intercepted");
|
||||
|
@ -36,19 +36,36 @@ struct vm;
|
||||
|
||||
#define MAX_VMM_STAT_TYPES 64 /* arbitrary */
|
||||
|
||||
enum vmm_stat_scope {
|
||||
VMM_STAT_SCOPE_ANY,
|
||||
VMM_STAT_SCOPE_INTEL, /* Intel VMX specific statistic */
|
||||
VMM_STAT_SCOPE_AMD, /* AMD SVM specific statistic */
|
||||
};
|
||||
|
||||
struct vmm_stat_type {
|
||||
const char *desc; /* description of statistic */
|
||||
int index; /* position in the stats buffer */
|
||||
const char *desc; /* description of statistic */
|
||||
enum vmm_stat_scope scope;
|
||||
};
|
||||
|
||||
void vmm_stat_init(void *arg);
|
||||
|
||||
#define VMM_STAT_DEFINE(type, desc) \
|
||||
#define VMM_STAT_DEFINE(type, desc, scope) \
|
||||
struct vmm_stat_type type[1] = { \
|
||||
{ desc, -1 } \
|
||||
{ -1, desc, scope } \
|
||||
}; \
|
||||
SYSINIT(type##_stat, SI_SUB_KLD, SI_ORDER_ANY, vmm_stat_init, type)
|
||||
|
||||
#define VMM_STAT_DECLARE(type) \
|
||||
extern struct vmm_stat_type type[1]
|
||||
|
||||
#define VMM_STAT(type, desc) \
|
||||
VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_ANY)
|
||||
#define VMM_STAT_INTEL(type, desc) \
|
||||
VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_INTEL)
|
||||
#define VMM_STAT_AMD(type, desc) \
|
||||
VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_AMD)
|
||||
|
||||
void *vmm_stat_alloc(void);
|
||||
void vmm_stat_free(void *vp);
|
||||
|
||||
@ -68,4 +85,8 @@ vmm_stat_incr(struct vm *vm, int vcpu, struct vmm_stat_type *vst, uint64_t x)
|
||||
#endif
|
||||
}
|
||||
|
||||
VMM_STAT_DECLARE(VCPU_MIGRATIONS);
|
||||
VMM_STAT_DECLARE(VMEXIT_COUNT);
|
||||
VMM_STAT_DECLARE(VMEXIT_EXTINT);
|
||||
VMM_STAT_DECLARE(VMEXIT_HLT);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user