Re: weird loadavg on idle machine post 5.7

From: Michal Kubecek
Date: Thu Jul 02 2020 - 19:11:27 EST


On Thu, Jul 02, 2020 at 10:36:27PM +0100, Mel Gorman wrote:
>
> It builds, not booted, it's for discussion but maybe Dave is feeling brave!
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index ca5db40392d4..52c73598b18a 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2592,9 +2592,6 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
> }
>
> #ifdef CONFIG_SMP
> - p->sched_contributes_to_load = !!task_contributes_to_load(p);
> - p->state = TASK_WAKING;
> -
> /*
> * Ensure we load p->on_cpu _after_ p->on_rq, otherwise it would be
> * possible to, falsely, observe p->on_cpu == 0.
> @@ -2650,6 +2647,13 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
> */
> smp_cond_load_acquire(&p->on_cpu, !VAL);
>
> + /*
> + * p is off the cpu and pi_lock is held to p->state is stable
> + * for calculating whether it contributes to load.
> + */
> + p->sched_contributes_to_load = !!task_contributes_to_load(p);
> + p->state = TASK_WAKING;
> +
> cpu = select_task_rq(p, p->wake_cpu, SD_BALANCE_WAKE, wake_flags);
> if (task_cpu(p) != cpu) {
> wake_flags |= WF_MIGRATED;
>
> --

I felt brave but something is probably wrong: I tried to boot three
times and all three attempts crashed during boot, all three in scheduler
related functions:

set_next_entity()
check_preempt_wakeup()
finish_task_switch()

I left my USB-to-serial adapter in the office but I'll try again
tomorrow on a test machine with serial console.

Michal