Re: [PATCH v2 1/5] locking/rtmutex: Stop spinning on the owner when the waiter is woken
From: Sebastian Andrzej Siewior
Date: Mon Nov 16 2026 - 07:06:42 EST
On 2026-11-08 09:13:43 [-0500], Mathieu Desnoyers wrote:
> Fixes: 992caf7f1724 ("locking/rtmutex: Add adaptive spinwait mechanism")
> Cc: stable@xxxxxxxxxxxxxxx
> Reviewed-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
> ---
> kernel/locking/rtmutex.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
> index 5a9534c715b8..323973be2074 100644
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -1516,9 +1516,13 @@ static bool rtmutex_spin_on_owner(struct rt_mutex_base *lock,
> * - current is not longer the top waiter
> * - current is requested to reschedule (redundant
> * for CONFIG_PREEMPT_RCU=y)
> + * - current is woken, by its timeout, a signal or
> + * whatever else would end the sleep the spin
> + * stands in for
> * - the VCPU on which owner runs is preempted
> */
> if (!owner_on_cpu(owner) || need_resched() ||
> + task_is_running(current) ||
Wouldn't it make sense to return true in this case so it can re-evaluate
the situation for timeout/ signal rather than visit the scheduler for no
reason?
Also, wouldn't it make sense to restrict this to
rt_mutex_slowlock_block() (and maybe there to the !TASK_UNINTERRUPTIBLE
case but this might result in too much code) rather than have it also
available rtlock_slowlock_locked() where it makes no difference?
That file is included so having rtlock_slowlock_locked() pass an
argument would remove that branch from code generation.
> !data_race(rt_mutex_waiter_is_top_waiter(lock, waiter))) {
> res = false;
> break;
Sebastian