summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2013-03-16 22:40:20 +0000
committerneel <neel@FreeBSD.org>2013-03-16 22:40:20 +0000
commit8089ec6659b314c029180ab7e322a27747d4d337 (patch)
tree60811a41eb27a0a319975a387e911be77b3bc622 /sys/amd64
parent2462133dfc9a0e178035727038c09022838210df (diff)
downloadFreeBSD-src-8089ec6659b314c029180ab7e322a27747d4d337.zip
FreeBSD-src-8089ec6659b314c029180ab7e322a27747d4d337.tar.gz
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
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/vmm/intel/vmx.c7
-rw-r--r--sys/amd64/vmm/vmm.c6
-rw-r--r--sys/amd64/vmm/vmm_stat.c13
-rw-r--r--sys/amd64/vmm/vmm_stat.h27
4 files changed, 43 insertions, 10 deletions
diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c
index 287ac8c..8db79ce 100644
--- a/sys/amd64/vmm/intel/vmx.c
+++ b/sys/amd64/vmm/intel/vmx.c
@@ -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);
diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c
index 85d277e..174d479 100644
--- a/sys/amd64/vmm/vmm.c
+++ b/sys/amd64/vmm/vmm.c
@@ -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)
diff --git a/sys/amd64/vmm/vmm_stat.c b/sys/amd64/vmm/vmm_stat.c
index ae60979..ae156ee 100644
--- a/sys/amd64/vmm/vmm_stat.c
+++ b/sys/amd64/vmm/vmm_stat.c
@@ -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");
diff --git a/sys/amd64/vmm/vmm_stat.h b/sys/amd64/vmm/vmm_stat.h
index 7c075a6..a1c0967 100644
--- a/sys/amd64/vmm/vmm_stat.h
+++ b/sys/amd64/vmm/vmm_stat.h
@@ -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
OpenPOWER on IntegriCloud