lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 24 Apr 2024 10:55:33 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: hupu@...o.com
Cc: mingo@...hat.com, juri.lelli@...hat.com, vincent.guittot@...aro.org,
	dietmar.eggemann@....com, rostedt@...dmis.org, bsegall@...gle.com,
	mgorman@...e.de, bristot@...hat.com, vschneid@...hat.com,
	linux-kernel@...r.kernel.org, wuyun.abel@...edance.com
Subject: Re: [PATCH] sched/fair.c: Fix the calculation method of 'lag' to
 ensure  that the vlag of the task after placement is the same as before.

On Tue, Apr 23, 2024 at 07:44:16PM +0800, hupu@...o.com wrote:
> From: hupu <hupu@...o.com>
> 
> I think the 'lag' calculation here is inaccurate.
> 
> Assume that delta needs to be subtracted from v_i to ensure that the
> vlag of task i after placement is the same as before.

Why ?!? v_i is the unkown, it makes no sense to complicate things by
adding extra unknowns.

> At this time, the
> vlag of task i after placement should be:
> vl'_i = V' - (v_i - delta)

But but but, you can't have V' without knowing v_i.

> From the above formula, we know that vl'_i should be:
> vl'_i = (vl_i * W)/(W + w_i)
> 
> That is to say:
> V' - (v_i - delta) = (vl_i * W)/(W + w_i)
> 
> For a newly added entity, generally set v_i to V', and the above formula
> can be converted into:
> V' - (V' - delta) = (vl_i * W)/(W + w_i)
> 
> Therefore the value of delta should be as follows, where delta is the
> 'lag' in the code.
> delta = (vl_i * W)/(W + w_i)
> 
> Signed-off-by: hupu <hupu@...o.com>
> ---
>  kernel/sched/fair.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 03be0d1330a6..c5f74f753be8 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -5239,9 +5239,12 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
>  		if (curr && curr->on_rq)
>  			load += scale_load_down(curr->load.weight);
>  
> -		lag *= load + scale_load_down(se->load.weight);
> +		lag *= load;
> +
> +		load += scale_load_down(se->load.weight);
>  		if (WARN_ON_ONCE(!load))
>  			load = 1;
> +
>  		lag = div_s64(lag, load);

You're making it:

	v_i = V - (W * vl_i) / (W + w_i)

In direct contradiction to the giant comment right above this that
explains why the code is as it is.

>  	}
>  
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ