From: Lukasz Luba <lukasz.luba@arm.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Yu-Che Cheng <giver@chromium.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
Zhang Rui <rui.zhang@intel.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Chen-Yu Tsai <wenst@chromium.org>
Subject: Re: [PATCH] thermal: gov_power_allocator: Fix incorrect calculation in divvy_up_power
Date: Fri, 21 Feb 2025 10:35:30 +0000 [thread overview]
Message-ID: <9cc02f9e-9326-4fe1-820b-ca725f68de29@arm.com> (raw)
In-Reply-To: <CAJZ5v0jSh=aOfP7BKTCSxnPGy-XKJKcHNw8bN5PXPH0LA0tAGg@mail.gmail.com>
On 2/20/25 19:45, Rafael J. Wysocki wrote:
> On Wed, Feb 19, 2025 at 8:07 AM Yu-Che Cheng <giver@chromium.org> wrote:
>>
>> divvy_up_power should use weighted_req_power instead of req_power to
>> calculate the granted_power. Otherwise, the granted_power may be
>> unexpected as the denominator total_req_power is weighted sum.
>
> Yes, this is what's happening, to my eyes.
>
>> This is a mistake during the previous refactor.
>>
>> Replace the req_power with weighted_req_power in divvy_up_power
>> calculation.
>>
>> Fixes: 912e97c67cc3 ("thermal: gov_power_allocator: Move memory allocation out of throttle()")
>> Signed-off-by: Yu-Che Cheng <giver@chromium.org>
>> ---
>> drivers/thermal/gov_power_allocator.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
>> index 3b644de3292e..3b626db55b2b 100644
>> --- a/drivers/thermal/gov_power_allocator.c
>> +++ b/drivers/thermal/gov_power_allocator.c
>> @@ -370,7 +370,7 @@ static void divvy_up_power(struct power_actor *power, int num_actors,
>>
>> for (i = 0; i < num_actors; i++) {
>> struct power_actor *pa = &power[i];
>> - u64 req_range = (u64)pa->req_power * power_range;
>> + u64 req_range = (u64)pa->weighted_req_power * power_range;
>>
>> pa->granted_power = DIV_ROUND_CLOSEST_ULL(req_range,
>> total_req_power);
>>
>> ---
>
> And the fix looks good to me.
>
> Lukasz, any concerns?
Good catch! It went through since the test didn't set different weights.
Thanks for the fix!
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
next prev parent reply other threads:[~2025-02-21 10:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-19 7:07 [PATCH] thermal: gov_power_allocator: Fix incorrect calculation in divvy_up_power Yu-Che Cheng
2025-02-20 19:45 ` Rafael J. Wysocki
2025-02-21 10:35 ` Lukasz Luba [this message]
2025-02-21 17:15 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9cc02f9e-9326-4fe1-820b-ca725f68de29@arm.com \
--to=lukasz.luba@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=giver@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=wenst@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox