vmm stat: Add a special nelems constant for arrays sized by vCPU count.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37170
This commit is contained in:
John Baldwin 2022-11-18 10:04:23 -08:00
parent 58eefc67a1
commit d5118d0fc4
3 changed files with 6 additions and 1 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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 } \