Once we have the thread lock, we are in a spinlock section and thus will
not be preempted, which ensures stability of 'td_owepreempt'. Check it
again for the improbable case where we were already preempted before
entering that section (after 'td_critnest' reached 0 in critical_exit()
but before clearing 'td_owepreempt', because of an IPI_PREEMPT received
in the meantime or any interrupt whose handler uses critical sections),
in which case there is no need to switch to another thread.
Remove the now obsolete micro-optimization temporarily raising
'td_critnest' around thread_lock(). thread_lock() already enters
a critical section before spinning for the thread lock, but it sometimes
perform a few operation before doing so. The micro-optimization
apparently intended to avoid preemption during that period as anyway we
were going to preempt after holding the lock (see commit 779186434a3d
("Sprinkle some volatile magic (...)")). Re-checking for whether we
actually need to preempt after taking the lock makes it obsolete, and is
a much more broadly-applicable optimization.