Re: [PATCH v12 22/43] rtmutex: Do not stop the chain walk at an owner whose top waiter changed
From: sashiko-bot
Date: Fri Nov 27 2026 - 11:18:47 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] rtmutex: requeue flag not reset in
rt_mutex_adjust_prio_chain()
--
commit 93bf69b06e02028d41139b08a870313be6d420b0
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
rtmutex: Do not stop the chain walk at an owner whose top waiter changed
This commit removes the early exit checks in rt_mutex_adjust_prio_chain()
when a task has no PI waiters or when top_waiter is no longer its top PI
waiter, relying instead on rt_waiter_up_to_date() so that concurrent or
previous-step changes to the task's priority or deadline donor propagate to
the next owner.
> diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
> index c78dfe9c93fc5..b09816977d4e5 100644
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -818,27 +818,14 @@ static int __sched rt_mutex_adjust_prio_chain(struct task_struct *task,
> detect_deadlock = false;
>
> /*
> - * Drop out, when the task has no waiters. Note,
> - * top_waiter can be NULL, when we are in the deboosting
> - * mode!
> + * Do not stop at a task that has no pi waiters, or whose top pi
> + * waiter is not top_waiter. The previous step can have made a
> + * waiter on another lock the top pi waiter of the task. A waiter
> + * can also have left meanwhile, and its own walk can be late. The
> + * priority of the task changed then, and the next owner must
> + * follow. The test below tells whether there is something to pass
> + * on.
> */
> - if (top_waiter) {
> - if (!task_has_pi_waiters(task))
> - goto out_unlock_pi;
> - /*
> - * If deadlock detection is off, we stop here if we
> - * are not the top pi waiter of the task. If deadlock
> - * detection is enabled we continue, but stop the
> - * requeueing in the chain walk.
> - */
> - if (top_waiter != task_top_pi_waiter(task)) {
> - if (!detect_deadlock)
> - goto out_unlock_pi;
> - else
> - requeue = false;
> - }
> - }
> -
> /*
> * If the waiter priority is the same as the task priority
> * then there is no further priority adjustment necessary. The
[Severity: Medium]
Does rt_mutex_adjust_prio_chain() also need to reset requeue to true on each
retry and step when detect_deadlock is enabled?
requeue is initialized to true only once at function entry, and
rt_waiter_up_to_date() sets it to false without ever setting it back to
true:
kernel/locking/rtmutex.c:rt_mutex_adjust_prio_chain() {
...
bool requeue = true;
...
retry:
raw_spin_lock_irq(&task->pi_lock);
...
if (rt_waiter_up_to_date(waiter, task)) {
if (!detect_deadlock)
goto out_unlock_pi;
else
requeue = false;
}
lock = waiter->lock;
if (!raw_spin_trylock(&lock->wait_lock)) {
raw_spin_unlock_irq(&task->pi_lock);
cpu_relax();
goto retry;
}
...
if (!requeue) {
...
goto again;
}
}
Once rt_waiter_up_to_date() sees an up-to-date waiter with detect_deadlock
set and clears requeue, a failed raw_spin_trylock(&lock->wait_lock) drops
task->pi_lock and jumps to retry (or the walk advances to the next owner via
goto again). If task's priority or deadline donor changes while
task->pi_lock is dropped and the other walk is preempted,
rt_waiter_up_to_date() returns false on the next pass, but requeue stays
false and the out-of-date waiter is skipped, leaving the next owner with a
stale priority or deadline donor.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795771147.git.mathieu.desnoyers@xxxxxxxxxxxx?part=22