git: 94a3876d7e18 - main - vmm: fix missing ipi statistic
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 17 Mar 2023 12:50:30 UTC
The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=94a3876d7e18ada9596464623829d37d186da856 commit 94a3876d7e18ada9596464623829d37d186da856 Author: Vitaliy Gusev <gusev.vitaliy@gmail.com> AuthorDate: 2023-03-17 09:17:22 +0000 Commit: Corvin Köhne <corvink@FreeBSD.org> CommitDate: 2023-03-17 12:50:08 +0000 vmm: fix missing ipi statistic ipi counters are missing in bhyvectl's output because vm_maxcpu is 0 when initializing them. That's because vmm_stat_register is executed before vmm_init. Instead of directly fixing it, there's a better solution in illumos which is cherry picked: https://github.com/illumos/illumos-gate/commit/65a3bc83734e5fb0fc2c19df3e5112b87dcdc3f8 It replaces the matrix statistic by two counters per vcpu. One for counting the ipis to the vcpu and one counting the ipis received by the vcpu. This has several advantages: - A matrix statistic becomes huge when using many vcpus. - A matrix statistic easily reaches the MAX_VMM_STAT_ELEMS limit. - Two counters are enough in most cases. DTrace can be used for more advanced debugging purposes. - A matrix statistic wastes memory. The matrix size is determined by vm_maxcpu regardless of the number of vcpus assigned to the vm. Reviewed by: corvink, markj Fixes: ee98f99d7a68b284a669fefb969cbfc31df2d0ab ("vmm: Convert VM_MAXCPU into a loader tunable hw.vmm.maxcpu.") MFC after: 1 week Sponsored by: vStack Differential Revision: https://reviews.freebsd.org/D39038 --- sys/amd64/vmm/io/vlapic.c | 9 ++++++--- sys/amd64/vmm/vmm_stat.c | 3 --- sys/amd64/vmm/vmm_stat.h | 2 -- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sys/amd64/vmm/io/vlapic.c b/sys/amd64/vmm/io/vlapic.c index 884e232b1422..2144cbabd979 100644 --- a/sys/amd64/vmm/io/vlapic.c +++ b/sys/amd64/vmm/io/vlapic.c @@ -905,7 +905,8 @@ vlapic_calcdest(struct vm *vm, cpuset_t *dmask, uint32_t dest, bool phys, } } -static VMM_STAT_ARRAY(IPIS_SENT, VMM_STAT_NELEMS_VCPU, "ipis sent to vcpu"); +static VMM_STAT(VLAPIC_IPI_SEND, "ipis sent from vcpu"); +static VMM_STAT(VLAPIC_IPI_RECV, "ipis received by vcpu"); static void vlapic_set_tpr(struct vlapic *vlapic, uint8_t val) @@ -1102,7 +1103,8 @@ vlapic_icrlo_write_handler(struct vlapic *vlapic, bool *retu) CPU_FOREACH_ISSET(i, &dmask) { vcpu = vm_vcpu(vlapic->vm, i); lapic_intr_edge(vcpu, vec); - vmm_stat_array_incr(vlapic->vcpu, IPIS_SENT, i, 1); + vmm_stat_incr(vlapic->vcpu, VLAPIC_IPI_SEND, 1); + vmm_stat_incr(vcpu, VLAPIC_IPI_RECV, 1); VLAPIC_CTR2(vlapic, "vlapic sending ipi %d to vcpuid %d", vec, i); } @@ -1223,7 +1225,8 @@ vlapic_self_ipi_handler(struct vlapic *vlapic, uint64_t val) vec = val & 0xff; lapic_intr_edge(vlapic->vcpu, vec); - vmm_stat_array_incr(vlapic->vcpu, IPIS_SENT, vlapic->vcpuid, 1); + vmm_stat_incr(vlapic->vcpu, VLAPIC_IPI_SEND, 1); + vmm_stat_incr(vlapic->vcpu, VLAPIC_IPI_RECV, 1); VLAPIC_CTR1(vlapic, "vlapic self-ipi %d", vec); } diff --git a/sys/amd64/vmm/vmm_stat.c b/sys/amd64/vmm/vmm_stat.c index 2750982185aa..2df4423bc60f 100644 --- a/sys/amd64/vmm/vmm_stat.c +++ b/sys/amd64/vmm/vmm_stat.c @@ -70,9 +70,6 @@ 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 050d3c13dda1..e40a960ec82a 100644 --- a/sys/amd64/vmm/vmm_stat.h +++ b/sys/amd64/vmm/vmm_stat.h @@ -58,8 +58,6 @@ 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 } \