for (unsigned i = 0; i < nthreads; i++) {
error = kthread_create(PRI_NONE, KTHREAD_MUSTJOIN |
KTHREAD_MPSAFE, NULL, worker, (void *)(uintptr_t)i,
&l[i], "npfperf");
KASSERT(error == 0); (void)error;
}
/* Let them spin! */
run = true;
kpause("perf", false, mstohz(NSECS * 1000), NULL);
done = true;
/* Wait until all threads exit and sum the counts. */
for (unsigned i = 0; i < nthreads; i++) {
kthread_join(l[i]);
total += npackets[i];
}
kmem_free(npackets, sizeof(uint64_t) * nthreads);
kmem_free(l, sizeof(lwp_t *) * nthreads);
printf("%u\t%" PRIu64 "\n", nthreads, total / NSECS);
}