mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power
@ 2024-10-21 12:11 ZhengShaobo
  2024-10-21 22:11 ` Lukasz Luba
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: ZhengShaobo @ 2024-10-21 12:11 UTC (permalink / raw)
  To: Lukasz Luba, Rafael J . Wysocki, Daniel Lezcano, Zhang Rui,
	linux-pm, linux-kernel
  Cc: zhuzhangwei, dingchongchong, chendejun, zhengshaobo1

From: zhengshaobo1 <zhengshaobo1@xiaomi.com>

When total_req_power is 0, divvy_up_power() will set granted_power to 0,
and cdev will be limited to the lowest performance. If our polling delay
is set to 200ms, it means that cdev cannot perform better within 200ms
even if cdev has a sudden load. This will affect the performance of cdev
and is not as expected.

For this reason, if nobody requests power, then set the granted power to
the max_power.

Signed-off-by: zhengshaobo1 <zhengshaobo1@xiaomi.com>
---
 drivers/thermal/gov_power_allocator.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index 1b2345a697c5..4301516c0938 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -356,11 +356,19 @@ static void divvy_up_power(struct power_actor *power, int num_actors,
 	u32 extra_power = 0;
 	int i;
 
-	/*
-	 * Prevent division by 0 if none of the actors request power.
-	 */
-	if (!total_req_power)
-		total_req_power = 1;
+	if (!total_req_power) {
+		/*
+		 * Nobody requested anything, just give everybody
+		 * the maximum power
+		 */
+		for (i = 0; i < num_actors; i++) {
+			struct power_actor *pa = &power[i];
+
+			pa->granted_power = pa->max_power;
+		}
+
+		return;
+	}
 
 	for (i = 0; i < num_actors; i++) {
 		struct power_actor *pa = &power[i];
-- 
2.43.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power
  2024-10-21 12:11 [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power ZhengShaobo
@ 2024-10-21 22:11 ` Lukasz Luba
  2024-10-23 10:09 ` Rafael J. Wysocki
  2024-10-24  8:00 ` ZhengShaobo
  2 siblings, 0 replies; 8+ messages in thread
From: Lukasz Luba @ 2024-10-21 22:11 UTC (permalink / raw)
  To: ZhengShaobo
  Cc: zhuzhangwei, Zhang Rui, Daniel Lezcano, Rafael J . Wysocki,
	dingchongchong, chendejun, linux-pm, linux-kernel

Hello ZhengShaobo,

On 10/21/24 13:11, ZhengShaobo wrote:
> From: zhengshaobo1 <zhengshaobo1@xiaomi.com>
> 
> When total_req_power is 0, divvy_up_power() will set granted_power to 0,
> and cdev will be limited to the lowest performance. If our polling delay
> is set to 200ms, it means that cdev cannot perform better within 200ms
> even if cdev has a sudden load. This will affect the performance of cdev
> and is not as expected.
> 
> For this reason, if nobody requests power, then set the granted power to
> the max_power.
> 
> Signed-off-by: zhengshaobo1 <zhengshaobo1@xiaomi.com>
> ---
>   drivers/thermal/gov_power_allocator.c | 18 +++++++++++++-----
>   1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
> index 1b2345a697c5..4301516c0938 100644
> --- a/drivers/thermal/gov_power_allocator.c
> +++ b/drivers/thermal/gov_power_allocator.c
> @@ -356,11 +356,19 @@ static void divvy_up_power(struct power_actor *power, int num_actors,
>   	u32 extra_power = 0;
>   	int i;
>   
> -	/*
> -	 * Prevent division by 0 if none of the actors request power.
> -	 */
> -	if (!total_req_power)
> -		total_req_power = 1;
> +	if (!total_req_power) {
> +		/*
> +		 * Nobody requested anything, just give everybody
> +		 * the maximum power
> +		 */
> +		for (i = 0; i < num_actors; i++) {
> +			struct power_actor *pa = &power[i];
> +
> +			pa->granted_power = pa->max_power;
> +		}
> +
> +		return;
> +	}
>   
>   	for (i = 0; i < num_actors; i++) {
>   		struct power_actor *pa = &power[i];

Thank you for the patch. Good catch of that corner case.

If there is no load on those devices, then the temperature should
be low, lower than the 1st trip point. In that case we should
reset the PID and call allow_maximum_power()...

Although, what if the temperature is higher, e.g. due to
ambient temperature and no load on the devices. Then we
hit that corner case and your code would help.

LGTM,

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power
  2024-10-21 12:11 [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power ZhengShaobo
  2024-10-21 22:11 ` Lukasz Luba
@ 2024-10-23 10:09 ` Rafael J. Wysocki
  2024-10-24  8:05   ` ZhengShaobo
  2024-10-24  8:14   ` ZhengShaobo
  2024-10-24  8:00 ` ZhengShaobo
  2 siblings, 2 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2024-10-23 10:09 UTC (permalink / raw)
  To: ZhengShaobo
  Cc: Lukasz Luba, Rafael J . Wysocki, Daniel Lezcano, Zhang Rui,
	linux-pm, linux-kernel, zhuzhangwei, dingchongchong, chendejun

On Mon, Oct 21, 2024 at 2:12 PM ZhengShaobo <zhengshaobo1@xiaomi.com> wrote:
>
> From: zhengshaobo1 <zhengshaobo1@xiaomi.com>
>
> When total_req_power is 0, divvy_up_power() will set granted_power to 0,
> and cdev will be limited to the lowest performance. If our polling delay
> is set to 200ms, it means that cdev cannot perform better within 200ms
> even if cdev has a sudden load. This will affect the performance of cdev
> and is not as expected.
>
> For this reason, if nobody requests power, then set the granted power to
> the max_power.
>
> Signed-off-by: zhengshaobo1 <zhengshaobo1@xiaomi.com>

I would have applied this, but your S-o-b above needs to be fixed.
Why don't you use your real name there?

If it can be changed to "ZhengShaobo <zhengshaobo1@xiaomi.com>",
please let me know, and I will fix it for you when applying the patch.

> ---
>  drivers/thermal/gov_power_allocator.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
> index 1b2345a697c5..4301516c0938 100644
> --- a/drivers/thermal/gov_power_allocator.c
> +++ b/drivers/thermal/gov_power_allocator.c
> @@ -356,11 +356,19 @@ static void divvy_up_power(struct power_actor *power, int num_actors,
>         u32 extra_power = 0;
>         int i;
>
> -       /*
> -        * Prevent division by 0 if none of the actors request power.
> -        */
> -       if (!total_req_power)
> -               total_req_power = 1;
> +       if (!total_req_power) {
> +               /*
> +                * Nobody requested anything, just give everybody
> +                * the maximum power
> +                */
> +               for (i = 0; i < num_actors; i++) {
> +                       struct power_actor *pa = &power[i];
> +
> +                       pa->granted_power = pa->max_power;
> +               }
> +
> +               return;
> +       }
>
>         for (i = 0; i < num_actors; i++) {
>                 struct power_actor *pa = &power[i];
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power
  2024-10-21 12:11 [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power ZhengShaobo
  2024-10-21 22:11 ` Lukasz Luba
  2024-10-23 10:09 ` Rafael J. Wysocki
@ 2024-10-24  8:00 ` ZhengShaobo
  2024-10-24 15:26   ` Rafael J. Wysocki
  2 siblings, 1 reply; 8+ messages in thread
From: ZhengShaobo @ 2024-10-24  8:00 UTC (permalink / raw)
  To: zhengshaobo1
  Cc: chendejun, chuci, daniel.lezcano, dingchongchong, linux-kernel,
	linux-pm, lukasz.luba, rafael, rui.zhang

On Wed, Oct 23, 2024 at 12:09:44PM +0200, Rafael J. Wysocki wrote:
> On Mon, Oct 21, 2024 at 2:12 PM ZhengShaobo <zhengshaobo1@xiaomi.com> wrote:
> >
> > From: zhengshaobo1 <zhengshaobo1@xiaomi.com>
> >
> > When total_req_power is 0, divvy_up_power() will set granted_power to 0,
> > and cdev will be limited to the lowest performance. If our polling delay
> > is set to 200ms, it means that cdev cannot perform better within 200ms
> > even if cdev has a sudden load. This will affect the performance of cdev
> > and is not as expected.
> >
> > For this reason, if nobody requests power, then set the granted power to
> > the max_power.
> >
> > Signed-off-by: zhengshaobo1 <zhengshaobo1@xiaomi.com>
>
> I would have applied this, but your S-o-b above needs to be fixed.
> Why don't you use your real name there?
>
> If it can be changed to "ZhengShaobo <zhengshaobo1@xiaomi.com>",
> please let me know, and I will fix it for you when applying the patch.
>
Yes, it should be "ZhengShaobo <zhengshaobo1@xiaomi.com>".
I would really appreciate your help in solving this problem.

Thanks,
ZhengShaobo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power
  2024-10-23 10:09 ` Rafael J. Wysocki
@ 2024-10-24  8:05   ` ZhengShaobo
  2024-10-24  8:14   ` ZhengShaobo
  1 sibling, 0 replies; 8+ messages in thread
From: ZhengShaobo @ 2024-10-24  8:05 UTC (permalink / raw)
  To: zhengshaobo1
  Cc: chendejun, chuci, daniel.lezcano, dingchongchong, linux-kernel,
	linux-pm, lukasz.luba, rafael, rui.zhang

On Wed, Oct 23, 2024 at 12:09:44PM +0200, Rafael J. Wysocki wrote:
> On Mon, Oct 21, 2024 at 2:12 PM ZhengShaobo <zhengshaobo1@xiaomi.com> wrote:
> >
> > From: zhengshaobo1 <zhengshaobo1@xiaomi.com>
> >
> > When total_req_power is 0, divvy_up_power() will set granted_power to 0,
> > and cdev will be limited to the lowest performance. If our polling delay
> > is set to 200ms, it means that cdev cannot perform better within 200ms
> > even if cdev has a sudden load. This will affect the performance of cdev
> > and is not as expected.
> >
> > For this reason, if nobody requests power, then set the granted power to
> > the max_power.
> >
> > Signed-off-by: zhengshaobo1 <zhengshaobo1@xiaomi.com>
>
> I would have applied this, but your S-o-b above needs to be fixed.
> Why don't you use your real name there?
>
> If it can be changed to "ZhengShaobo <zhengshaobo1@xiaomi.com>",
> please let me know, and I will fix it for you when applying the patch.
>
Yes, it should be "ZhengShaobo <zhengshaobo1@xiaomi.com>".
I would really appreciate your help in solving this problem.

Thanks,
ZhengShaobo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power
  2024-10-23 10:09 ` Rafael J. Wysocki
  2024-10-24  8:05   ` ZhengShaobo
@ 2024-10-24  8:14   ` ZhengShaobo
  1 sibling, 0 replies; 8+ messages in thread
From: ZhengShaobo @ 2024-10-24  8:14 UTC (permalink / raw)
  To: rafael
  Cc: chendejun, chuci, daniel.lezcano, dingchongchong, linux-kernel,
	linux-pm, lukasz.luba, rui.zhang

On Wed, Oct 23, 2024 at 12:09:44PM +0200, Rafael J. Wysocki wrote:
> On Mon, Oct 21, 2024 at 2:12 PM ZhengShaobo <zhengshaobo1@xiaomi.com> wrote:
> >
> > From: zhengshaobo1 <zhengshaobo1@xiaomi.com>
> >
> > When total_req_power is 0, divvy_up_power() will set granted_power to 0,
> > and cdev will be limited to the lowest performance. If our polling delay
> > is set to 200ms, it means that cdev cannot perform better within 200ms
> > even if cdev has a sudden load. This will affect the performance of cdev
> > and is not as expected.
> >
> > For this reason, if nobody requests power, then set the granted power to
> > the max_power.
> >
> > Signed-off-by: zhengshaobo1 <zhengshaobo1@xiaomi.com>
>
> I would have applied this, but your S-o-b above needs to be fixed.
> Why don't you use your real name there?
>
> If it can be changed to "ZhengShaobo <zhengshaobo1@xiaomi.com>",
> please let me know, and I will fix it for you when applying the patch.
>
Yes, it should be "ZhengShaobo <zhengshaobo1@xiaomi.com>".
I would really appreciate your help in solving this problem.

Thanks,
ZhengShaobo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power
  2024-10-24  8:00 ` ZhengShaobo
@ 2024-10-24 15:26   ` Rafael J. Wysocki
  2024-10-31  4:06     ` ZhengShaobo
  0 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2024-10-24 15:26 UTC (permalink / raw)
  To: ZhengShaobo
  Cc: chendejun, chuci, daniel.lezcano, dingchongchong, linux-kernel,
	linux-pm, lukasz.luba, rafael, rui.zhang

On Thu, Oct 24, 2024 at 10:01 AM ZhengShaobo <zhengshaobo1@xiaomi.com> wrote:
>
> On Wed, Oct 23, 2024 at 12:09:44PM +0200, Rafael J. Wysocki wrote:
> > On Mon, Oct 21, 2024 at 2:12 PM ZhengShaobo <zhengshaobo1@xiaomi.com> wrote:
> > >
> > > From: zhengshaobo1 <zhengshaobo1@xiaomi.com>
> > >
> > > When total_req_power is 0, divvy_up_power() will set granted_power to 0,
> > > and cdev will be limited to the lowest performance. If our polling delay
> > > is set to 200ms, it means that cdev cannot perform better within 200ms
> > > even if cdev has a sudden load. This will affect the performance of cdev
> > > and is not as expected.
> > >
> > > For this reason, if nobody requests power, then set the granted power to
> > > the max_power.
> > >
> > > Signed-off-by: zhengshaobo1 <zhengshaobo1@xiaomi.com>
> >
> > I would have applied this, but your S-o-b above needs to be fixed.
> > Why don't you use your real name there?
> >
> > If it can be changed to "ZhengShaobo <zhengshaobo1@xiaomi.com>",
> > please let me know, and I will fix it for you when applying the patch.
> >
> Yes, it should be "ZhengShaobo <zhengshaobo1@xiaomi.com>".
> I would really appreciate your help in solving this problem.

OK, applied as 6.13 material with the S-o-b tag as per the above, thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power
  2024-10-24 15:26   ` Rafael J. Wysocki
@ 2024-10-31  4:06     ` ZhengShaobo
  0 siblings, 0 replies; 8+ messages in thread
From: ZhengShaobo @ 2024-10-31  4:06 UTC (permalink / raw)
  To: rafael
  Cc: chendejun, chuci, daniel.lezcano, dingchongchong, linux-kernel,
	linux-pm, lukasz.luba, rui.zhang, zhengshaobo1

On Thu, Oct 24, 2024 at 05:26:49PM +0200, Rafael J. Wysocki wrote:
> On Thu, Oct 24, 2024 at 10:01 AM ZhengShaobo <zhengshaobo1@xiaomi.com> wrote:
> >
> > On Wed, Oct 23, 2024 at 12:09:44PM +0200, Rafael J. Wysocki wrote:
> > > On Mon, Oct 21, 2024 at 2:12 PM ZhengShaobo <zhengshaobo1@xiaomi.com> wrote:
> > > >
> > > > From: zhengshaobo1 <zhengshaobo1@xiaomi.com>
> > > >
> > > > When total_req_power is 0, divvy_up_power() will set granted_power to 0,
> > > > and cdev will be limited to the lowest performance. If our polling delay
> > > > is set to 200ms, it means that cdev cannot perform better within 200ms
> > > > even if cdev has a sudden load. This will affect the performance of cdev
> > > > and is not as expected.
> > > >
> > > > For this reason, if nobody requests power, then set the granted power to
> > > > the max_power.
> > > >
> > > > Signed-off-by: zhengshaobo1 <zhengshaobo1@xiaomi.com>
> > >
> > > I would have applied this, but your S-o-b above needs to be fixed.
> > > Why don't you use your real name there?
> > >
> > > If it can be changed to "ZhengShaobo <zhengshaobo1@xiaomi.com>",
> > > please let me know, and I will fix it for you when applying the patch.
> > >
> > Yes, it should be "ZhengShaobo <zhengshaobo1@xiaomi.com>".
> > I would really appreciate your help in solving this problem.
>
> OK, applied as 6.13 material with the S-o-b tag as per the above, thanks!

I would like to backport the patch to android15-6.6, but this needs to be merged
into the maintainer tree. I am wondering when this patch will be merged into your
maintainer tree, and I hope you can let me know.

Thanks,
ZhengShaobo

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-10-31  4:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-21 12:11 [PATCH] thermal: gov_power_allocator: Granted power set to max when nobody request power ZhengShaobo
2024-10-21 22:11 ` Lukasz Luba
2024-10-23 10:09 ` Rafael J. Wysocki
2024-10-24  8:05   ` ZhengShaobo
2024-10-24  8:14   ` ZhengShaobo
2024-10-24  8:00 ` ZhengShaobo
2024-10-24 15:26   ` Rafael J. Wysocki
2024-10-31  4:06     ` ZhengShaobo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®