Re: [tip: sched/core] sched: Fix balance_callback()

From: Peter Zijlstra
Date: Wed Nov 11 2020 - 15:45:09 EST


On Wed, Nov 11, 2020 at 09:30:42PM +0100, Paul Bolle wrote:
> tip-bot2 for Peter Zijlstra schreef op wo 11-11-2020 om 08:23 [+0000]:
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > [...]
> > +static void do_balance_callbacks(struct rq *rq, struct callback_head *head)
> > +{
> > + void (*func)(struct rq *rq);
> > + struct callback_head *next;
> > +
> > + lockdep_assert_held(&rq->lock);
> > +
> > + while (head) {
> > + func = (void (*)(struct rq *))head->func;
> > + next = head->next;
> > + head->next = NULL;
> > + head = next;
>
> Naive question: is there some subtle C-issue that is evaded here by setting
> head->next to NULL prior to copying over it?
>
> (I know this piece of code only got copied around in this patch and this is
> therefor not something that this patch actually introduced.)

It's like list_del_init(), it zeros the entry before unlinking it.
queue_balance_callback() relies on this.