aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-11-18 18:04:23 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2022-11-18 18:25:38 +0000
commitd5118d0fc4599f69116ec8de59052606e36e6306 (patch)
tree76c560b1fe1e50e13209e6e7d4580d00e47c4c9f
parent58eefc67a1cf16623c23354efd089f65401c0455 (diff)
downloadsrc-d5118d0fc4599f69116ec8de59052606e36e6306.tar.gz
src-d5118d0fc4599f69116ec8de59052606e36e6306.zip
vmm stat: Add a special nelems constant for arrays sized by vCPU count.
Reviewed by: corvink, markj Differential Revision: https://reviews.freebsd.org/D37170
-rw-r--r--sys/amd64/vmm/io/vlapic.c2
-rw-r--r--sys/amd64/vmm/vmm_stat.c3
-rw-r--r--sys/amd64/vmm/vmm_stat.h2
3 files changed, 6 insertions, 1 deletions
diff --git a/sys/amd64/vmm/io/vlapic.c b/sys/amd64/vmm/io/vlapic.c
index bcfe6b498721..9c61726e77d7 100644
--- a/sys/amd64/vmm/io/vlapic.c
+++ b/sys/amd64/vmm/io/vlapic.c
@@ -905,7 +905,7 @@ vlapic_calcdest(struct vm *vm, cpuset_t *dmask, uint32_t dest, bool phys,
}
}
-static VMM_STAT_ARRAY(IPIS_SENT, VM_MAXCPU, "ipis sent to vcpu");
+static VMM_STAT_ARRAY(IPIS_SENT, VMM_STAT_NELEMS_VCPU, "ipis sent to vcpu");
static void
vlapic_set_tpr(struct vlapic *vlapic, uint8_t val)
diff --git a/sys/amd64/vmm/vmm_stat.c b/sys/amd64/vmm/vmm_stat.c
index 2df4423bc60f..168a380b221b 100644
--- a/sys/amd64/vmm/vmm_stat.c
+++ b/sys/amd64/vmm/vmm_stat.c
@@ -70,6 +70,9 @@ vmm_stat_register(void *arg)
if (vst->scope == VMM_STAT_SCOPE_AMD && !vmm_is_svm())
return;
+ if (vst->nelems == VMM_STAT_NELEMS_VCPU)
+ vst->nelems = VM_MAXCPU;
+
if (vst_num_elems + vst->nelems >= MAX_VMM_STAT_ELEMS) {
printf("Cannot accommodate vmm stat type \"%s\"!\n", vst->desc);
return;
diff --git a/sys/amd64/vmm/vmm_stat.h b/sys/amd64/vmm/vmm_stat.h
index e40a960ec82a..050d3c13dda1 100644
--- a/sys/amd64/vmm/vmm_stat.h
+++ b/sys/amd64/vmm/vmm_stat.h
@@ -58,6 +58,8 @@ struct vmm_stat_type {
void vmm_stat_register(void *arg);
+#define VMM_STAT_NELEMS_VCPU (-1)
+
#define VMM_STAT_FDEFINE(type, nelems, desc, func, scope) \
struct vmm_stat_type type[1] = { \
{ -1, nelems, desc, func, scope } \