diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -554,7 +554,7 @@ void (* teardown_func)(void *), void *arg) { - int curcpumap, i, ncpus = 0; + int curcpumap, ncpus = 0; /* See comments in the !SMP case. */ if (!smp_started) { @@ -575,10 +575,8 @@ */ MPASS(curthread->td_md.md_spinlock_count == 0); - CPU_FOREACH(i) { - if (CPU_ISSET(i, &map)) - ncpus++; - } + CPU_AND(&map, &map, &all_cpus); + ncpus = CPU_COUNT(&map); if (ncpus == 0) panic("ncpus is 0 with non-zero map");