Re: [PATCH V4 1/2] sched/fair: Fix load_balance() affinity redo path

From: Peter Zijlstra
Date: Tue Jun 06 2017 - 12:34:08 EST


On Tue, Jun 06, 2017 at 02:30:11PM +0200, Peter Zijlstra wrote:

> So with that the problem is that active_load_balance_cpu_stop() calls
> into can_migrate_task() with ->idle = CPU_IDLE and !dst_grpmask, which
> then goes *bang*. Now active_load_balance_cpu_stop() doesn't need to
> re-evaluate anything, so ideally it would just skip this entirely,
> right?
>
> So why not do #3:
>
> ---
> kernel/sched/fair.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 47a0c552c77b..fd639d32fa4c 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8523,6 +8523,13 @@ static int active_load_balance_cpu_stop(void *data)
> .src_cpu = busiest_rq->cpu,
> .src_rq = busiest_rq,
> .idle = CPU_IDLE,

So I realized that setting CPU_NEW_IDLE here does the 'same' thing.
Except that would be a 'visible' change in the schedstat output (not
sure anybody really cares about that).

> + /*
> + * can_migrate_task() doesn't need to compute new_dst_cpu
> + * for active balancing. Since we have CPU_IDLE, but no
> + * @dst_grpmask we need to make that test go away with lying
> + * about DST_PINNED.
> + */
> + .flags = LBF_DST_PINNED,

But given this is trivial and doesn't have any visible side effects,
this seems 'better'.

> };
>
> schedstat_inc(sd->alb_count);