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: Wed, 7 Feb 2024 11:40:03 +0000
From: Hongyan Xia <hongyan.xia2@....com>
To: Lukasz Luba <lukasz.luba@....com>, linux-kernel@...r.kernel.org,
 linux-pm@...r.kernel.org, rafael@...nel.org
Cc: dietmar.eggemann@....com, rui.zhang@...el.com,
 amit.kucheria@...durent.com, amit.kachhap@...il.com,
 daniel.lezcano@...aro.org, viresh.kumar@...aro.org, len.brown@...el.com,
 pavel@....cz, mhiramat@...nel.org, qyousef@...alina.io, wvw@...gle.com,
 xuewen.yan94@...il.com
Subject: Re: [PATCH v7 15/23] PM: EM: Optimize em_cpu_energy() and remove
 division

On 17/01/2024 09:57, Lukasz Luba wrote:
> The Energy Model (EM) can be modified at runtime which brings new
> possibilities. The em_cpu_energy() is called by the Energy Aware Scheduler
> (EAS) in its hot path. The energy calculation uses power value for
> a given performance state (ps) and the CPU busy time as percentage for that
> given frequency.
> 
> It is possible to avoid the division by 'scale_cpu' at runtime, because
> EM is updated whenever new max capacity CPU is set in the system.
> 
> Use that feature and do the needed division during the calculation of the
> coefficient 'ps->cost'. That enhanced 'ps->cost' value can be then just
> multiplied simply by utilization:
> 
> pd_nrg = ps->cost * \Sum cpu_util
> 
> to get the needed energy for whole Performance Domain (PD).
> 
> With this optimization and earlier removal of map_util_freq(), the
> em_cpu_energy() should run faster on the Big CPU by 1.43x and on the Little
> CPU by 1.69x (RockPi 4B board).
> 
> Signed-off-by: Lukasz Luba <lukasz.luba@....com>
> ---
>   include/linux/energy_model.h | 54 ++++++++++--------------------------
>   kernel/power/energy_model.c  |  7 ++---
>   2 files changed, 17 insertions(+), 44 deletions(-)
> 
> diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
> index 689d71f6b56f..aabfc26fcd31 100644
> --- a/include/linux/energy_model.h
> +++ b/include/linux/energy_model.h
> [...]
> @@ -208,8 +206,9 @@ static int em_compute_costs(struct device *dev, struct em_perf_state *table,
>   				return -EINVAL;
>   			}
>   		} else {
> -			power_res = table[i].power;
> -			cost = div64_u64(fmax * power_res, table[i].frequency);
> +			/* increase resolution of 'cost' precision */
> +			power_res = table[i].power * 10;

NIT: Does this have to be 10, or something simple like << 3 (* 8) also 
does the job?

Although compiler these days often are clever enough to convert x * 10 
into (x << 3) + (x << 1), and this is not on the hot path anyway, so 
just a NIT.

> +			cost = power_res / table[i].performance;
>   		}
>   
>   		table[i].cost = cost;

Reviewed-by: Hongyan Xia <hongyan.xia2@....com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ