Re: [PATCH 1/3] sched/core: Avoid requeueing a singleton balance callback
From: Andrea Righi
Date: Wed Oct 21 2026 - 01:37:43 EST
Hi Tejun,
On Tue, Oct 20, 2026 at 08:20:25AM -1000, Tejun Heo wrote:
> 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.
Ah yes, thanks for pointing that out. Agreed, the head check only covers
the singleton case, but the tail-entry case remains.
I'll keep this fix scoped to the reported issue and address the
duplicate detection for a separate follow-up with Peter.
Thanks,
-Andrea