git: d5118d0fc459 - main - vmm stat: Add a special nelems constant for arrays sized by vCPU count.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 18 Nov 2022 18:26:50 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=d5118d0fc4599f69116ec8de59052606e36e6306
commit d5118d0fc4599f69116ec8de59052606e36e6306
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-11-18 18:04:23 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-11-18 18:25:38 +0000
vmm stat: Add a special nelems constant for arrays sized by vCPU count.
Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37170
---
sys/amd64/vmm/io/vlapic.c | 2 +-
sys/amd64/vmm/vmm_stat.c | 3 +++
sys/amd64/vmm/vmm_stat.h | 2 ++
3 files changed, 6 insertions(+), 1 deletion(-)
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 } \