On Fri, May 15, 2020 at 12:38:44PM +0200, Peter Zijlstra wrote:
>   less := !((s64)(s_a - s_b) <= 0)
> 
>   (v_a - S_a) - (v_b - S_b) == v_a - v_b - S_a + S_b
>                             == v_a - (v_b - S_a + S_b)
> 

> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -469,7 +469,7 @@ bool cfs_prio_less(struct task_struct *a
>  {
>       struct sched_entity *se_a = &a->se, *se_b = &b->se;
>       struct cfs_rq *cfs_rq_a, *cfa_rq_b;
> -     u64 vruntime_a, vruntime_b;
> +     u64 s_a, s_b, S_a, S_b;
>  
>       while (!is_same_tg(se_a, se_b)) {
>               int se_a_depth = se_a->depth;
> @@ -484,10 +484,16 @@ bool cfs_prio_less(struct task_struct *a
>       cfs_rq_a = cfs_rq_of(se_a);
>       cfs_rq_b = cfs_rq_of(se_b);
>  
> -     vruntime_a = se_a->vruntime - cfs_rq_a->core_vruntime;
> -     vruntime_b = se_b->vruntime - cfs_rq_b->core_vruntime;
> +     S_a = cfs_rq_a->core_vruntime;
> +     S_b = cfs_rq_b->core_vruntime;
>  
> -     return !((s64)(vruntime_a - vruntime_b) <= 0);
> +     if (cfs_rq_a == cfs_rq_b)
> +             S_a = S_b = cfs_rq_a->min_vruntime;
> +
> +     s_a = se_a->vruntime - S_a;
> +     s_b = se_b->vruntime - S_b;
> +
> +     return !((s64)(s_a - s_b) <= 0);
>  }

Clearly I'm not awake yet; 's/s_/l_/g', 's/v_/s_/g', IOW:

  l_a = s_a - S_a


Reply via email to