On Tue, Aug 22, 2023 at 07:57:52PM -0700, Jörn Engel wrote: > > You are right. I'm actually quite surprised how we turn a trylock into > a spinning lock. Now I know, thank you! On that subject, why do we turn a trylock into a spinning lock? Thomas, is there a good argument against a patch like the one below? If the question was ever considered, it seems to have happened outside of mainline. At least I cannot find it in git history. Jörn -- If you cannot make a function run 100x faster, maybe you can call it 100x less often. -- Unknown diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index fcd9ad3f7f2e..5bda84d5879a 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -1255,11 +1255,13 @@ static int __sched rt_mutex_slowtrylock(struct rt_mutex_base *lock) /* * 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. */ - raw_spin_lock_irqsave(&lock->wait_lock, flags); + ret = raw_spin_trylock_irqsave(&lock->wait_lock, flags); + if (!ret) + return 0; ret = __rt_mutex_slowtrylock(lock); raw_spin_unlock_irqrestore(&lock->wait_lock, flags);