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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 15 Mar 2021 09:51:14 +0000
From:   Lukasz Luba <lukasz.luba@....com>
To:     gao.yunxiao6@...il.com, daniel.lezcano@...aro.org
Cc:     rui.zhang@...el.com, amitk@...nel.org, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, orsonzhai@...il.com,
        zhang.lyra@...il.com, "jeson.gao" <jeson.gao@...soc.com>
Subject: Re: [PATCH] thermal: power_allocator: using round the division when
 re-divvying up power



On 3/15/21 8:25 AM, gao.yunxiao6@...il.com wrote:
> From: "jeson.gao" <jeson.gao@...soc.com>
> 
> The division is used directly in re-divvying up power, the decimal part will
> be discarded, devices will get less than the extra_actor_power - 1.
> if using round the division to make the calculation more accurate.
> 
> For example:
> actor0 received more than it's max_power, it has the extra_power 759
> actor1 received less than it's max_power, it require extra_actor_power 395
> actor2 received less than it's max_power, it require extra_actor_power 365
> actor1 and actor2 require the total capped_extra_power 760
> 
> using division in re-divvying up power
> actor1 would actually get the extra_actor_power 394
> actor2 would actually get the extra_actor_power 364
> 
> if using round the division in re-divvying up power
> actor1 would actually get the extra_actor_power 394
> actor2 would actually get the extra_actor_power 365
> 
> Signed-off-by: Jeson Gao <jeson.gao@...soc.com>
> ---
>   drivers/thermal/gov_power_allocator.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
> index 92acae53df49..2802a0e13c88 100644
> --- a/drivers/thermal/gov_power_allocator.c
> +++ b/drivers/thermal/gov_power_allocator.c
> @@ -374,9 +374,11 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors,
>   	 */
>   	extra_power = min(extra_power, capped_extra_power);
>   	if (capped_extra_power > 0)
> -		for (i = 0; i < num_actors; i++)
> -			granted_power[i] += (extra_actor_power[i] *
> -					extra_power) / capped_extra_power;
> +		for (i = 0; i < num_actors; i++) {
> +			u64 extra_range = (u64)extra_actor_power[i] * extra_power;
> +			granted_power[i] += DIV_ROUND_CLOSEST_ULL(extra_range,
> +							 capped_extra_power);
> +		}
>   }
>   
>   static int allocate_power(struct thermal_zone_device *tz,
> 

Make sense. There is already DIV_ROUND_CLOSEST_ULL() in that function,
so let's align both. There might be a bit overhead on 32bit machines,
but IPA polling isn't so often there.

Reviewed-by: Lukasz Luba <lukasz.luba@....com>

Regards,
Lukasz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ