perf_counter: use atomics instead of mutex