Re: [patch 27/50] locking/spinlock: Provide RT variant

From: Peter Zijlstra
Date: Wed Jul 14 2021 - 07:26:40 EST


On Tue, Jul 13, 2021 at 05:11:21PM +0200, Thomas Gleixner wrote:

> + * - Non RT spin/rw_locks disable preemption and evtl. interrupts.
> + * Disabling preemption has the side effect of disabling migration and
> + * preventing RCU grace periods.
> + *
> + * The RT substitutions explicitly disable migration and take
> + * rcu_read_lock() across the lock held section.

> +static __always_inline void __rt_spin_lock(spinlock_t *lock)
> +{
> + rtlock_lock(&lock->lock);
> + rcu_read_lock();
> + migrate_disable();
> +}

One notable difference is that regular spinlocks disable preemption (and
hence imply the other things) *before* they acquire the lock, while this
thing does the implied semantics *after* it acquires the lock.

The difference is of course that the acquisition period is not covered
and I don't think anybody actually relies on that, nor do I readily see
how one could.