Making the majority of kernel locks preemptible is the most intrusive change that
PREEMPT_RT makes and this code remains outside of the mainline kernel.
The problem occurs with spinlocks, which are used for much of the kernel locking. A spinlock is a busy-wait mutex which does not require a context switch in the contended case and so is very efficient as long as the lock is held for a short time. Ideally, they should be locked for less than the time it would take to reschedule twice. The following diagram shows threads running on two different CPUs contending the same spinlock. CPU0 gets it first, forcing CPU1 to spin, waiting until it is unlocked:
The thread that holds the spinlock cannot be preempted since doing so may ...