vmm_stat.h (248935) | vmm_stat.h (250427) |
---|---|
1/*- 2 * Copyright (c) 2011 NetApp, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2011 NetApp, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/amd64/vmm/vmm_stat.h 248935 2013-03-30 17:46:03Z neel $ | 29 * $FreeBSD: head/sys/amd64/vmm/vmm_stat.h 250427 2013-05-10 02:59:49Z neel $ |
30 */ 31 32#ifndef _VMM_STAT_H_ 33#define _VMM_STAT_H_ 34 35struct vm; 36 | 30 */ 31 32#ifndef _VMM_STAT_H_ 33#define _VMM_STAT_H_ 34 35struct vm; 36 |
37#define MAX_VMM_STAT_TYPES 64 /* arbitrary */ | 37#define MAX_VMM_STAT_ELEMS 64 /* arbitrary */ |
38 39enum vmm_stat_scope { 40 VMM_STAT_SCOPE_ANY, 41 VMM_STAT_SCOPE_INTEL, /* Intel VMX specific statistic */ 42 VMM_STAT_SCOPE_AMD, /* AMD SVM specific statistic */ 43}; 44 45struct vmm_stat_type { 46 int index; /* position in the stats buffer */ | 38 39enum vmm_stat_scope { 40 VMM_STAT_SCOPE_ANY, 41 VMM_STAT_SCOPE_INTEL, /* Intel VMX specific statistic */ 42 VMM_STAT_SCOPE_AMD, /* AMD SVM specific statistic */ 43}; 44 45struct vmm_stat_type { 46 int index; /* position in the stats buffer */ |
47 int nelems; /* standalone or array */ |
|
47 const char *desc; /* description of statistic */ 48 enum vmm_stat_scope scope; 49}; 50 51void vmm_stat_init(void *arg); 52 | 48 const char *desc; /* description of statistic */ 49 enum vmm_stat_scope scope; 50}; 51 52void vmm_stat_init(void *arg); 53 |
53#define VMM_STAT_DEFINE(type, desc, scope) \ | 54#define VMM_STAT_DEFINE(type, nelems, desc, scope) \ |
54 struct vmm_stat_type type[1] = { \ | 55 struct vmm_stat_type type[1] = { \ |
55 { -1, desc, scope } \ | 56 { -1, nelems, desc, scope } \ |
56 }; \ 57 SYSINIT(type##_stat, SI_SUB_KLD, SI_ORDER_ANY, vmm_stat_init, type) 58 59#define VMM_STAT_DECLARE(type) \ 60 extern struct vmm_stat_type type[1] 61 62#define VMM_STAT(type, desc) \ | 57 }; \ 58 SYSINIT(type##_stat, SI_SUB_KLD, SI_ORDER_ANY, vmm_stat_init, type) 59 60#define VMM_STAT_DECLARE(type) \ 61 extern struct vmm_stat_type type[1] 62 63#define VMM_STAT(type, desc) \ |
63 VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_ANY) | 64 VMM_STAT_DEFINE(type, 1, desc, VMM_STAT_SCOPE_ANY) |
64#define VMM_STAT_INTEL(type, desc) \ | 65#define VMM_STAT_INTEL(type, desc) \ |
65 VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_INTEL) | 66 VMM_STAT_DEFINE(type, 1, desc, VMM_STAT_SCOPE_INTEL) |
66#define VMM_STAT_AMD(type, desc) \ | 67#define VMM_STAT_AMD(type, desc) \ |
67 VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_AMD) | 68 VMM_STAT_DEFINE(type, 1, desc, VMM_STAT_SCOPE_AMD) |
68 | 69 |
70#define VMM_STAT_ARRAY(type, nelems, desc) \ 71 VMM_STAT_DEFINE(type, nelems, desc, VMM_STAT_SCOPE_ANY) 72 |
|
69void *vmm_stat_alloc(void); 70void vmm_stat_free(void *vp); 71 72/* 73 * 'buf' should be at least fit 'MAX_VMM_STAT_TYPES' entries 74 */ 75int vmm_stat_copy(struct vm *vm, int vcpu, int *num_stats, uint64_t *buf); | 73void *vmm_stat_alloc(void); 74void vmm_stat_free(void *vp); 75 76/* 77 * 'buf' should be at least fit 'MAX_VMM_STAT_TYPES' entries 78 */ 79int vmm_stat_copy(struct vm *vm, int vcpu, int *num_stats, uint64_t *buf); |
76const char *vmm_stat_desc(int index); | 80int vmm_stat_desc_copy(int index, char *buf, int buflen); |
77 78static void __inline | 81 82static void __inline |
83vmm_stat_array_incr(struct vm *vm, int vcpu, struct vmm_stat_type *vst, 84 int statidx, uint64_t x) 85{ 86#ifdef VMM_KEEP_STATS 87 uint64_t *stats; 88 89 stats = vcpu_stats(vm, vcpu); 90 91 if (vst->index >= 0 && statidx < vst->nelems) 92 stats[vst->index + statidx] += x; 93#endif 94} 95 96 97static void __inline |
|
79vmm_stat_incr(struct vm *vm, int vcpu, struct vmm_stat_type *vst, uint64_t x) 80{ | 98vmm_stat_incr(struct vm *vm, int vcpu, struct vmm_stat_type *vst, uint64_t x) 99{ |
81#ifdef VMM_KEEP_STATS 82 uint64_t *stats = vcpu_stats(vm, vcpu); 83 if (vst->index >= 0) 84 stats[vst->index] += x; | 100 101#ifdef VMM_KEEP_STATS 102 vmm_stat_array_incr(vm, vcpu, vst, 0, x); |
85#endif 86} 87 88VMM_STAT_DECLARE(VCPU_MIGRATIONS); 89VMM_STAT_DECLARE(VMEXIT_COUNT); 90VMM_STAT_DECLARE(VMEXIT_EXTINT); 91VMM_STAT_DECLARE(VMEXIT_HLT); 92VMM_STAT_DECLARE(VMEXIT_CR_ACCESS); --- 13 unchanged lines hidden --- | 103#endif 104} 105 106VMM_STAT_DECLARE(VCPU_MIGRATIONS); 107VMM_STAT_DECLARE(VMEXIT_COUNT); 108VMM_STAT_DECLARE(VMEXIT_EXTINT); 109VMM_STAT_DECLARE(VMEXIT_HLT); 110VMM_STAT_DECLARE(VMEXIT_CR_ACCESS); --- 13 unchanged lines hidden --- |