Re: [PATCH 09/16] sched/fair: Let asymmetric cpu configurations balance at wake-up

Peter Zijlstra
2016-06-02T14:21:17Z

On Mon, May 23, 2016 at 11:58:51AM +0100, Morten Rasmussen wrote:
> Currently, SD_WAKE_AFFINE always takes priority over wakeup balancing if
> SD_BALANCE_WAKE is set on the sched_domains. For asymmetric
> configurations SD_WAKE_AFFINE is only desirable if the waking task's
> compute demand (utilization) is suitable for the cpu capacities
> available within the SD_WAKE_AFFINE sched_domain. If not, let wakeup
> balancing take over (find_idlest_{group, cpu}()).
>
> The assumption is that SD_WAKE_AFFINE is never set for a sched_domain
> containing cpus with different capacities. This is enforced by a
> previous patch based on the SD_ASYM_CPUCAPACITY flag.
>
> Ideally, we shouldn't set 'want_affine' in the first place, but we don't
> know if SD_BALANCE_WAKE is enabled on the sched_domain(s) until we start
> traversing them.

I'm a bit confused...

Lets assume a 2+2 big.little thing with shared LLC:

---------- SD2 ----------

-- SD1 -- -- SD1 --

0 1 2 3

SD1: WAKE_AFFINE, BALANCE_WAKE
SD2: ASYM_CAPACITY, BALANCE_WAKE

t0 used to run on cpu1, t0 used to run on cpu2

cpu0 wakes t0:

want_affine = 1
SD1:
WAKE_AFFINE
cpumask_test_cpu(prev_cpu, sd_mask) == true
affine_sd = SD1
break;

affine_sd != NULL -> affine-wakeup

cpu0 wakes t1:

want_affine = 1
SD1:
WAKE_AFFINE
cpumask_test_cpu(prev_cpu, sd_mask) == false
SD2:
BALANCE_WAKE
sd = SD2

affine_sd == NULL, sd == SD2 -> find_idlest_*()

All without this patch...

So what is this thing doing?