diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c --- a/sys/dev/hwpmc/hwpmc_amd.c +++ b/sys/dev/hwpmc/hwpmc_amd.c @@ -1173,37 +1173,13 @@ void pmc_amd_finalize(struct pmc_mdep *md) { -#if defined(INVARIANTS) - int classindex, i, ncpus, pmcclass; -#endif + PMCDBG0(MDP, INI, 1, "amd-finalize"); pmc_tsc_finalize(md); - KASSERT(amd_pcpu != NULL, ("[amd,%d] NULL per-cpu array pointer", - __LINE__)); - -#if defined(INVARIANTS) - switch (md->pmd_cputype) { -#if defined(__i386__) - case PMC_CPU_AMD_K7: - classindex = PMC_MDEP_CLASS_INDEX_K7; - pmcclass = PMC_CLASS_K7; - break; -#endif - default: - classindex = PMC_MDEP_CLASS_INDEX_K8; - pmcclass = PMC_CLASS_K8; - } - - KASSERT(md->pmd_classdep[classindex].pcd_class == pmcclass, - ("[amd,%d] pmc class mismatch", __LINE__)); - - ncpus = pmc_cpu_max(); - - for (i = 0; i < ncpus; i++) - KASSERT(amd_pcpu[i] == NULL, ("[amd,%d] non-null pcpu", - __LINE__)); -#endif + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(amd_pcpu[i] == NULL, + ("[amd,%d] non-null pcpu cpu %d", __LINE__, i)); free(amd_pcpu, M_PMC); amd_pcpu = NULL; diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -611,5 +611,9 @@ { PMCDBG0(MDP, INI, 1, "arm64-finalize"); + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(arm64_pcpu[i] == NULL, + ("[arm64,%d] non-null pcpu cpu %d", __LINE__, i)); + free(arm64_pcpu, M_PMC); } diff --git a/sys/dev/hwpmc/hwpmc_armv7.c b/sys/dev/hwpmc/hwpmc_armv7.c --- a/sys/dev/hwpmc/hwpmc_armv7.c +++ b/sys/dev/hwpmc/hwpmc_armv7.c @@ -535,5 +535,9 @@ { PMCDBG0(MDP, INI, 1, "armv7-finalize"); + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(armv7_pcpu[i] == NULL, + ("[armv7,%d] non-null pcpu cpu %d", __LINE__, i)); + free(armv7_pcpu, M_PMC); } diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -1260,6 +1260,10 @@ { PMCDBG0(MDP,INI,1, "core-finalize"); + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(core_pcpu[i] == NULL, + ("[core,%d] non-null pcpu cpu %d", __LINE__, i)); + free(core_pcpu, M_PMC); core_pcpu = NULL; } diff --git a/sys/dev/hwpmc/hwpmc_powerpc.c b/sys/dev/hwpmc/hwpmc_powerpc.c --- a/sys/dev/hwpmc/hwpmc_powerpc.c +++ b/sys/dev/hwpmc/hwpmc_powerpc.c @@ -581,6 +581,11 @@ void pmc_md_finalize(struct pmc_mdep *md) { + PMCDBG0(MDP, INI, 1, "powerpc-finalize"); + + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(powerpc_pcpu[i] == NULL, + ("[powerpc,%d] non-null pcpu cpu %d", __LINE__, i)); free(powerpc_pcpu, M_PMC); powerpc_pcpu = NULL; diff --git a/sys/dev/hwpmc/hwpmc_soft.c b/sys/dev/hwpmc/hwpmc_soft.c --- a/sys/dev/hwpmc/hwpmc_soft.c +++ b/sys/dev/hwpmc/hwpmc_soft.c @@ -456,17 +456,12 @@ void pmc_soft_finalize(struct pmc_mdep *md) { -#ifdef INVARIANTS - int i, ncpus; + PMCDBG0(MDP, INI, 1, "soft-finalize"); - ncpus = pmc_cpu_max(); - for (i = 0; i < ncpus; i++) + for (int i = 0; i < pmc_cpu_max(); i++) KASSERT(soft_pcpu[i] == NULL, ("[soft,%d] non-null pcpu cpu %d", __LINE__, i)); - KASSERT(md->pmd_classdep[PMC_CLASS_INDEX_SOFT].pcd_class == - PMC_CLASS_SOFT, ("[soft,%d] class mismatch", __LINE__)); -#endif ast_deregister(TDA_HWPMC); free(soft_pcpu, M_PMC); soft_pcpu = NULL; diff --git a/sys/dev/hwpmc/hwpmc_tsc.c b/sys/dev/hwpmc/hwpmc_tsc.c --- a/sys/dev/hwpmc/hwpmc_tsc.c +++ b/sys/dev/hwpmc/hwpmc_tsc.c @@ -339,18 +339,12 @@ void pmc_tsc_finalize(struct pmc_mdep *md __diagused) { -#ifdef INVARIANTS - int i, ncpus; + PMCDBG0(MDP, INI, 1, "tsc-finalize"); - ncpus = pmc_cpu_max(); - for (i = 0; i < ncpus; i++) + for (int i = 0; i < pmc_cpu_max(); i++) KASSERT(tsc_pcpu[i] == NULL, ("[tsc,%d] non-null pcpu cpu %d", __LINE__, i)); - KASSERT(md->pmd_classdep[PMC_MDEP_CLASS_INDEX_TSC].pcd_class == - PMC_CLASS_TSC, ("[tsc,%d] class mismatch", __LINE__)); -#endif - free(tsc_pcpu, M_PMC); tsc_pcpu = NULL; } diff --git a/sys/dev/hwpmc/hwpmc_uncore.c b/sys/dev/hwpmc/hwpmc_uncore.c --- a/sys/dev/hwpmc/hwpmc_uncore.c +++ b/sys/dev/hwpmc/hwpmc_uncore.c @@ -758,6 +758,10 @@ { PMCDBG0(MDP,INI,1, "uncore-finalize"); + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(uncore_pcpu[i] == NULL, + ("[uncore,%d] non-null pcpu cpu %d", __LINE__, i)); + free(uncore_pcpu, M_PMC); uncore_pcpu = NULL; }