Thermal governors improvements and a fix
Subsystems (3)
Lukasz Luba
maintainercover Thermal governors improvements and a fix
Hi all,
The patch set introduces one fix (patch 1/3) and two improvements, which are possible thanks to the new helper function [1].
The patch 1/3 with a fix for fair share thermal governor is also sent CC'ed stable, but it's hard to point a particular commit, which back then was for fair_share.c.
The patch set should apply on top of [1].
Regards,
Lukasz
[1] https://lore.kernel.org/linux-pm/[email protected]/
Lukasz Luba (3):
thermal: fair share: lock thermal zone while looping over instances
thermal: fair share: use __thermal_cdev_update()
thermal: power allocator: use __thermal_cdev_update()
drivers/thermal/gov_fair_share.c | 11 +++++++---- drivers/thermal/gov_power_allocator.c | 3 +-- 2 files changed, 8 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.1
Lukasz Luba
maintainerPATCH 1/3 thermal: fair share: lock thermal zone while looping over instances
The tz->lock must be hold during the looping over the instances in that thermal zone. This lock was missing in the governor code since the beginning, so it's hard to point into a particular commit.
--- drivers/thermal/gov_fair_share.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/thermal/gov_fair_share.c +4 -0
@@ -82,6 +82,8 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)int total_instance =0 ;int cur_trip_level =get_trip_level (tz); +mutex_lock (&tz->lock); +list_for_each_entry (instance, &tz->thermal_instances, tz_node) {if (instance->trip != trip)continue ;
@@ -110,6 +112,8 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)mutex_unlock (&instance->cdev->lock);thermal_cdev_update (cdev); } + +mutex_unlock (&tz->lock);return 0 ; }
Signature · 1 line
2.17.1
[thermal: thermal/next] thermal/core/fair share: Lock the thermal zone while looping over instances
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: fef05776eb02238dcad8d5514e666a42572c3f32 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//fef05776eb02238dcad8d5514e666a42572c3f32 Author: Lukasz Luba <[email protected]> AuthorDate: Thu, 22 Apr 2021 16:36:22 +01:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Thu, 22 Apr 2021 23:51:32 +02:00
thermal/core/fair share: Lock the thermal zone while looping over instances
The tz->lock must be hold during the looping over the instances in that thermal zone. This lock was missing in the governor code since the beginning, so it's hard to point into a particular commit.
--- drivers/thermal/gov_fair_share.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/thermal/gov_fair_share.c +4 -0
@@ -82,6 +82,8 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)int total_instance =0 ;int cur_trip_level =get_trip_level (tz); +mutex_lock (&tz->lock); +list_for_each_entry (instance, &tz->thermal_instances, tz_node) {if (instance->trip != trip)continue ;
@@ -110,6 +112,8 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)mutex_unlock (&instance->cdev->lock);thermal_cdev_update (cdev); } + +mutex_unlock (&tz->lock);return 0 ; }
Lukasz Luba
maintainerPATCH 2/3 thermal: fair share: use __thermal_cdev_update()
In reply to Lukasz LubaUse the new helper function and avoid unnecessery second lock/unlock, which was present in old approach with thermal_cdev_update().
--- drivers/thermal/gov_fair_share.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/thermal/gov_fair_share.c +3 -4
@@ -107,10 +107,9 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip) instance->target =get_target_state (tz, cdev, percentage, cur_trip_level); -mutex_lock (&instance->cdev->lock); - instance->cdev->updated = false; -mutex_unlock (&instance->cdev->lock); -thermal_cdev_update (cdev); +mutex_lock (&cdev->lock); +__thermal_cdev_update (cdev); +mutex_unlock (&cdev->lock); }mutex_unlock (&tz->lock);
Signature · 1 line
2.17.1
[thermal: thermal/next] thermal/core/fair share: Use the lockless __thermal_cdev_update() function
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 1a93369810660905f5e89b527cd709fa6832f7c8 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//1a93369810660905f5e89b527cd709fa6832f7c8 Author: Lukasz Luba <[email protected]> AuthorDate: Thu, 22 Apr 2021 16:36:23 +01:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Thu, 22 Apr 2021 23:51:32 +02:00
thermal/core/fair share: Use the lockless __thermal_cdev_update() function
Use the new helper function and avoid unnecessery second lock/unlock, which was present in old approach with thermal_cdev_update().
--- drivers/thermal/gov_fair_share.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/thermal/gov_fair_share.c +3 -4
@@ -107,10 +107,9 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip) instance->target =get_target_state (tz, cdev, percentage, cur_trip_level); -mutex_lock (&instance->cdev->lock); - instance->cdev->updated = false; -mutex_unlock (&instance->cdev->lock); -thermal_cdev_update (cdev); +mutex_lock (&cdev->lock); +__thermal_cdev_update (cdev); +mutex_unlock (&cdev->lock); }mutex_unlock (&tz->lock);
Lukasz Luba
maintainerPATCH 3/3 thermal: power allocator: use __thermal_cdev_update()
In reply to Lukasz LubaUse the new helper function and avoid unnecessery second lock/unlock, which was present in old approach with thermal_cdev_update().
--- drivers/thermal/gov_power_allocator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/thermal/gov_power_allocator.c +1 -2
@@ -301,9 +301,8 @@ power_actor_set_power(struct thermal_cooling_device *cdev, instance->target =clamp_val (state, instance->lower, instance->upper);mutex_lock (&cdev->lock); - cdev->updated = false; +__thermal_cdev_update (cdev);mutex_unlock (&cdev->lock); -thermal_cdev_update (cdev);return 0 ; }
Signature · 1 line
2.17.1
[thermal: thermal/next] thermal/core/power allocator: Use the lockless __thermal_cdev_update() function
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: ab39c8853737158604e154ad3b03639e74082bd6 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//ab39c8853737158604e154ad3b03639e74082bd6 Author: Lukasz Luba <[email protected]> AuthorDate: Thu, 22 Apr 2021 16:36:24 +01:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Thu, 22 Apr 2021 23:51:32 +02:00
thermal/core/power allocator: Use the lockless __thermal_cdev_update() function
Use the new helper function and avoid unnecessery second lock/unlock, which was present in old approach with thermal_cdev_update().
--- drivers/thermal/gov_power_allocator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/thermal/gov_power_allocator.c +1 -2
@@ -301,9 +301,8 @@ power_actor_set_power(struct thermal_cooling_device *cdev, instance->target =clamp_val (state, instance->lower, instance->upper);mutex_lock (&cdev->lock); - cdev->updated = false; +__thermal_cdev_update (cdev);mutex_unlock (&cdev->lock); -thermal_cdev_update (cdev);return 0 ; }
Daniel Lezcano
AppliedQuoted 15 lines · Lukasz Luba
Hi all,
The patch set introduces one fix (patch 1/3) and two improvements, which are possible thanks to the new helper function [1].
The patch 1/3 with a fix for fair share thermal governor is also sent CC'ed stable, but it's hard to point a particular commit, which back then was forfair_share.c.The patch set should apply on top of [1].
Regards,
Lukasz
Quoted 8 lines
Lukasz Luba (3):
thermal: fair share: lock thermal zone while looping over instances
thermal: fair share: use__thermal_cdev_update()
thermal: power allocator: use__thermal_cdev_update()drivers/thermal/gov_fair_share.c | 11 +++++++---- drivers/thermal/gov_power_allocator.c | 3 +-- 2 files changed, 8 insertions(+), 6 deletions(-)
Applied, thanks
Two users left of thermal_cdev_update ;)
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Lukasz Luba
maintainerQuoted 21 lines · Daniel Lezcano
Quoted 20 lines · Lukasz Luba
Hi all,
The patch set introduces one fix (patch 1/3) and two improvements, which are possible thanks to the new helper function [1].
The patch 1/3 with a fix for fair share thermal governor is also sent CC'ed stable, but it's hard to point a particular commit, which back then was forfair_share.c.The patch set should apply on top of [1].
Regards,
Lukasz[1] https://lore.kernel.org/linux-pm/[email protected]/
Lukasz Luba (3):
thermal: fair share: lock thermal zone while looping over instances
thermal: fair share: use__thermal_cdev_update()
thermal: power allocator: use__thermal_cdev_update()
Quoted 5 lines
Quoted 3 lines
drivers/thermal/gov_fair_share.c | 11 +++++++---- drivers/thermal/gov_power_allocator.c | 3 +-- 2 files changed, 8 insertions(+), 6 deletions(-)Applied, thanks
thanks!
Quoted 4 lines
Two users left of
thermal_cdev_update;)
True, I didn't dare to touch them, since that would require more work and understandings :)
Quoted 35 lines · Lukasz Luba
Quoted 23 lines · Daniel Lezcano
Quoted 22 lines · Lukasz Luba
Hi all,
The patch set introduces one fix (patch 1/3) and two improvements, which are possible thanks to the new helper function [1].
The patch 1/3 with a fix for fair share thermal governor is also sent CC'ed stable, but it's hard to point a particular commit, which back then was forfair_share.c.The patch set should apply on top of [1].
Regards,
Lukasz[1]
https://lore.kernel.org/linux-pm/[email protected]/Lukasz Luba (3):
thermal: fair share: lock thermal zone while looping over instances
thermal: fair share: use__thermal_cdev_update()
thermal: power allocator: use__thermal_cdev_update()Quoted 5 lines
Quoted 3 lines
drivers/thermal/gov_fair_share.c | 11 +++++++----
drivers/thermal/gov_power_allocator.c| 3 +--2 files changed, 8 insertions(+), 6 deletions(-)Applied, thanks
thanks!
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Two users left of
thermal_cdev_update;)True, I didn't dare to touch them, since that would require more work and understandings :)
Yeah I agree. The changes are no trivial ...
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog