[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1ca192e6-3a45-45c6-b4f0-be6a89eaf192@arm.com>
Date: Thu, 17 Apr 2025 06:57:50 +0100
From: Lukasz Luba <lukasz.luba@....com>
To: Yaxiong Tian <iambestgod@...com>, rafael@...nel.org
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
Yaxiong Tian <tianyaxiong@...inos.cn>
Subject: Re: [PATCH v4] PM: EM: Fix potential division-by-zero error in
em_compute_costs()
On 4/17/25 02:07, Yaxiong Tian wrote:
> From: Yaxiong Tian <tianyaxiong@...inos.cn>
>
> When the device is of a non-CPU type, table[i].performance won't be
> initialized in the previous em_init_performance(), resulting in division
> by zero when calculating costs in em_compute_costs().
>
> Since the 'cost' algorithm is only used for EAS energy efficiency
> calculations and is currently not utilized by other device drivers, we
> should add the _is_cpu_device(dev) check to prevent this division-by-zero
> issue.
>
> Fixes: 1b600da51073 ("PM: EM: Optimize em_cpu_energy() and remove division")
> Signed-off-by: Yaxiong Tian <tianyaxiong@...inos.cn>
> ---
> kernel/power/energy_model.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
> index d9b7e2b38c7a..41606247c277 100644
> --- a/kernel/power/energy_model.c
> +++ b/kernel/power/energy_model.c
> @@ -233,6 +233,10 @@ static int em_compute_costs(struct device *dev, struct em_perf_state *table,
> unsigned long prev_cost = ULONG_MAX;
> int i, ret;
>
> + /* This is needed only for CPUs and EAS skip other devices */
> + if (!_is_cpu_device(dev))
> + return 0;
> +
> /* Compute the cost of each performance state. */
> for (i = nr_states - 1; i >= 0; i--) {
> unsigned long power_res, cost;
Please stop for a while. I have to check what happened that you
faced the issue in the first place. I have been testing the GPU
EMs and there was no issues...
Let me debug that today.
Powered by blists - more mailing lists