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:65a3bc8373
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:ee98f99d7a
("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
This commit is contained in:
parent
949efdaa1d
commit
94a3876d7e
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 } \
|
||||
|
Loading…
Reference in New Issue
Block a user