Re: [PATCH 1/3] sched/core: Avoid requeueing a singleton balance callback

From: Tejun Heo

Date: Tue Oct 20 2026 - 14:26:53 EST


Hello, Andrea.

On Tue, Oct 20, 2026 at 10:43:19AM +0200, Andrea Righi wrote:
> When the callback is the only list entry, its next pointer is NULL, so
> the existing duplicate check misses it. Queueing it again links it to
> itself and causes the wait to run twice.

The last entry of a longer list has the same problem. Its next is NULL
and it isn't rq->balance_callback, so it can be queued again:

1. A is queued on an empty list. A->next is NULL.
2. B is queued. The list is B -> A.
3. A is queued again. A->next = B and the list becomes A -> B -> A.

do_balance_callbacks() then runs A twice. This doesn't affect
kick_sync_bal_cb, as nothing gets queued between the SNT_REPICK and
SNT_PICK calls.

Thanks.

--
tejun