Avoid a race when we're setting the event timer while going idle by not reading the next event until we hold the lock and are ready to set the timer.
Previously, cpu_idleclock() could race with another thread trying to set an earlier event. cpu_idleclock() would read the next event time. The other thread would set an earlier event. Then, cpu_idleclock() would acquire the lock and set the event timer based on the later event it had previously read.
By acquiring the lock before reading the next event, cpu_idleclock() will get a consistent view of the next event. And, the other thread will get a consistent view of the state of the timers which are actually set.