Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Mar 2013 17:46:03 +0000 (UTC)
From:      Neel Natu <neel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r248935 - in head: sys/amd64/vmm sys/amd64/vmm/intel usr.sbin/bhyvectl
Message-ID:  <201303301746.r2UHk30q009830@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: neel
Date: Sat Mar 30 17:46:03 2013
New Revision: 248935
URL: http://svnweb.freebsd.org/changeset/base/248935

Log:
  Add some more stats to keep track of all the reasons that a vcpu is exiting.

Modified:
  head/sys/amd64/vmm/intel/vmx.c
  head/sys/amd64/vmm/vmm_stat.c
  head/sys/amd64/vmm/vmm_stat.h
  head/usr.sbin/bhyvectl/bhyvectl.c

Modified: head/sys/amd64/vmm/intel/vmx.c
==============================================================================
--- head/sys/amd64/vmm/intel/vmx.c	Sat Mar 30 16:33:16 2013	(r248934)
+++ head/sys/amd64/vmm/intel/vmx.c	Sat Mar 30 17:46:03 2013	(r248935)
@@ -1217,9 +1217,11 @@ vmx_exit_process(struct vmx *vmx, int vc
 
 	switch (vmexit->u.vmx.exit_reason) {
 	case EXIT_REASON_CR_ACCESS:
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_CR_ACCESS, 1);
 		handled = vmx_emulate_cr_access(vmx, vcpu, qual);
 		break;
 	case EXIT_REASON_RDMSR:
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_RDMSR, 1);
 		ecx = vmxctx->guest_rcx;
 		error = emulate_rdmsr(vmx->vm, vcpu, ecx);
 		if (error) {
@@ -1229,6 +1231,7 @@ vmx_exit_process(struct vmx *vmx, int vc
 			handled = 1;
 		break;
 	case EXIT_REASON_WRMSR:
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_WRMSR, 1);
 		eax = vmxctx->guest_rax;
 		ecx = vmxctx->guest_rcx;
 		edx = vmxctx->guest_rdx;
@@ -1258,15 +1261,18 @@ vmx_exit_process(struct vmx *vmx, int vc
 			vmexit->exitcode = VM_EXITCODE_HLT;
 		break;
 	case EXIT_REASON_MTF:
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_MTRAP, 1);
 		vmexit->exitcode = VM_EXITCODE_MTRAP;
 		break;
 	case EXIT_REASON_PAUSE:
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_PAUSE, 1);
 		vmexit->exitcode = VM_EXITCODE_PAUSE;
 		break;
 	case EXIT_REASON_INTR_WINDOW:
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_INTR_WINDOW, 1);
 		vmx_clear_int_window_exiting(vmx, vcpu);
 		VMM_CTR0(vmx->vm, vcpu, "Disabling interrupt window exiting");
-		/* FALLTHRU */
+		return (1);
 	case EXIT_REASON_EXT_INTR:
 		/*
 		 * External interrupts serve only to cause VM exits and allow
@@ -1286,10 +1292,12 @@ vmx_exit_process(struct vmx *vmx, int vc
 		return (1);
 	case EXIT_REASON_NMI_WINDOW:
 		/* Exit to allow the pending virtual NMI to be injected */
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_NMI_WINDOW, 1);
 		vmx_clear_nmi_window_exiting(vmx, vcpu);
 		VMM_CTR0(vmx->vm, vcpu, "Disabling NMI window exiting");
 		return (1);
 	case EXIT_REASON_INOUT:
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_INOUT, 1);
 		vmexit->exitcode = VM_EXITCODE_INOUT;
 		vmexit->u.inout.bytes = (qual & 0x7) + 1;
 		vmexit->u.inout.in = (qual & 0x8) ? 1 : 0;
@@ -1299,9 +1307,11 @@ vmx_exit_process(struct vmx *vmx, int vc
 		vmexit->u.inout.eax = (uint32_t)(vmxctx->guest_rax);
 		break;
 	case EXIT_REASON_CPUID:
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_CPUID, 1);
 		handled = vmx_handle_cpuid(vmx->vm, vcpu, vmxctx);
 		break;
 	case EXIT_REASON_EPT_FAULT:
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_EPT_FAULT, 1);
 		gla = vmcs_gla();
 		gpa = vmcs_gpa();
 		cr3 = vmcs_guest_cr3();
@@ -1314,6 +1324,7 @@ vmx_exit_process(struct vmx *vmx, int vc
 		}
 		break;
 	default:
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_UNKNOWN, 1);
 		break;
 	}
 
@@ -1455,6 +1466,7 @@ vmx_run(void *arg, int vcpu, register_t 
 			vmexit->inst_length = 0;
 			vmexit->exitcode = VM_EXITCODE_BOGUS;
 			vmx_astpending_trace(vmx, vcpu, rip);
+			vmm_stat_incr(vmx->vm, vcpu, VMEXIT_ASTPENDING, 1);
 			break;
 		}
 
@@ -1473,6 +1485,9 @@ vmx_run(void *arg, int vcpu, register_t 
 		      handled, vmexit->exitcode);
 	}
 
+	if (!handled)
+		vmm_stat_incr(vmx->vm, vcpu, VMEXIT_USERSPACE, 1);
+
 	VMM_CTR1(vmx->vm, vcpu, "goto userland: exitcode %d",vmexit->exitcode);
 
 	/*

Modified: head/sys/amd64/vmm/vmm_stat.c
==============================================================================
--- head/sys/amd64/vmm/vmm_stat.c	Sat Mar 30 16:33:16 2013	(r248934)
+++ head/sys/amd64/vmm/vmm_stat.c	Sat Mar 30 17:46:03 2013	(r248935)
@@ -115,3 +115,16 @@ VMM_STAT(VCPU_MIGRATIONS, "vcpu migratio
 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");
+VMM_STAT(VMEXIT_CR_ACCESS, "number of times %cr access was intercepted");
+VMM_STAT(VMEXIT_RDMSR, "number of times rdmsr was intercepted");
+VMM_STAT(VMEXIT_WRMSR, "number of times wrmsr was intercepted");
+VMM_STAT(VMEXIT_MTRAP, "number of monitor trap exits");
+VMM_STAT(VMEXIT_PAUSE, "number of times pause was intercepted");
+VMM_STAT(VMEXIT_INTR_WINDOW, "vm exits due to interrupt window opening");
+VMM_STAT(VMEXIT_NMI_WINDOW, "vm exits due to nmi window opening");
+VMM_STAT(VMEXIT_INOUT, "number of times in/out was intercepted");
+VMM_STAT(VMEXIT_CPUID, "number of times cpuid was intercepted");
+VMM_STAT(VMEXIT_EPT_FAULT, "vm exits due to nested page fault");
+VMM_STAT(VMEXIT_UNKNOWN, "number of vm exits for unknown reason");
+VMM_STAT(VMEXIT_ASTPENDING, "number of times astpending at exit");
+VMM_STAT(VMEXIT_USERSPACE, "number of vm exits handled in userspace");

Modified: head/sys/amd64/vmm/vmm_stat.h
==============================================================================
--- head/sys/amd64/vmm/vmm_stat.h	Sat Mar 30 16:33:16 2013	(r248934)
+++ head/sys/amd64/vmm/vmm_stat.h	Sat Mar 30 17:46:03 2013	(r248935)
@@ -89,4 +89,17 @@ VMM_STAT_DECLARE(VCPU_MIGRATIONS);
 VMM_STAT_DECLARE(VMEXIT_COUNT);
 VMM_STAT_DECLARE(VMEXIT_EXTINT);
 VMM_STAT_DECLARE(VMEXIT_HLT);
+VMM_STAT_DECLARE(VMEXIT_CR_ACCESS);
+VMM_STAT_DECLARE(VMEXIT_RDMSR);
+VMM_STAT_DECLARE(VMEXIT_WRMSR);
+VMM_STAT_DECLARE(VMEXIT_MTRAP);
+VMM_STAT_DECLARE(VMEXIT_PAUSE);
+VMM_STAT_DECLARE(VMEXIT_INTR_WINDOW);
+VMM_STAT_DECLARE(VMEXIT_NMI_WINDOW);
+VMM_STAT_DECLARE(VMEXIT_INOUT);
+VMM_STAT_DECLARE(VMEXIT_CPUID);
+VMM_STAT_DECLARE(VMEXIT_EPT_FAULT);
+VMM_STAT_DECLARE(VMEXIT_UNKNOWN);
+VMM_STAT_DECLARE(VMEXIT_ASTPENDING);
+VMM_STAT_DECLARE(VMEXIT_USERSPACE);
 #endif

Modified: head/usr.sbin/bhyvectl/bhyvectl.c
==============================================================================
--- head/usr.sbin/bhyvectl/bhyvectl.c	Sat Mar 30 16:33:16 2013	(r248934)
+++ head/usr.sbin/bhyvectl/bhyvectl.c	Sat Mar 30 17:46:03 2013	(r248935)
@@ -981,7 +981,7 @@ main(int argc, char *argv[])
 			printf("vcpu%d\n", vcpu);
 			for (i = 0; i < num_stats; i++) {
 				desc = vm_get_stat_desc(ctx, i);
-				printf("%-32s\t%ld\n", desc, stats[i]);
+				printf("%-40s\t%ld\n", desc, stats[i]);
 			}
 		}
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303301746.r2UHk30q009830>