thermal: gov_step_wise: Go straight to instance->lower when mitigation is over
PATCH 1/1 thermal: gov_step_wise: Go straight to instance->lower when mitigation is over
From: Rafael J. Wysocki <[email protected]>
Commit b6846826982b ("thermal: gov_step_wise: Restore passive polling management") attempted to fix a Step-Wise thermal governor issue introduced by commit 042a3d80f118 ("thermal: core: Move passive polling management to the core"), which caused the governor to leave cooling devices in high states, by partially revering that commit.
However, this turns out to be insufficient on some systems due to interactions between the governor code restored by commit b6846826982b and the passive polling management in the thermal core.
For this reason, revert commit b6846826982b and make the governor set the target cooling device state to the "lower" one as soon as the zone temperature falls below the threshold of the trip point corresponding to the given thermal instance, which means that thermal mitigation is not necessary any more.
Before this change the "lower" cooling device state would be reached in steps through the passive polling mechanism which was questionable for three reasons: (1) cooling device were kept in high states when that was not necessary (and it could adversely impact performance), (2) it only worked for thermal zones with nonzero passive_delay_jiffies value, and
(3) passive polling belongs to the core and should not be hijacked by governors for their internal purposes.
--- drivers/thermal/gov_step_wise.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-)
drivers/thermal/gov_step_wise.c +5 -18
@@ -55,7 +55,11 @@ static unsigned long get_target_state(stif (cur_state <= instance->lower)return THERMAL_NO_TARGET ; -return clamp (cur_state -1 , instance->lower, instance->upper); +/* +* If 'throttle' is false, no mitigation is necessary, so +* request the lower state for this instance. +*/ +return instance->lower; }return instance->target;
@@ -93,23 +97,6 @@ static void thermal_zone_trip_update(strif (instance->initialized && old_target == instance->target)continue ; -if (trip->type ==THERMAL_TRIP_PASSIVE ) { -/* -* If the target state for this thermal instance -* changes from THERMAL_NO_TARGET to something else, -* ensure that the zone temperature will be updated -* (assuming enabled passive cooling) until it becomes -* THERMAL_NO_TARGET again, or the cooling device may -* not be reset to its initial state. -*/ -if (old_target ==THERMAL_NO_TARGET && - instance->target !=THERMAL_NO_TARGET ) - tz->passive++; -else if (old_target !=THERMAL_NO_TARGET && - instance->target ==THERMAL_NO_TARGET ) - tz->passive--; - } - instance->initialized = true;mutex_lock (&instance->cdev->lock);
Rafael J. Wysocki
maintainerQuoted 68 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Commit
b6846826982b("thermal:gov_step_wise: Restore passive polling management") attempted to fix a Step-Wise thermal governor issue introduced by commit042a3d80f118("thermal: core: Move passive polling management to the core"), which caused the governor to leave cooling devices in high states, by partially revering that commit.However, this turns out to be insufficient on some systems due to interactions between the governor code restored by commit
b6846826982band the passive polling management in the thermal core.For this reason, revert commit
b6846826982band make the governor set the target cooling device state to the "lower" one as soon as the zone temperature falls below the threshold of the trip point corresponding to the given thermal instance, which means that thermal mitigation is not necessary any more.Before this change the "lower" cooling device state would be reached in steps through the passive polling mechanism which was questionable for three reasons: (1) cooling device were kept in high states when that was not necessary (and it could adversely impact performance), (2) it only worked for thermal zones with nonzero
passive_delay_jiffiesvalue, and
(3) passive polling belongs to the core and should not be hijacked by governors for their internal purposes.Fixes b6846826982b ("thermal: gov_step_wise: Restore passive polling management")Reported-by Jens Glathe <[email protected]>Tested-by Jens Glathe <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/thermal/gov_step_wise.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-)Index:
linux-pm/drivers/thermal/gov_step_wise.c
===================================================================drivers/thermal/gov_step_wise.c +5
-11@@ -55,7 +55,11 @@ static unsigned long get_target_state(stif (cur_state <= instance->lower)return THERMAL_NO_TARGET ; -return clamp (cur_state -1 , instance->lower, instance->upper); +/* +* If 'throttle' is false, no mitigation is necessary, so +* request the lower state for this instance. +*/ +return instance->lower; }return instance->target;@@ -93,23 +97,6 @@ static void thermal_zone_trip_update(strif (instance->initialized && old_target == instance->target)continue ; -if (trip->type ==THERMAL_TRIP_PASSIVE ) { -/* -* If the target state for this thermal instance -* changes from THERMAL_NO_TARGET to something else, -* ensure that the zone temperature will be updated -* (assuming enabled passive cooling) until it becomes -* THERMAL_NO_TARGET again, or the cooling device may -* not be reset to its initial state. -*/ - if (old_target == THERMAL_NO_TARGET &&
drivers/thermal/gov_step_wise.c static void thermal_zone_trip_update(str · line 102
Quoted 10 lines
drivers/thermal/gov_step_wise.c +0
-7- instance->target != THERMAL_NO_TARGET) - tz->passive++; - else if (old_target != THERMAL_NO_TARGET && - instance->target == THERMAL_NO_TARGET) - tz->passive--; - } - instance->initialized = true;mutex_lock (&instance->cdev->lock);
If there is no feedback, I'm going to assume that this is fine with everybody.
Thanks!
Hi Rafael,
Quoted 70 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Commit
b6846826982b("thermal:gov_step_wise: Restore passive polling management") attempted to fix a Step-Wise thermal governor issue introduced by commit042a3d80f118("thermal: core: Move passive polling management to the core"), which caused the governor to leave cooling devices in high states, by partially revering that commit.However, this turns out to be insufficient on some systems due to interactions between the governor code restored by commit
b6846826982band the passive polling management in the thermal core.For this reason, revert commit
b6846826982band make the governor set the target cooling device state to the "lower" one as soon as the zone temperature falls below the threshold of the trip point corresponding to the given thermal instance, which means that thermal mitigation is not necessary any more.Before this change the "lower" cooling device state would be reached in steps through the passive polling mechanism which was questionable for three reasons: (1) cooling device were kept in high states when that was not necessary (and it could adversely impact performance), (2) it only worked for thermal zones with nonzero
passive_delay_jiffiesvalue, and
(3) passive polling belongs to the core and should not be hijacked by governors for their internal purposes.Fixes b6846826982b ("thermal: gov_step_wise: Restore passive polling management")Reported-by Jens Glathe <[email protected]>Tested-by Jens Glathe <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/thermal/gov_step_wise.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-)Index:
linux-pm/drivers/thermal/gov_step_wise.c
===================================================================drivers/thermal/gov_step_wise.c +5
-11@@ -55,7 +55,11 @@ static unsigned long get_target_state(stif (cur_state <= instance->lower)return THERMAL_NO_TARGET ; -return clamp (cur_state -1 , instance->lower, instance->upper); +/* +* If 'throttle' is false, no mitigation is necessary, so +* request the lower state for this instance. +*/ +return instance->lower; }return instance->target;@@ -93,23 +97,6 @@ static void thermal_zone_trip_update(strif (instance->initialized && old_target == instance->target)continue ; -if (trip->type ==THERMAL_TRIP_PASSIVE ) { -/* -* If the target state for this thermal instance -* changes from THERMAL_NO_TARGET to something else, -* ensure that the zone temperature will be updated -* (assuming enabled passive cooling) until it becomes -* THERMAL_NO_TARGET again, or the cooling device may -* not be reset to its initial state. -*/ - if (old_target == THERMAL_NO_TARGET &&
drivers/thermal/gov_step_wise.c static void thermal_zone_trip_update(str · line 102
Quoted 10 lines
drivers/thermal/gov_step_wise.c +0
-7- instance->target != THERMAL_NO_TARGET) - tz->passive++; - else if (old_target != THERMAL_NO_TARGET && - instance->target == THERMAL_NO_TARGET) - tz->passive--; - } - instance->initialized = true;mutex_lock (&instance->cdev->lock);
I've tested this here against 6.10.0-rc5 and it looks like it does what it says on the tin now. Locks to low speeds at thermal and (rather quickly) unlocks once it's no longer in the "danger zone"
Quoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Commit
b6846826982b("thermal:gov_step_wise: Restore passive polling management") attempted to fix a Step-Wise thermal governor issue introduced by commit042a3d80f118("thermal: core: Move passive polling management to the core"), which caused the governor to leave cooling devices in high states, by partially revering that commit.
typo: reverting
Quoted 3 lines
However, this turns out to be insufficient on some systems due to interactions between the governor code restored by commit
b6846826982band the passive polling management in the thermal core.
Care to elaborate on what went wrong here? In my test of the previous fix I saw the frequency ramping up in steps as expected when the temperature dropped. Under what circumstances would that fail to happen?
Quoted 6 lines
For this reason, revert commit
b6846826982band make the governor set the target cooling device state to the "lower" one as soon as the zone temperature falls below the threshold of the trip point corresponding to the given thermal instance, which means that thermal mitigation is not necessary any more.
Quoted 7 lines
Before this change the "lower" cooling device state would be reached in steps through the passive polling mechanism which was questionable for three reasons: (1) cooling device were kept in high states when that was not necessary (and it could adversely impact performance), (2) it only worked for thermal zones with nonzero
passive_delay_jiffiesvalue, and
(3) passive polling belongs to the core and should not be hijacked by governors for their internal purposes.
I've tested this patch on the Lenovo ThinkPad X13s, where I could reproduce the rc1 regression, and things works as intended with the fix applied to rc5:
The CPU frequency still oscillates heavily but now with a more sawtoothed curve.
Not sure if it helps with performance, though, as running the CPU at full speed as soon as we drop below the threshold (with hysteresis) also means that we get back to running at the lowest frequency even faster.
Johan
Rafael J. Wysocki
maintainerQuoted 11 lines · Johan Hovold
Quoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Commit
b6846826982b("thermal:gov_step_wise: Restore passive polling management") attempted to fix a Step-Wise thermal governor issue introduced by commit042a3d80f118("thermal: core: Move passive polling management to the core"), which caused the governor to leave cooling devices in high states, by partially revering that commit.typo: reverting
Thanks!
Quoted 7 lines
Quoted 3 lines
However, this turns out to be insufficient on some systems due to interactions between the governor code restored by commit
b6846826982band the passive polling management in the thermal core.Care to elaborate on what went wrong here? In my test of the previous fix I saw the frequency ramping up in steps as expected when the temperature dropped. Under what circumstances would that fail to happen?
System suspend-resume would interfere with that as it would call thermal_zone_device_init().
Quoted 20 lines
Quoted 6 lines
For this reason, revert commit
b6846826982band make the governor set the target cooling device state to the "lower" one as soon as the zone temperature falls below the threshold of the trip point corresponding to the given thermal instance, which means that thermal mitigation is not necessary any more.Quoted 7 lines
Before this change the "lower" cooling device state would be reached in steps through the passive polling mechanism which was questionable for three reasons: (1) cooling device were kept in high states when that was not necessary (and it could adversely impact performance), (2) it only worked for thermal zones with nonzero
passive_delay_jiffiesvalue, and
(3) passive polling belongs to the core and should not be hijacked by governors for their internal purposes.I've tested this patch on the Lenovo ThinkPad X13s, where I could reproduce the rc1 regression, and things works as intended with the fix applied to rc5:
Tested-by Johan Hovold <[email protected]>
Quoted 7 lines
The CPU frequency still oscillates heavily but now with a more sawtoothed curve.
Not sure if it helps with performance, though, as running the CPU at full speed as soon as we drop below the threshold (with hysteresis) also means that we get back to running at the lowest frequency even faster.
True, but assuming that the reason for the mitigation is still there. If it's actually gone, it's better to stop cooling as soon as it can be done.
Thanks!