void evcnt_inc(uint32_t c[2]) { int s; s = splhigh(); if (++c[0] == 0) { membar_producer(); c[1]++; } splx(s); } uint64_t evcnt_read(uint32_t c[2]) { struct lwp *l = curlwp; uint64_t ncsw; uint32_t hi, lo; again: ncsw = l->l_ncsw; __insn_barrier(); hi = c[1]; membar_consumer(); lo = c[0]; membar_consumer(); __insn_barrier(); if (hi != c[1] || ncsw != l->l_ncsw) goto again; return ((uint64_t)hi << 32) | lo; }