Re: [PATCH v3] locking/rtmutex: Always use trylock in rt_mutex_trylock()

From: Peter Zijlstra
Date: Mon Oct 07 2024 - 11:36:11 EST


On Mon, Oct 07, 2024 at 11:29:10AM -0400, Waiman Long wrote:
> diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
> index ebebd0eec7f6..a32bc2bb5d5e 100644
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -1381,10 +1381,13 @@ static int __sched rt_mutex_slowtrylock(struct rt_mutex_base *lock)
> return 0;
>
> /*
> - * The mutex has currently no owner. Lock the wait lock and try to
> - * acquire the lock. We use irqsave here to support early boot calls.
> + * The mutex has currently no owner. Try to lock the wait lock first.
> + * If successful, try to acquire the lock. We use irqsave here to
> + * support early boot calls. Trylock is used all the way to avoid
> + * circular lock dependency.
> */
> - raw_spin_lock_irqsave(&lock->wait_lock, flags);
> + if (!raw_spin_trylock_irqsave(&lock->wait_lock, flags))
> + return 0;
>

NACKED!!!!