Re: [PATCH v23 8/9] sched: Add blocked_donor link to task for smarter mutex handoffs

From: K Prateek Nayak

Date: Fri Oct 31 2025 - 01:03:12 EST


Hello Peter, John,

On 10/30/2025 5:48 AM, John Stultz wrote:
> @@ -958,7 +964,34 @@ static noinline void __sched __mutex_unlock_slowpath(struct mutex *lock, unsigne
>
> raw_spin_lock_irqsave(&lock->wait_lock, flags);
> debug_mutex_unlock(lock);
> - if (!list_empty(&lock->wait_list)) {
> +
> + if (sched_proxy_exec()) {
> + raw_spin_lock(&current->blocked_lock);
> + /*
> + * If we have a task boosting current, and that task was boosting
> + * current through this lock, hand the lock to that task, as that
> + * is the highest waiter, as selected by the scheduling function.
> + */
> + donor = current->blocked_donor;
> + if (donor) {

Any concerns on new waiters always appearing as donors and in-turn
starving the long time waiters on the list?

> + struct mutex *next_lock;
> +
> + raw_spin_lock_nested(&donor->blocked_lock, SINGLE_DEPTH_NESTING);
> + next_lock = __get_task_blocked_on(donor);
> + if (next_lock == lock) {
> + next = donor;
> + __set_task_blocked_on_waking(donor, next_lock);
> + wake_q_add(&wake_q, donor);
> + current->blocked_donor = NULL;
> + }
> + raw_spin_unlock(&donor->blocked_lock);
> + }
> + }
--
Thanks and Regards,
Prateek